1. List of files and directories 1.1 more common Linux top-level virtual directory names and their contents:
Directory |
Use |
/ |
The root directory of the virtual directory. Files are not usually stored here |
/bin
|
Binary directory, storing many user-level GNU tools |
/boot
|
Start directory, store startup files |
/dev
|
Device directory, where Linux creates device nodes |
/etc
|
System Configuration file Directory |
/home
|
Home directory, where Linux creates the user directory |
/lib
|
Library directories, library files for systems and applications |
/media
|
Media catalog, common mount points for removable media devices |
/mnt
|
Mount directory, another common mount point for removable media devices |
/opt
|
Optional directory, often used to store third-party packages and data files |
/proc
|
Process directory, storing information about existing hardware and current processes |
/root
|
Root User's home directory |
/sbin
|
System binaries directory, storing many GNU administrator-level tools |
/run
|
Run directory to store runtime data when the system is operating |
/srv
|
Service catalog, files related to local services |
/sys
|
The system directory, which holds the system hardware information related files |
/tmp
|
Temporary directory in which temporary working files can be created and deleted |
/usr
|
User binaries directory, a large number of user-level GNU tools and data files are stored here |
/var |
A variable directory for storing frequently changing files, such as log files |
1.2CD command:
A single-dot character (.), which indicates the current directory;
Double dot character (.. ) that represents the parent directory of the current directory.
1.3ls command:
-F easily differentiate files and directories
-A to display hidden files and common files and directories together
-r recursive option, which lists the files in subdirectories contained in the current directory
-D lists only the information for the directory itself and does not list its contents.
-L produces a long tabular output that contains more information about each file in the directory
The output of this long-list format lists individual files or directories in each row. In addition to the file name, there are other useful information in the output. The first line of the output shows the total number of blocks that are contained in the catalog. After that, each line contains the following information about the file (or directory):
? File types, such as directory (d), file (-), character file (c), or block device (b);
? The permissions of the file;
? The total number of hard links to the file;
? The user name of the file owner;
? The group name of the file group;
? The size of the file (in bytes);
? The last modified time of the file;
? The file name or directory name.
1.4LS Filter Output list:
$ ls-l My_script
-rwxrw-r--1 Christine Christine 11:26 My_script
The LS command recognizes standard wildcard characters and uses them for pattern matching in filters:
? Question mark (? ) represents a character;
? An asterisk (*) represents 0 or more characters.
The question mark can be used in a filter string to override a single character anywhere. For example:
$ ls-l my_scr?pt
-rw-rw-r--1 Christine Christine 0 may 13:25 My_scrapt
-rwxrw-r--1 Christine Christine 11:26 My_script
The use of asterisks and question marks in filters is called file extension matching, which refers to the process of using wildcard characters for pattern matching. globbing The formal name of a wildcard is called a meta-character wildcard (metacharacter wildcards). In addition to asterisks and question marks, there are more meta-character wildcard that can be used for file extension matching. You can use the brackets. You can also specify a range of characters, such as the letter range [A–i]
$ ls-l F[a-i]ll
-rw-rw-r--1 Christine Christine 0 may 13:44 fall
-rw-rw-r--1 Christine Christine 0 may 13:44 fell
-rw-rw-r--1 Christine Christine 0 may 13:44 fill
In addition, you can use an exclamation point (!) to exclude unwanted content.
$ ls-l F[!a]ll
-rw-rw-r--1 Christine Christine 0 may 13:44 fell
-rw-rw-r--1 Christine Christine 0 may 13:44 fill
-rw-rw-r--1 Christine Christine 0 13:44 full
Basic Shell Command 1