Linux terminal is not only a place where commands are typed. If you are familiar with these basic skills, you will be able to use Bash shell by default in most Linux distributions.
This is the seven weapons that the howtogeek.com website cannot forget to carry when it is designed to upgrade novice users --
1. Tab completion
This saves time and makes it easy to enter files and commands with names that you are not sure about. For example, there is a file named "really long file name" in the current directory, and you want to delete it. You can enter the complete file name, but you must ensure that the space and each letter are entered correctly. If there are many files starting with the letter "r" in the current directory (if you do not enter the characters correctly) Bash will not know which file you want to delete.
If there is another file named "really very long file name" in the current directory, you hit the Tab key. Bash will automatically add the "really \" section for all files starting with "r. Press the Tab key to obtain a list that matches all file names.
2. MPS queue mechanism
This mechanism allows you to send the output of a command to another command. According to the UNIX philosophy, every program is small enough to do only one thing and do the best. For example, if the ls command is used to list all files in the current directory, the grep command is used to search and enter the specified search items.
You can use the pipeline mechanism (| character) to combine the two to search for files in the current directory. The following command (in the current folder) searches for files with the keyword "word:
ls | grep word
3. wildcard characters
The asterisk (*) character is a wildcard that matches any characters in length. For example, to delete two files named "really long file name" and "really very long file name" in the current folder, run the following command:
rm really*name
This command will delete all files starting with "really" and ending with "name. However, if you run the rm * command, you will delete all files in the folder. Note: Be careful when using wildcards, especially when rm is not confirmed by-f !)
4. Output redirection
The ">" character can redirect the output of a command to one file or another command. For example, after the following line of commands is executed, all files in the current folder are listed. The result is not displayed on the terminal, but output to the next file named "file1" in the current folder:
ls > file1
5. History
Bash can remember the commands you have previously entered. The top and bottom arrow keys can call them up line by line. Use the history command to print historical records and use the pipeline mechanism grep to selectively output the expected results.
~. ..
"~", It is also called a Tilde to indicate the Home Directory of the current user. You can enter cd ~ To achieve the same effect. This can also be used in related paths, such as cd ~ /Desktop can reach the current user's Desktop directory.
Similarly, "." indicates the current directory, and ".." indicates the parent directory of the current directory. You can use cd .. to return to the upper-level directory. They can also be used in related paths. For example: You are currently in the Desktop Folder, using cd .. you can go to the Documents folder in the same parent folder as the Desktop.
("-" Indicates the previous directory. cd-can be returned to the previous working directory .)
6. Background commands
Bash runs each command you typed on the current terminal by default. This is usually the case, but what if you want to continue using the terminal after starting an application? Start firefox by entering firefox, and your terminal will be occupied by error prompts and other information output until you close firefox. In Bash, you can add the "&" operator at the end of the command to execute the program in the background.
firefox &
7. Conditional execution
Bash can also execute two consecutive commands. The second command starts to be executed only after the first command is successfully executed. To do this, you can separate them by typing "&", that is, two "&" characters, and enter two commands in the same line. The following command will run the gnome-screenshot tool five seconds later:
sleep 5 && gnome-screenshot
Additional reading:
Color characters: customized Ubuntu Linux terminal
Ubuntu Linux terminal beautification