Learning Notes (iv)--common commands such as directory commands, RM, view text commands, file properties

Source: Internet
Author: User

1.mkdir rmdir Command:

(1) Create a directory:

[Email protected] ~]# Mkdir/tmp/learn/folder

If/tmp/learn does not exist at this time, an error will be made, resulting in the folder directory not being created successfully. To create a cascade, use the-p parameter:

[Email protected] ~]# mkdir-p/tmp/learn/folder

(2) Delete directory:

Let's start with a method that we often use: RM Plus-r parameter

[[email protected] ~]# rm-r/tmp/learn/folder//Force Delete using the-f parameter

There is also a method that is not as convenient to use as the Rm-r, and is only understood here:

[Email protected] ~]# Rmdir/tmp/learn/folder

Note that if the folder directory is not empty at this time, the deletion will error, causing the deletion to fail. The rmdir also has the-p parameter, and if you use-p, the parent directory of the folder is deleted layered, assuming that the folder's parent directory contains only the folder itself, that is, the parent directory is empty to delete the folder after it is deleted. We recommend mastering the Rm-r command.


2.RM MV CP Command:

Under the root user, the RM MV CP is associated with its-I parameter by alias:

Alias rm= ' Rm-i '

Alias mv= ' Mv-i '

Alias cp= ' cp-i '//Normal user no this association

So if you want to force RM MV CP when you log in with the root user, you need to use the-f parameter. Note Here,CP is very special, use-f is still there will be a hint , this will give us the CP need to overwrite a large number of files caused great inconvenience, two solutions-disassociate, or use the absolute path of the command, we recommend the use of Absolute path method:

[[email protected] ~]# Unalias CP//Disassociate

[[email protected] ~]#/BIN/CP//absolute path

In addition,RM and CP need to use the-R parameter (recursive) when operating against the directory, and the MV does not need to be used (MV does not have this parameter).

The MV command also has the ability to rename:

[Email protected] learn]# mv./alreadyexists./chongmingming

[Email protected] learn]# mv./chongmingming. /xinmingzi

Renaming is not limited to the same directory, that is, moving and renaming can be done in one step. The prerequisites for renaming are as follows: In the first step, there is no chongmingming/directory in the learn/directory, and in the second step there is no xinmingzi/directory in the parent directory of learn/. If these directories are available, they will be moved to these directories with the same name.

Of course, renaming has a "genuine" command, not commonly used, usually solved with MV:

[Email protected] ~]# rename oldname newname./oldname

Rename the oldname file, rename it to NewName, and make it known only.

3. View Text command:

There are several: cat head tail more less

(1) Cat: View all, occasionally use the-a parameter, the function is to display the line at the end of each line to add the $ character, convenient to view a longer line.

(2) Head: View the first 10 lines of text, you can specify how many rows to view

[[email protected] ~]# head-5 file.log//Specify to view the first few lines of text, not specify the first 10 lines

(3) Tail: Look at the text after 10 lines, you can specify the number of rows to view, you can also specify from the text of the line to see is viewed, there is a common parameter-f, commonly used to view the ever-increasing files, such as log files,

[[email protected] ~}# tail-5 file.log//Specify a few lines after viewing the text

[[email protected] ~}# tail-n +5 file.log//View the first five lines of the text to the last line

(4) More: Split screen view text, you can view text in full screen

[Email protected] ~]# more File.log

After entering view mode, q exits view, b page UP, F page down. These commands also apply to less, and to the Man command. (more F in the page will skip a lot of lines, do not know why, it is recommended to use the less command to view)

(5) Less: Split-screen view text, you can view the text on the whole screen, with a little more than more

[email protected] ~]# less File.log

Page flipping mode with the above command. You can also use K down line, J up line , (can also be implemented using the UP and DOWN ARROW keys). Less relative to the more useful place, unless the manual Q exit view, otherwise will not exit, and the more command will see the end of the text automatically exit view. And the less command can be turned over and over and viewed on a line, it is recommended.


4. File properties:

To view file properties:

[Email protected] ~]# ls-l File.log

-rw-r--r--. 1 root root 12:11 file.log

This is also mentioned in the previous notes, but there is no mention of the authority. Permissions are divided into three groups, from left to right are the main permissions, belong to group permissions, other people permissions. R stands for readable, W is writable, X is executable for the file, and is accessible (CD) for the directory. After the permission. is related to SELinux. The inode number and several files are related to using the inode number.

This article is from the "barrel of fake dog excrement" blog, please be sure to keep this source http://xitongjiagoushi.blog.51cto.com/9975742/1622175

Learning Notes (iv)--common commands such as directory commands, RM, view text commands, file properties

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.