Linux command line and command

Source: Internet
Author: User

Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement. Thank you!

Linux commands are important tools and are often the biggest bottleneck for beginners. A friend with a long time Linux GUI, basically do not use command line Input command execution, so installed Linux finally become a device. Here is a summary of some command-line commands that are commonly used, and hope to be useful.

What is a command?

The Linux command line we usually call is the shell running in the terminal (terminal) (read the Linux architecture to see what the shell is and where it is in the Linux system)

The so-called command is a string of characters that we enter on the command line. The shell is responsible for understanding and executing these strings. Shell commands can be divided into the following categories 1) executable (executable file) 2) shell built-in function (built-in function) 3) alias. Executable files are compiled program files, and we enter the paths of these files to let the shell run, such as $/bin/ls. Some executables are placed under a special directory (the default path), so that the operating system can be found by file names without always entering the absolute path of the file (absolute path). For example $ls (in fact, the shell automatically helps us with the path of LS). The programs that are included in these executables are then run and become processes. The shell's built-in function is similar to the above, except that its corresponding program is stored inside the shell. An alias is a short term that we give to both of these commands to reduce the amount of input.

We can understand the type of command by using the type command:

$type ls

$type CD

Composition of the Order

When we enter commands at the command line, it is often a form of:

$ls-L/Home

The entire line is divided into three parts by a space (note that $ is a prompt that appears automatically, and sometimes the computer name appears before this). The first is the name of the command LS, the function of this command LS is to list all the files in the directory, the second-L is the keyword, it tells LS to list the details of each file, the third/home parameter, indicating that I want to list the directory is/home. In fact, the keyword is a special parameter, in most cases to switch the program's special functions (to choose whether to make a latte or black coffee). A parameter is a generic variable that is used to pass to the program. After LS has been processed, the individual file names contained in the terminal output/home are shown (see: http://www.cnblogs.com/vamei/archive/2012/09/09/2676792.html):

Vamei another

Keywords and parameters can have more than one, such as:

$ls-L-a/home/bin

$ls-la/home/bin

(The above two commands are equivalent)

Lists the files in the/home and/bin directories,-a indicates that all files are listed (even hidden files are listed),-L indicates the details of each file are listed.

(If the command is not placed in the default path, you can also enter an absolute path to execute)

Recall Linux file Management background knowledge, we know that each file can be executed according to the user's permissions. The command is actually an executable file, as well. System-related commands, or actions defined in a command, often require superuser root to be used. If you are a user Vamei, you will not be able to use these commands. But logging in as Root is a bad idea. To resolve this contradiction, you can log in as Vamei, but add sudo before executing the command to temporarily execute a command as root. such as $sudo ls.

For most shells, there are command-completion functions. When you enter a part of the command after $, such as RmDir's RMD, press TAB, Linux will help you to play the remaining characters and add to the rmdir. More than just commands, if you enter a file name, Linux can also help you fill it. For example, $ls a.txt. When you enter $ls A.T, press the TAB key, and Linux will help you fill in the file name and become $ls a.txt. Of course, the premise is that when you enter the RMD, there is only one rmdir for the command that matches it in the default path. If there are multiple matching commands, double-clicking the tab,linux displays all the matching commands.

Benefits of multi-use commands

In fact, the functionality of many commands can be achieved through a graphical interface, where is the meaning of learning these commands?

In most of the history of UNIX development, users are working through the shell. Most of the commands have been developed and improved over several decades, with powerful features and stable performance. Linux inherits from Unix, and so is nature. In addition to the graphical interface of Linux is not good, not all commands have a corresponding graphics button. Not to mention the graphical interface crashes, you have to rely on the shell Input command to restore the computer.

The command itself is a function, which is a small function module. When we want to make the computer do something very complicated (say: at 12:00 in the evening to download all the links to a page, and then copy to the mobile hard disk), constantly to press the graphical buttons is not a very smart thing (1. The main points, 2. must wait until 12:00). We typically do this with shell programming, where we can embed commands as functions into our shell programs, allowing different commands to work together (for example, using date to query for time, then using wget for time, and so on).

How to understand a strange command?

Some commands can be used to understand the situation of a command itself, such as the absolute path of the command.

$which ls

Which searches for a command in the default path, returning the absolute path to the command.

$whereis ls

Whereis searches for a command in a relatively large range, returning the absolute path to the command.

$whatis ls

Whatis used a short sentence to introduce the order.

$man ls

Man queries a concise help manual. For most Linux-brought commands, when the author writes it, it comes with a help document that tells the user how to use the command.

(man can be said to be the best encyclopedia we know about Linux, it can not only tell you the features of Linux commands, but also query Linux system files and system calls.) If you want to learn more about Linux, you have to know how to use man to query related documents. )

$info ls

Info query For more detailed help information

In addition, in the shell, you can also use the UP arrow to view previously entered commands that were run.

You can also use

$history

To query the previous operation on the command line.

When a command runs, you can use CTRL + C when you want to stop it halfway. If you just want to stop temporarily, use CTRL + Z. The specific mechanism is related to the signal (signal), which we will introduce later

Summarize

Command line: Use the shell to interpret the input string to run the program

Type

Sudo

Which, Whereis, Whatis, man, info

Use tab autocomplete, up arrow to query history

CTRL + C, CTRL + Z

Linux command line and command

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.