Linux's supplementary description of shell Lifecycle
Source: Internet
Author: User
Linux's supplementary description of shell life & #63912;-Linux general technology-Linux programming and kernel information. The following is a detailed description. Study the shell problem again and add some shell commands and special usage.
Do we really need to know which shell we are running? Of course not. At least it is not required for me. Various shells are the same for me.
The shortcut key should remember a ctrl + D to log out of shell, equivalent to exit
Another thing to remember ~ Usage
Common usage is simple
However, if you have a me user
So ~ Me is equivalent to/home/me
New ls usage
Ls-R
You can use it to list all the subdirectories in the directory, but be careful not to use them in ultra-large folders. Scrolling over 700 rows is not very fun, stupid I used ls-R/usr
Ls-d
Display the information of its own directory. you can experiment with it.
Key points: (easy to understand the file system structure)
Use ls to display recursion and index lists
Syntax ls-I
First, let's understand what an index node is.
Each object in the file system has a unique index node. Be sure to understand the meaning of the object here. It is not a file, but a specified location on the hard disk, you need to understand that many directories may be connected to an index node.
The so-called independent files are actually the files with different index nodes.
New mkdir usage
Mkdir-p path
This is the mkdir usage that can be used to create a parent directory, which is super easy to use.
Use
Ls-dl shows how many times a node is referenced
How many times have a directory node been referenced? This problem is actually caused by the number of non-hidden files in the directory + 3 >_< (you can think about why, this is very interesting). Also note that here I am talking about directories, not files.
Touch command
Used to create an empty file
Touch karon
Try it
Ls-l karon
-Rw-r -- 1 root 0 19:58 karon January 19
The file is not executable and can only be modified by the user.
Echo command
This command is used to add data to a file. It has its own parameters and prints these parameters to the standard output.
The separate echo command is
Echo "haha ~ "
Haha ~
Returns a redirection echo command.
Echo "haha ~ "> Karon
This command refers to the haha ~ string ~ Input to karon. If karon does not exist, create him. If he exists, overwrite him.
Check the result.
Ls-l karon
-Rw-r -- 1 root 6 January 19 20:03 karon
The result has changed.
Cat command
This command is used to extract the content from the file to the terminal.
Cat karon
Haha ~
It should be a bit more complex, such as a long file.
It can also have the same effect, but note that the terminal does not support Chinese well and cannot be used to read novels >_<
Cp command New Content
The files copied by the cp command have different index node numbers, so they are independent files.
New music video content
The index node number does not change, whether it is a new name or a mobile file, as long as it is in the same file system.
Concept of Link
When we talk about index nodes, we talk about the so-called links. Here we will introduce them in detail.
Hard link: an index node can have any number of hard links. This index node remains in the file system until one of its hard links is deleted.
Hard links work at the index node level. You can give a hard link to the file, but the directory cannot, including "." "..." "~". Hard links cannot be created for different file systems.
Create a hardware connection command ln
Here is an example.
Touch firstlink secondlink
Ln firstlink secondlink
Let's take a look.
Ls-I-d firstlink secondlink
3457416 firstlink 3457416 secondlink
If no index is found, the Link number is the same.
Symbolic link: (symbolic link) In fact, this is a special file type. We can regard it as a window shortcut, which will not prevent the node from being deleted. If the target file does not exist, the symbolic connection file is only damaged.
The ln command can contain-s to establish a symbolic connection.
Ln-s seconlink thirdlink
Let's take a look.
Ls-I-l * link
3457416-rw-r -- 2 root 0 January 19 20:37 firstlink
3457416-rw-r -- 2 root 0 January 19 20:37 secondlink
3457417 lrwxrwxrwx 1 root 10 20:46 thirdlink-> secondlink
Note: thirdlink-> secondlink indicates that the former is a symbolic link of the latter.
The index node number of the symbolic connection file is different, and the symbolic connection file is readable, writable, and executable.
Explain the symbolic link in detail again
Both directories and files can be used to establish symbolic connections. Because they are based on paths rather than file nodes, they can be used in different file systems, you must use an absolute path to establish a symbolic link. You must use an absolute path here. In fact, you can use a relative path. However, I like the safe and reassuring method and won't easily choose a concise one, however, if you want to destroy the source file, you can change the source file. However, if you do so, I suggest pulling you out for destruction.
Additional instructions for deleting commands, including rm and rmdir
When using rmdir, it is not possible if there are files in dir.
However, you can use
Rmdir-rf will delete the directory, no matter what is in it
But ................. it is also very dangerous (in windows, I have a bad habit of del + shift, and I have suffered a long time)
Now let's look at the wildcard.
The built-in wildcard support in linux is called globbing. It indicates that the wildcard support is purely for historical reasons. Such naming rules are hateful due to historical reasons.
Let's discuss the working mode of shell for globbing. First, shell will separate the matched objects with spaces (this process is called extension ), this is the same as entering all the objects manually, but if the shell cannot find them, it will report an error> _ <
* And? We will not discuss it anymore.
[] What is actually the sum? The format is the same, representing a character, but can be specified in the range within [], such as [1-9], [A-Za_z] Very useful things
[!] This is the same as [], but the difference is that it means the opposite [].
Then [,], *,?,. How to express it ?, Here we need to use the extension concept we mentioned earlier. The key to remembering this problem is not to let shell be extended. shell won't be extended in two cases. The first is the symbol behind, the second is the content in ''.
You can use/to display //
Another way is to use''
Of course, "" is acceptable, but ''is safer. Shell can also perform some extensions for "", while ''is dedicated to this.
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