Use eight tips to make you a super Linux End User

Source: Internet
Author: User
Using a Linux terminal is not just a command. After learning these basic skills, you will gradually master Bashshell, which is the default terminal tool used in most Linux distributions. This article is intended for beginners who lack experience. I believe most advanced users already know the Linux skills.

Using a Linux terminal is not just a command. After learning these basic skills, you will gradually master the Bash shell, which is the default terminal tool used in most Linux distributions.

This article is intended for beginners who lack experience. I believe most advanced users already know all these skills. However, you can still see that you may be able to learn things you have ignored for a long time.

Tab key auto-completion

Using the Tab key auto-completion is a basic technique. It saves you a lot of time and is useful when you are not sure how to spell a file name or command.

For example, if you have a file in the current directory named "really long file nam", you want to delete the file. You can enter the entire file name, but you must be careful to enter the wrong space character (use \ escape ). If you enter "rm r" and press the Tab key, Bash will automatically complete the name of the file for you.

Of course, if you have many files starting with the letter r in the current directory, Bash will not know which one you are referring. For example, if you have another file named "really very long file name" in the current directory, Bash will complete the "really \" section when you press the Tab key, because both files start with this. Then, press the Tab key and you will see a list of all files that match the beginning of this, as shown in.

Enter the name of the file you want and press the Tab key. In this way, when we press "l" and press the Tab key, Bash will automatically complete the file name we want.

This method also applies to input commands. When you are not sure what the command you want is, just remember to start with "gnome", enter "gnome" and press the Tab key, and you will see all possible results.

Pipeline command

Pipeline commands allow you to transfer the output results of one command to another. In the design philosophy of Unix, every program has only a few and refined functions. For example, the "ls" command will display the list of all files in the current directory, while the "grep" command will search for the input string at the specified place.

By combining these two methods with pipeline commands (represented by "|"), you can search for a file in the current directory. the following command is used to search for "really ":

ls | grep really

Wildcard

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 deletes all files starting with really and ending with name. If you use the "rm *" command, all files in the directory will be deleted, and you should use it with caution.

Output redirection

">" Can redirect the output result of a command to a file without using another command. For example, the code uses the "ls" command to list all files in the current directory, and input the output list to a file named "file1", instead of simply displaying the output on the terminal.

ls > file1

Command line history

Bash will remember the history of the commands you used. You can use the up key and down key to read the commands you have used. The "history" command prints all history commands, so you can use the pipeline command to search for your recent commands.

There are also many useful techniques for the history of command lines.

~,. &..

Tilde "~" Represents the home directory of the current user. Therefore, you can use "cd ~" Switch to your home directory without entering "cd/home/name ". This is also used for relative paths, such as "cd ~ /Desktop will switch to the current user's Desktop directory.

Similarly, "." indicates the current directory, and "..." indicates the parent directory. All, "cd .." will jump to the parent directory. This is also effective for relative paths. for example, if you want to switch to the Document directory at the same level as the Desktop directory, you can use the "cd ../Documents" command.

Run commands in the background

By default, Bash runs your command on the current terminal. Normally, there is no problem, but what if you want to run an application at the same time and continue to use the terminal? For example, if you enter the "firefox" command to run firefox, firefox will occupy your terminal and display some error messages and other output until you close it. However, adding the "&" symbol after the command will make Bash run the program in the background:

firefox &

Conditional execution

You can also run two commands in Bash, one after the other. The second command runs only after the first command is successfully run. To do this, separate the two commands with "&" in the same line.

For example, the "sleep" command will accept a parameter in seconds, then count down and allow the end. This command is useless if used separately, but you can use it as a delay before running the next program. The following command stops for 5 seconds and then runs gnome's screenshot tool:

sleep 5 && gnome-screenshot

Do you have any other tips to share? Leave a message. Script (adsbygoogle = window. adsbygoogle | []). push ({}); script

Original article: Chris Hoffman translation: geek fan-minejo

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.