Linux File Communication and Attributes
23 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which command is used to change the permissions of a file?

  • chmod (correct)
  • umask
  • chown
  • chgrp
  • What does the umask command do?

  • Displays current directory contents
  • Changes the owner of a file
  • Changes the group of a file
  • Sets default permissions for newly created files (correct)
  • What permissions does the umask value of 027 allow for the owner, group, and others?

  • Read, write, and execute for the owner, no permissions for group and others
  • All permissions for the owner, write and execute for the group, no permissions for others (correct)
  • All permissions for the owner, no permissions for the group, no permissions for others
  • Read and execute for the owner, write for the group, no permissions for others
  • Which option is required to change permissions recursively within a directory using the chmod command?

    <p>-R</p> Signup and view all the answers

    What must you be to change a file’s group using the chgrp command?

    <p>The owner of the file and a member of the target group</p> Signup and view all the answers

    What is a characteristic feature of symbolic links?

    <p>They provide a way to reference files without duplicating data.</p> Signup and view all the answers

    How are named pipes (FIFOs) typically used in a UNIX-like operating system?

    <p>To facilitate communication between processes.</p> Signup and view all the answers

    What effect does the setuid bit have on an executable file?

    <p>Grants the permissions of the file's owner during execution.</p> Signup and view all the answers

    What does the sticky bit do when set on a directory?

    <p>Allows directory deletion only by the file owner.</p> Signup and view all the answers

    Why might a user create a named pipe in a filesystem?

    <p>To synchronize operations between unrelated processes.</p> Signup and view all the answers

    What distinguishes hard links from symbolic links?

    <p>Hard links maintain the original file's inode and data structure.</p> Signup and view all the answers

    Which type of file would you typically find in the /dev directory?

    <p>Character and block device files.</p> Signup and view all the answers

    What happens to a file when its last hard link is deleted?

    <p>The file is deleted and its data blocks released.</p> Signup and view all the answers

    What is the primary function of named pipes?

    <p>To enable processes to communicate on the same host</p> Signup and view all the answers

    How are symbolic links created in a filesystem?

    <p>Using the ln -s command</p> Signup and view all the answers

    Which of the following statements about file permission bits is true?

    <p>Read bit allows opening and reading the contents of the file.</p> Signup and view all the answers

    What does the setuid bit allow when set on an executable file?

    <p>Grants access to files and processes normally off-limits to users</p> Signup and view all the answers

    Under what condition can files be deleted in a directory with the sticky bit set?

    <p>Only the file's owner can delete the file.</p> Signup and view all the answers

    What command is used to inspect file attributes such as owner and permissions?

    <p>ls -l</p> Signup and view all the answers

    What is a characteristic of a symbolic link?

    <p>It can reference files across different filesystems.</p> Signup and view all the answers

    How do the setgid bits influence newly created files in a directory?

    <p>They ensure new files take on the group ownership of the directory.</p> Signup and view all the answers

    Which bit has been rendered obsolete and is often ignored by modern systems?

    <p>Sticky bit</p> Signup and view all the answers

    What happens when a write bit is set on a file?

    <p>It permits modification of the file's contents only.</p> Signup and view all the answers

    Study Notes

    Serial Ports

    • The first serial port is /dev/tty0
    • It has a major device number of 4 and a minor device number of 0

    Local Domain Sockets

    • Allow communication between processes
    • Only accessible from the local host
    • Referred to through a filesystem object
    • Examples: syslog and the X Window System
    • Created using the "socket" system call
    • Removed using the "rm" or "unlink" system call

    Named Pipes

    • Allow communication between processes on the same host
    • Also known as FIFO files
    • Created using "mknod"
    • Removed using "rm"
    • Similar in purpose to local domain sockets
    • Point to a file by name
    • Distinct from the files they point to
    • Created using "ln -s"
    • Removed using "rm"
    • Can refer to files on other filesystems or nonexistent files

    File Attributes

    • Nine permission bits control read, write, and execute access
    • Three additional bits make up the file's "mode"
    • Owner and superuser can modify permissions using the "chmod" command.

    File Permissions

    • Only the most specific permissions apply
    • Regular Files:
      • Read bit allows reading the file
      • Write bit allows modifying the file contents, but not deleting or renaming it
      • Execute bit allows the file to be executed (binaries and scripts)
    • Directories:
      • Execute bit allows entering the directory (search bit)
      • Read and execute allows listing directory contents
      • Write and execute allows creating, deleting, and renaming files inside the directory

    Setuid & Setgid Bits

    • Setuid (4000) allows programs to access files and processes that would usually be off-limits
    • Setgid (2000) causes newly created files in a directory to inherit the directory's group ownership

    Sticky Bit

    • Octal value: 1000
    • Modern systems ignore it when set on regular files.
    • If set on a directory, prevents deletion or renaming of files unless you are the directory owner, file owner, or superuser

    ls Command

    • Allows inspection of link count, owner, group, mode, size, access/modification timestamps, and file type
    • Use "ls -l" for detailed info
    • "ls -ld" for directory info
    • Directories have at least two hard links: one from the parent directory ("..") and one from the special "." file
    • "/etc/fstab" lists filesystems that are normally mounted on the system
    • "umount" detaches filesystems

    File Tree Organization

    • Files are divided by function
    • The root filesystem includes the root directory ("/") and essential files/subdirectories
    • Common directories:
      • /boot: OS kernel
      • /etc: Critical system and configuration files
      • /sbin & /bin: Important utilities
      • /tmp: Temporary files
      • /dev: Devices
      • /lib or /lib64: Shared library files
      • /usr: Standard programs, manuals, libraries
      • /var: Spool directories, log files, accounting info, variable data

    File Types

    • Regular files: Series of bytes
    • Directories: Named references to files
    • Character device files: Device drivers present a standard communication interface that looks like a regular file
    • Block device files: Similar to character devices
    • Local domain sockets: Communication between processes on the same host
    • Named pipes: Communication between processes on the same host (FIFO files)
    • Symbolic links: Point to files by name
    • The first character of the "ls" output indicates the file type

    Regular Files

    • Consist of a series of bytes
    • Filesystems don't impose structure
    • Text, data, executable programs, and shared libraries are stored as regular files
    • Support sequential and random access

    Directories

    • Contain named references to other files
    • Created using "mkdir" and deleted using "rmdir" (if empty)
    • "." refers to the directory itself, ".." refers to the parent directory
    • File names are stored in the parent directory, not within the file itself
    • Multiple directories can refer to the same file
    • Hard links are synonymous with the original file
    • Filesystem tracks the number of hard links; data blocks aren't freed until the last link is deleted
    • Cannot cross filesystems
    • Created using "ln" and removed using "rm"

    Character and Block Device Files

    • Kernel drivers handle the specifics of managing devices
    • Device drivers present a standardized interface to the kernel that looks like a regular file
    • These "device files" are rendezvous points for communication with drivers
    • Identified by major and minor device numbers
      • Major device number: Driver responsible
      • Minor device number: Specific physical device unit

    Other "ls" Options:

    • "-a": show all files (including hidden ones - "." and ".." are always hidden)
    • "-l": long listing of files
    • "-R": recursively applies options to directories
    • "-t": sort by modification date and time
    • "-S": sort by file size
    • "-h": human readable file sizes

    chmod: Change Permissions

    • Only the owner of the file and the superuser can change permissions
    • Accepts octal notation and mnemonic syntax:
      • Octal: chmod 711 myprog (rwx-r-x)
      • Mnemonic: chmod u+x myprog (add execute permission for user )
    • "--reference=filea": copy permissions from filea to fileb
    • "-R" option: recursively applies permissions to a directory

    chown & chgrp: Change Ownership and Group

    • To change the group, you must be the superuser or the file owner and a member of the target group
    • chown is now a privileged operation
    • "-R" flag: recursive application
    • chown can change owner and group simultaneously using syntax: chown user:group file

    umask: Assign Default Permissions

    • Sets the shell's default permissions (umask)
    • Inherited by commands run by the shell
    • Specified as a three-digit octal value representing permissions to take away
    • Example: umask 027 (remove write permission for group, all permissions for others)

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    SNA_Filesystems PDF

    Description

    Test your knowledge on serial ports, local domain sockets, named pipes, symbolic links, and file attributes in Linux. This quiz covers essential concepts regarding inter-process communication and file permission management. Assess your understanding and improve your Linux skills!

    More Like This

    Use Quizgecko on...
    Browser
    Browser