In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the sample analysis of Linux commands and command lines. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
What is an order?
What we usually call the Linux command line is the shell running on the terminal (terminal) (read the Linux architecture to understand what shell is and its location in the Linux system).
The so-called command is a string of characters we enter on the command line. 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). Executable files are compiled program files, and we enter the path to these files to have shell run, such as $/ bin/ls. Some executables are placed under a special directory (the default path) so that the operating system can find it by file name instead of always entering the absolute path of the file (absolute path). For example, $ls (in fact, shell automatically helps us complete the path of ls). Subsequently, the programs contained in these executable files run and become processes. The built-in function of shell is similar to the above, except that its corresponding program is stored inside shell. An alias means that we give an abbreviation to the above two commands in order to reduce the workload of typing.
We can learn about the type of command through the type command:
The code is as follows:
$type ls
$type cd
Composition of orders
When we enter a command on the command line, it often consists of the following ways:
The code is as follows:
$ls-l / home
The entire line of command is divided into three parts by spaces (note that $is an automatic prompt, sometimes preceded by a computer name). 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, and the third / home is the parameter, indicating that the directory I want to list is / home. In fact, the keyword is a special parameter that is used in most cases to switch on and off some special functions of the program (used to choose whether to make latte or black coffee). Parameters are general variables that are passed to the program. After the ls is processed, each file name will be included under the terminal output / home (for this file system, see: https://www.yisu.com/LINUXjishu/214042.html):
The code is as follows:
Vamei another
There can be more than one keyword and parameter, such as:
The code is as follows:
$ls-l-a / home / bin
$ls-la / home / bin
(the above two commands are equivalent)
List the files in the / home and / bin directories,-a to list all files (even hidden files), and-l to list 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 knowledge of Linux file management, we know that whether each file can be executed depends on the permissions the user has. Commands are actually executable files, and the same is true. System-related commands, or actions defined in a command, often require the identity of superuser root to be used. If you are the user vamei, then you cannot 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 shell, there is a command completion function. When you type part of the command later, such as rmdir's rmd, press the Tab key, and Linux will type the rest of the characters for you, adding it to rmdir. Not only commands, but if you enter a file name, Linux can also help you make it up. For example, ls a.txt. When you type into lsa.t, press the Tab key, and Linux will help you complete the file name and become ls a.txt. Of course, this is done on the premise that when you type into rmd, there is only one rmdir in the default path that matches it. If there are multiple matching commands, double-click Tab,Linux will display all the matching commands.
Benefits of using commands more often
In fact, the functions of many commands can be achieved through a graphical interface. What's the point of learning these commands?
For most of the history of UNIX development, users worked through shell. Most commands have been developed and improved for decades, with powerful functions and stable performance. Linux inherits from UNIX, and so does it. In addition, the graphical interface of Linux is not good, and not all commands have corresponding graphical buttons. Not to mention that if the graphical interface crashes, you have to rely on shell to enter commands to restore the computer.
The command itself is a function (function) and a small functional module. When we want the computer to do complex things (such as downloading all the links to a page at 12:00 in the evening and then copying it to a removable hard drive), it's not very smart to keep pressing the graphical buttons (1. A lot of points, 2. It must wait until 12:00. We usually use shell programming to achieve such complex tasks, at this time, we can embed commands as functions in our shell programs, so that different commands can work together (such as using date to query time, and then according to time to use wget download, etc.).
How to understand a strange command?
There are some commands that can be used to understand a command itself, such as the absolute path of the command.
The code is as follows:
$which ls
Which searches for a command in the default path and returns the absolute path to the command.
The code is as follows:
$whereis ls
Whereis searches for a command over a relatively large range and returns the absolute path to 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 inquires concise help manuals. For most commands that come with Linux, 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 functions of the commands that come with Linux, but also query Linux's system files and system calls. If you want to learn more about Linux, you must know how to use man to query relevant documents.)
The code is as follows:
$info ls
Info queries for more detailed help
In addition, in shell, you can use the up arrow to see the command that was previously entered and run.
You can also use it.
The code is as follows:
$history
To query the previous operations on the command line.
When a command runs and you want to stop it halfway, you can use Ctrl + c. If you just want to stop temporarily, use Ctrl + z. The specific mechanism is related to signal, which we will introduce later.
Summary
Command line: use shell to interpret the entered string to run the program
Type
Sudo
Which, whereis, whatis, man, info
Use Tab auto-completion, up arrow query history, history
Ctrl + c, Ctrl + z
This is the end of this article on "sample analysis of Linux commands and command lines". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.