Users and Files
- Users
- Are uniquely identified by a userid
- Userid 0 is special, it is root.
- Root can
- Access any file on the system.
- Send a signal to any process on the system
- Generally you should only use the superuser account to do system admin type stuff.
- The username is associated with this in /etc/passwd (possibly)
- Your home directory and login shell are listed here as well.
- There are groups as well.
- File System
- As pictures on page 27, the file system is (sort of) a tree.
- It is definitely built as a single hierarchical structure.
- But we can form loops and point back up the tree (but this is not the default behavior)
- There are many different types of files.
- Normal text files.
- Directories or folders
- Symbolic links
- Hard links
- Pipes
- Character special devices
- Block special devices
- File names
- can contain anything but a / and the null character
- But you would be silly to use much other than digits, letters and .
- - for example becomes somewhat problematic as most shells think it is something else.
- . and .. are used by the os so they are out.
- Path names
- There are two (and a half) ways to specify a path.
- Absolute comes from root down (pwd)
- relative involves .. to go up
- ~ is a shell thing
- ~/ means the current user's home directory
- ~user means from another user's home directory
- Each process has an associated current working directory.
- Each file has an owner and permissions.
- File I/O model
- They claim unix/linux has a universal I/O model
- Everything is a file
- All files are manipulated in the same way
- Files in programs are represented by file descriptors
- A small positive integer (or 0)
- Which is really just a pointer into a kernel table.
- Three default stdin, stdout, stderr
- These map to cin, cout and cerr in C++