What is the meaning of Linux beginners learning commands?

  
                

For beginners, the learning of Linux commands is not so simple. Many beginners rarely use commands or do not know how to use them. In fact, Linux commands are very important. The following small series will give you a detailed introduction to Linux commands. .

A friend took a long time Linux graphical interface, basic input command without command-line execution, so the final installed Linux utterly useless. Here are some of the commands that are commonly used under the command line. I hope it will be useful.

What is a command

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

The so-called command is a string of characters 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 file (executable file) 2) shell built-in function (built-in function) 3) alias (alias). The executable is a compiled program file, and we enter the path to these files to let the shell run, such as $/bin/ls. Some executable files are placed under a special directory (the default path) so that the operating system can be found by the file name without always entering the absolute path of the file. For example, $ls (actually, the shell automatically helps us fill in the path of ls). The programs contained in these executables then run and become processes. The shell's built-in functions are similar to the above, except that the corresponding program is stored inside the shell. An alias means that we give an abbreviation for the above two commands in order to reduce the amount of input work.

We can use the type command to understand the type of the command:

The code is as follows:

$type ls "/p" "p" $type cd

The composition of the command

When we enter the command on the command line, it is often composed of the following:

The code is as follows:

$ls -l /home

The entire line of commands is divided into three parts by spaces (note that $ is the prompt that appears automatically, and sometimes the computer name appears before). The first one 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 is The parameter indicates that the directory I want to list is /home. In fact, keywords are a special kind of parameter, and in most cases, some special functions used to switch programs (used to choose whether to make latte or black coffee). The parameters are the general variables that are passed to the program. After ls is processed, the file name will be included in the terminal output /home (see the file system: http://www.jb51.net/LINUXjishu/214042.html):

The code is as follows: Br>

vamei another

There can be more than one keyword and parameter, for example:

The code is as follows:

$ls -l -a /home /bin" /p" "p" $ls -la /home /bin

(The above two commands are equivalent)

List the files in the /home and /bin directories, -a for the columns All files are listed (even if they are hidden files), and -l indicates the details of each file.

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

Recalling the background of Linux file management, we know that each file can be executed According to the permissions owned by the user. The command is actually an executable file, as well. System-related commands, or defined operations in a command, often require the superuser root to be used. If you are a user vamei, then you can't 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. For example $sudo ls.

For most shells, there are command completions. When you enter a part of the command behind, such as rmd rmd, press the Tab key, Linux will help you to play the remaining characters, added to rmdir. More than just commands, if you type in a file name, Linux can help you. For example, ls a.txt. When you type in lsa.t, press the Tab key, Linux will help you fill in the file name and become ls a.txt. Of course, the premise of this is that when you type in rmd, the command that matches it in the default path has only one rmdir. If there are multiple matching commands, double-click Tab and Linux will display all the matching commands.

Benefits of Using Commands

In fact, the functions of many commands can be implemented through a graphical interface. What is the significance of learning these commands?

In most of the history of UNIX development, users work through the shell. Most of the commands have been developed and improved over the past few decades, with powerful features and stable performance. Linux inherits from UNIX, and naturally it does. In addition, the graphical interface of Linux is not good, not all commands have corresponding graphic buttons. Not to mention that in the case of a graphical interface crash, you have to rely on the shell input command to restore the computer.

The command itself is a function and is a small functional module. When we want to make computers do very complicated things (say: download all the links of a page at 12:00 in the evening, then copy to the mobile hard drive), it is not very smart to constantly press each graphical button. Things (1. There are a lot of points, 2. Must wait until 12:00). We usually use shell programming to implement such complex tasks. In this case, we can embed the commands as functions in our shell program, so that different commands work together (such as using date to query time and then use it according to time). Wget download, etc.).

How do you know an unfamiliar order?

There are a few commands that can be used to understand the condition of a command itself, such as the absolute path of the command.

The code is as follows:

$which ls

which searches for the command in the default path and returns the absolute path of the command.

The code is as follows:

$whereis ls

whereis searches for commands in a relatively large range and returns the absolute path of the command.

The code is as follows:

$whatis ls

whatis introduces the command in a very short sentence.

The code is as follows:

$man ls

man Query the concise help manual. For most of the commands that come with Linux, when the author writes it, it comes with a help file that tells the user how to use this command.

(Man can be said that we understand the best encyclopedia of Linux, it can not only tell you the functions of Linux's own commands, but also query Linux system files and system calls. If you want to learn Linux in depth You must know how to use man to query related documents.)

The code is as follows:

$info ls

info Query more detailed help information

In addition, in the shell, you can also use the up arrow to see the commands that were previously entered and run.

You can also use the

code as follows:

$history

to query the previous command line operations.

When a command is running, you can use Ctrl + c when you want to stop it. If you just want to stop temporarily, use Ctrl + z. The specific mechanism is related to the signal, which we will introduce later.

Summary

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

type

sudo

which, whereis , whatis, man, info

Use Tab to automatically fill up, up arrow to query history, history

Ctrl + c, Ctrl + z

The above is the introduction of Linux commands The Linux command does not know the benefits of Linux commands without using Linux commands. Linux commands can solve some common problems in the system. It is very important for beginners to master Linux commands.

Copyright © Windows knowledge All Rights Reserved