Podcast
Questions and Answers
Which command is used to change the permissions of a file?
Which command is used to change the permissions of a file?
What does the umask command do?
What does the umask command do?
What permissions does the umask value of 027 allow for the owner, group, and others?
What permissions does the umask value of 027 allow for the owner, group, and others?
Which option is required to change permissions recursively within a directory using the chmod command?
Which option is required to change permissions recursively within a directory using the chmod command?
Signup and view all the answers
What must you be to change a file’s group using the chgrp command?
What must you be to change a file’s group using the chgrp command?
Signup and view all the answers
What is a characteristic feature of symbolic links?
What is a characteristic feature of symbolic links?
Signup and view all the answers
How are named pipes (FIFOs) typically used in a UNIX-like operating system?
How are named pipes (FIFOs) typically used in a UNIX-like operating system?
Signup and view all the answers
What effect does the setuid bit have on an executable file?
What effect does the setuid bit have on an executable file?
Signup and view all the answers
What does the sticky bit do when set on a directory?
What does the sticky bit do when set on a directory?
Signup and view all the answers
Why might a user create a named pipe in a filesystem?
Why might a user create a named pipe in a filesystem?
Signup and view all the answers
What distinguishes hard links from symbolic links?
What distinguishes hard links from symbolic links?
Signup and view all the answers
Which type of file would you typically find in the /dev directory?
Which type of file would you typically find in the /dev directory?
Signup and view all the answers
What happens to a file when its last hard link is deleted?
What happens to a file when its last hard link is deleted?
Signup and view all the answers
What is the primary function of named pipes?
What is the primary function of named pipes?
Signup and view all the answers
How are symbolic links created in a filesystem?
How are symbolic links created in a filesystem?
Signup and view all the answers
Which of the following statements about file permission bits is true?
Which of the following statements about file permission bits is true?
Signup and view all the answers
What does the setuid bit allow when set on an executable file?
What does the setuid bit allow when set on an executable file?
Signup and view all the answers
Under what condition can files be deleted in a directory with the sticky bit set?
Under what condition can files be deleted in a directory with the sticky bit set?
Signup and view all the answers
What command is used to inspect file attributes such as owner and permissions?
What command is used to inspect file attributes such as owner and permissions?
Signup and view all the answers
What is a characteristic of a symbolic link?
What is a characteristic of a symbolic link?
Signup and view all the answers
How do the setgid bits influence newly created files in a directory?
How do the setgid bits influence newly created files in a directory?
Signup and view all the answers
Which bit has been rendered obsolete and is often ignored by modern systems?
Which bit has been rendered obsolete and is often ignored by modern systems?
Signup and view all the answers
What happens when a write bit is set on a file?
What happens when a write bit is set on a file?
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
Symbolic Links
- 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
Hard Links
- 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.
Related Documents
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!