ULSAH Quiz 4 (Ch. 5, 20, 21, 22, and 30)
ls File Type Encoding
- Regular File d Directory (Only one not removed by just rm) c Character device file b Block device file s Local domain socket p Named pipe
ls Options
-i inode number -a show all entries in a directory -t sort files by modification time -tr sort files by modification time in reverse -F show names of files in a way that distinguishes directories and executable files -R to list recursively -h to show file sizes in human-readable form
Which two directories must be available to enable the system to come up all the way to multiuser mode?
/usr and /var
Which directories are the most common candidates for having their own partitions?
/var, /tmp, and user home directories
Four Main Components of Filesystem
1. A namespace - a way to name things and organize them in a hierarchy 2. An API - a set of system calls for navigating and manipulating objects 3. Security models - schemes for protecting, hiding, and sharing things 4. An implementation - software to tie the logical model to the hardware
Seven Types of Files
1. Regular files 2. Directories 3. Character device files 4. Block device files 5. Local domain sockets 6. Named pipes (FIFOs) 7. Symbolic links
Predominant Filesystem Standards Supported by Kernel
1. ext4 2. XFS 3. UFS 4. ZFS (Oracle) 5. Btrfs (Oracle) 6. FAT (Windows) 7. NTFS (Windows) 8. ISO 9660 (Older CD-ROMs)
Permission Bits
9 permission bits that control who can read, write, and execute the contents of a file. 3 for the owner, 3 for the group owners, and 3 for everyone else. Can be expressed in octal as 4, 2, and 1.
Named Pipes
Allow communication between two processes running on the same host. Also known as FIFO files. Created with mknod and removed with rm.
Write Bit
Allows the contents of the file to be modified or truncated, but the ability to delete or rename the file is controlled by the permissions on its parent directory.
Execute Bit
Allows the file to be executed. When set on a directory, it only allows the directory to be entered or passed through as a pathname is evaluated.
Read Bit
Allows the file to be opened and read.
chown and chgrp
Change owner and group owner for a file
chmod
Changes the permission on a file.
Sockets
Connections between processes that allow them to communicate hygienically.
Regular Files
Consist of a series of bytes and have no imposed structure. Allows both sequential access and random access. Examples: text files, data files, executable programs, and shared libraries.
Directory
Contains named references to other files. Created with mkdir and deleted with rm -r.
/etc
Critical system and configuration files
umount
Detaches filesystems. Cannot have any open files or processes. -f forces an unmount, but is almost always a bad idea.
file
Determine file type
Scripts
Executable file that must be interpreted by a shell or some other program. Begin with a line that specifies the interpreter such as: #!/usr/bin/perl Default interpreter is sh scripts.
Binaries
Executable file that the CPU runs directly.
fuser
Find out which processes hold references to that filesystem. -c Prints PID of every process that's using a file or directory on that filesystem -x Indicates a program being executed -v Produces a more readable output that includes the command name lsof is a more elaborate alternative
Application Programming Interface (API)
Generic term for the set of routines that a library, operating system, or software package permits programmers to call
What is the difference between hard and symbolic links?
Hard links are a direct reference, and symbolic links are a reference by name.
/sbin and /bin
Important utilities
Access Control Entry (ACE)
Individual rules within an ACL
umask
Influence the default permissions given to files by specifying what to take away.
Character and Block Device Files
Let programs communicate with the system's hardware and peripherals. The files are rendezvous points that communicate with drivers.
Access Control List (ACL)
List of permissions for specific files or directories. Two types: POSIX ACLs and NFSv4 ACLs.
Major and Minor Device Numbers
Major device number tells the kernel which driver the file refers to. Minor device number tells the driver which physical unit to address.
mount
Maps a directory within the existing file tree, called the mount point, to the root of the newly attached filesystem
Hugo
Method of remembering mnemonic syntax for permission bits.
Link Count
Number of names for the file. Hard links increase this, but symbolic links have no effect.
Sticky Bit
Octal value of 1000. Usually ignored for executable files, but when set on a directory, users may not delete or rename a file unless you are the owner of the file or directory.
Setuid and Setgid Bits
Octal values of 4000 and 2000. When set on executable files, they allow programs to access files and processes that would otherwise be off-limits to the user that runs them. When set on directories, they cause newly created files to take on the ownership of the directory rather than the user who created them.
Hard Links
Only a file's name is stored in its parent directory rather than the file itself. Created with ln and removed with rm.
ls -ld
Option for investigating files. -l shows detailed information. -d forces ls to show the information for a directory rather than showing the directory's contents
Symbolic Links
Points to a file by name. Created with ln -s and removed with rm. Permissions shown through ls are dummy values. Permission to create, remove, or follow the link follow those of the containing directory. Permission to read, write, and execute are granted by the target's own permissions.
Which two permission bits must be set to list the contents of a directory?
Read and execute bits
How to remove a file named -f?
Refer to the file by a pathname that doesn't start with a dash or use rm's -- argument to tell it that everything that follows is a filename and not an option.
What do the setuid, setgid, and sticky bits look like?
Replace the respective x with an s for the first two, and replace the x with a t for others for the last one. Capitalize it if the original bit is not set.
/lib, /lib64, or /usr/lib
Shared library files and a few other oddments
Local Domain Sockets
Sockets that are accessible only from the local host and are referred to through a filesystem object rather than a network port. Also known as UNIX domain sockets.
/var
Spool directories, log files, accounting information, and various other items that grow or change rapidly and that vary on each host
/usr
Standard-but-not-system-critical programs
/tmp
Temporary files
Pathname
The list of directories that must be traversed to locate a file plus that file's filename
rm
Universal tool for deleting files
/boot
Usually holds the file that contains the OS kernel
lsattr and chattr
View and change file attributes
/dev
Virtual filesystem that is mounted separately from root filesystem
Which two permission bits must be set to create, delete, and rename files within a directory?
Write and execute bits