-
FHS
Filesystem Hierarchy Standard (FHS)lShareable vs. Unshareable FilesStatic vs. Variable Files
-
Shareable vs. Unshareable Files
- Static vs. Variable Files
- Shareable
- Static: /usr, /opt
- Variable /home, /var/mail
- Unshareable
- Static /etc, /boot
- Variable /var/run, /var/lock
-
configuration directory
- executable directories
- library director
- Configuration directory - /etcl
- Executable directories
- –/sbin
- –/bin
- –/usr/sbin
- Library directories
- –Libraries - collections of programming functions
- –/lib
- –/usr/lib
- –/usr/bin
-
Run Level 3
- If no GUI (i.e. Run Level 3)
- –Use command-line shell commands
- –Use wildcard characters to simplify tasks
-
ls
- “ls” command (list)
- –Many options (the examples below are all alphabetic)“
- ls –l” List long (include file type, permissions etc)
- –Combine Options“
- ls –la” List long and include all directory entries
- ls -lai
- Display the contents the current working directory using long formatLists filenames/directory names, with permissions, date created, owner, file size, type of file“a” will list hidden files (files with a filename starting with a period)Also display i-node numbers
-
touch
- touch command
- Used to create a new empty file
- Can change the time stamp on an existing file
- Example usage:
- touch newfile.txt
- “-c” option
- –Don’t create a file if non exist
- –Used to change the time stamps on existing files
- “-d” option followed by date
- –Set time/date to specific value
-
cp
- cp oldfile newfile
- same location
- cp oldfile /otherdir
- new location/same name
- cp oldfile /otherdir/newfile
- new location/new name
-
cp outfile.txt ~/network
- –If “network” is a directory, the results is a file call “outfile.txt” in the network directory
- –If “network” is a file, then it will be replace with “outfile.txt”
- –If “network” does not exist, the result is a new file
-
cp options
- “-i” interactive option
- –Cause cp to ask you before overwriting any existing file
- “-p” preserve option
- –Preserve ownership
- “-R” recursive copy
- –If you specify a directory of source of copy, the entire directory including subdirectories are copied
-
mv oldfile newfile
- mv testfile ./newdir
- mv testfile ./newdir/newname
- mv oldfile newfile
- rename a file
- mv testfile ./newdir
- move a file to a new directory
- mv testfile ./newdir/newname
- move with a new location/name
-
Hard Links
- Duplicate directory entry
- Only the same filesystem
- will have a number > 1 in the second column of ls -l output
- Example usage:
- ln origname linkname
-
Symbolic Links
- (soft link)
- A file that refers to another file by name
- Can cross filesystems
- will have a “l” as the file type
- Example usage:
- ln –s origname linkname
-
rm file1
- m file1 file2
- rm –r mydir
- rm file1
- delete one file
- rm file1 file2
- delete multiple files
- rm –r mydi
- r delete a directory and all contents
-
Wildcards
- –Sometimes called “globbing”
- “?” (Question Mark)–Stands for a single character
- “*” (Asterick)–Matches any character or set of characters, including no character
- [ ] square brackets–Match any character in set–Specific a range of values [a-z] (a to z)
-
b\?\?k matches
- b\*k matches
- b[\a\o][\l\o]k matches
- b\?\?k matches “book”, “buck”, “beek” etc
- b\*k matches “book”, “buck”, “bk”, “bok”, “backtrack” etc
- “b[ao][lo]k” matches “book”, “balk”, but not “buck”
-
mkdir newdir
- mkdir newdir/dirone
- mkdir –p newdir/dirone
- mkdir newdir
- create a directory named “newdir”
- mkdir newdir/dirone
- create a directory named “dirone” in the directory “newdir”
- mkdir –p newdir/dirone
- create a directory parent first then create the child directory
-
rmdir dirone
- rmdir –p newdir/dirone
- rmdir –r dirone
- rmdir dirone
- remove a directory named “dirone”
- rmdir –p newdir/dirone
- remove a directory named “dirone” first then remove parent
- rmdir –r dirone
- remove a directory named “dirone” and all files and subdirectories
-
Deleting Directories
- Use the “rmdir” command to delete a directory
- Remember “r” option on “rmdir” command RecursiveCan be dangerous be careful
-
/
The root directory. All files appear in this directory or in subdirectories of it.
-
/etc
Holds system configuration files.
-
/boot
Holds important boot files, such as the Linux kernel, the initial RAM disk, and often boot-loader configuration files.
-
/bin
- /sbin
- /bin
- Holds program files that are critical for normal operation and that ordinary users may run.
- /sbin
- Holds program files that are critical for normal operation and that ordinary users seldom run.
-
/lib
- /lib
- Holds libraries—code used by many other programs—that are critical for basic system operation.
-
/usr
Holds programs and data that are used in normal system operation but are not critical for a bare-bones boot of the system. This directory is split into subdirectories that mirror parts of the root organization—/usr/bin, /usr/sbin, /usr/lib, and so on.
-
/home
Holds users’ home directories. Separating this directory into its own low-level filesystem effectively isolates most user data from the OS, which can be useful if you want to reinstall the OS without losing user data.
-
/root
The root user’s home directory.
-
/var
Holds miscellaneous transient files, such as log files and print spool files. One subdirectory of /var, /var/tmp, deserves special mention. Like /tmp (described next), /var/tmp holds temporary files. These files should not be deleted when the computer reboots.
-
/tmp
Holds temporary files, often including temporary files created by user programs. Such files may theoretically be deleted when the computer reboots, although in practice many distributions don’t do this.
-
/mnt
The traditional mount point for removable media; sometimes split into subdirectories for each mounted filesystem.
-
/media
The new mount point for removable media; typically split into subdirectories for each mounted filesystem.
-
/dev
Holds device files, which provide low-level access to hardware.
-
/run
Holds information about the running system.
|
|