1.~ ,/Directory
~ Is a shortcut to enter the user's main directory in shell. /Is the root directory flag. No matter where the current working directory is located (you can view the current working directory through the PWD command), you can use the command Cd ~ Go to the user's home directory and go to the root directory through CD.
2./etc/passwd file
This file is used to save the information of each user account. Regardless of the account, the information is saved as an entry in the/etc/passwd text file. Each entry includes the user name, password field represented by X (the password field is actually saved in the/etc/shadow file), user ID (UID), group ID (GID ), the fifth field is the selected user ID (such as the user's real name and phone number). The sixth field is the user's home directory address, the last field is the default shell used for user login.
3. Finger user name, chfn command
Enter finger Younes to display the user ID registered in the fifth field of the corresponding entry in/etc/passwd. The chfn command (Change finger information) is used to change this information.
4. sudo passwd root command
Sudo passwd root change or set to enableEnable the root user password.
Sudo-I // This command enters the root working state, which is dangerous and requires careful operation.
5. Create a user and password
Sudo useradd Liangliang // Add a user
Sudo passwd Liangliang // set the password
Sudo userdel-r Liangliang // delete a user and his/her files
6. mkdir-p command
Mkdir-P Jiangsu/Lianyungang/Ganyu // create a hierarchical directory at a time. -P indicates parent.
Rm-r Jiangsu // recursively deletes a directory. -R indicates recursive, recursive.
//To delete a directory, you must use the-r option. Otherwise, the directory cannot be deleted.
7. Add a new directory to path
Use Path = $ path: Directory: directory .... For example, Path = $ path:/sbin
8. dirname command
Dirname/home/Younes // output/home
Basename/home/Younes // output Younes
9. Use cat to create and write files
Cat> write.txt // after running this command, you can create a write.txt file and then write content to it.
10. umask command
Umask sets the default blocking value for file creation in user files and directories, that is, the permission to be subtracted.
Umask [-p] [-S] [mode]
-S: determines the current umask settings.
-P: Modify umask settings.
[Mode]: Modify the value.
The umask value of traditional UNIX is 022, which prevents other users in the same group and users in other groups from modifying the user's files.
Umask-S
U = rwx, G = RX, O = RX
Umask-P 177
Umask-S
U = RW, G =, O =
The preceding five-line command first shows the current status, and then changes the umask value to 177. Only the file owner has the permission to read and write the file.
Note that when you create a file, the default permission is RW-. When you create a directory, rwxrwxrwx is used. Therefore, when umask is set to 022, a file is created. Touch test1 and LS have the following access permissions: RW-r --
11. Search for archives or directories
There are also excellent search systems in Linux. Usually, find is not very commonly used, because it is also very difficult to operate hard disks in addition to slow speed. Generally, whereis or locate is used to locate the problem. If the problem cannot be found, find the problem. Why? Because whereis and locate use databases to search for data, they are fast and there is no actual hard disk search.
Which
Whereis view the location of the file
Use locate with the database to view the file location
Find the actual search hard disk to query the file name
[Root @ test/root] # Find [path] [parameter]
Parameter description:
1. Time:
-Atime N: the files that have been accessed and accessed within N * 24 hours are listed!
-Ctime N: changed or added files or directories are printed out within N * 24 hours.
-Mtime N: the modified file is printed out within N * 24 hours after modified.
-Newer file: new files are listed if they are more than file!
2. Use name:
-Gid N: Find the file whose group ID is N.
-Group Name: Find the file with the group name
-Uid n: Find the file whose owner ID is N.
-User name: Find the user name file
-Name file: find the name of the file (which can contain characters)
-Type: Find an archive whose attribute is type. Type contains B, c, d, P, L, S,
These attributes are the same as those in the previous chapter! For example, l indicates link and D indicates path!
Example:
[Root @ test/root] # Find/-name Testing < = Search for the file named Testing
[Root @ test/root] # Find/-name 'test * '< = Search for file name inclusion Test!
[Root @ test/root] # Find.-ctime 1 < = Search for new directories or files in the current directory within the next day
[Root @ test/root] # Find/home/test-newer. bashrc < = Search The/home/test directory contains more files than. bashrc.
[Root @ test/root] # Find/home-user test < = Search /The archive whose owner is test under home
[Root @ test/root] # Find/dev-type B < = Search In the/dev directory, the archive attribute is B.
12. Application of the tab key in Terminal
In the terminal, enter B and press the 2 tab key to list all executable commands starting with B.
13. Alias the command
Alias LM = LS-Al // you can use lm as a command to replace it later. You can convert a long command into a short command.