Using a Linux terminal is more than just typing commands. Learning these basic techniques, you will gradually master the Bash shell, which in most Linux distributions on the default use of terminal tools.
This article is written for inexperienced novices, I believe that most advanced users already know all of these skills. However, you can still see, you may be able to learn what you have been ignored.
Tab key auto-complete
Using the TAB key to auto-complete is the basic technique. It can save you a lot of time, and when you are not sure how a file name or command spelling, it is also useful.
For example, in the current directory you have a file named "really long file nam" that you want to delete. You can enter the entire file name, but you have to carefully enter the wrong space character (need to use \ escape). If you type "rm r" and then press Tab, Bash will automatically complete the file name for you.
Of course, if you have a lot of files in the current directory that begin with the letter r, Bash will not know which one you refer to. For example, the current directory you have another name called "really very long file name" text, when you press the Tab key, Bash will make up to the "really" part, because the two documents are beginning with this. Then, press Tab again and you'll see a list of all the files that match the beginning of the file
Then enter the file name you want and press Tab. So, when we lose "l" and then press the Tab key, Bash will automatically complete the file name we want.
This method is also valid for input commands. When you are not sure what command you want, just remember to start with "gnome", type "gnome" and press Tab, you will see all the possible results.
The pipeline command allows you to transfer the output of one command to another command. In the Unix design philosophy, each program is only a small but fine function. For example, the "ls" command displays a list of all the files in the current directory, and the "grep" command searches for the input string at the specified location.
You can search for a file in the current directory by combining the two with the pipe command (the "|" symbol). The following command searches for "really":
Ls | grep really
The asterisk "*" is a wildcard that can match anything. For example, if we want to delete "really long file name" and "really very long file name" from the current directory, we can use the following command:
Rm really * name
This command removes all files that start with really and ends with name. If you use the "rm *" command, it will delete all the files in the directory, all need to be used with caution.
The ">" character can redirect the output of a command to a file without the need for an additional command. For example, the code below uses the "ls" command to list all the files in the current directory and enter the output list into a file named "file1" instead of just the output on the terminal.
Command line history
Bash will remember the history of the commands you have used. You can use the UP and DOWN keys to scroll through the commands you have already used. Use the "history" command to print the history commands, so you can use the pipe command to search for your most recent commands.
There are a number of techniques that can be used with command-line history
~,. & ..
The tilde "~" represents the current user's home directory. So, you can use "cd ~" to switch to your home directory instead of typing "cd / home / name". This is also used for relative paths, such as "cd ~ / Desktop", to switch to the current user's desktop directory.
Similarly, "." Represents the current directory, ".." represents the parent directory. All, "cd .." will jump to the parent directory. This is also valid for relative paths. For example, if you are in the Desktop directory and you want to switch to the Document directory at the same level as the Desktop directory, you can use the "cd ../Documents" command.
Run the command in the background
By default, Bash will run your command under the current terminal. Normally there is no problem, but when you want to run an application while continuing to use the terminal how to do? For example, if you enter the "firefox" command to run the Firefox browser, Firefox will take over your terminal and display some error messages and other output until you close it. But adding an "&" sign after the command causes Bash to run the program in the background:
Firefox & amp;
You can also use Bash to run two commands, one after the other. The second command will not run until the first command completes successfully. To do this, the two commands in the same line can be separated by "&&".
For example, the "sleep" command takes a parameter in seconds and then counts down, allowing the end. Used alone, the command has no use, but you can use it as a delay before running the next program. The following command will stop for 5 seconds and then run the gnome screenshot tool:
Sleep 5 & amp; & amp; gnome-screenshot