linux based operation and maintenance [linux common commands] ------ directory processing command [ls, mkdir, cd, pwd, rmdir, cp, mv, rm]

1.ls

  • Command name: ls
  • Command English original meaning: list
  • The path then the command: / bin / ls
  • Execute permissions: All users
  • Description: display the directory file

Thatls command is used to view the file or folder information

ls [-adl] [文件或目录]

Here Insert Picture Description

1.1 -a

  • -a:- - all. Displays all meaning, we can use this parameter in the directory, you can see the directoryHidden Files

Here Insert Picture Description
The role of hidden files: We know our hidden files can easily view hidden files, the hidden files is to tell the user which is a file system, if we are not sure, it is best not to move him. ThatHidden files is actually a tool used to protect the files from being misuse

1.2 -l

  • -l:- -long. Long display files, display many properties.

Here Insert Picture Description
This means that long list:

-rwxrwxrwx:-代表是一个文件,同等级的还有:d代表目录、l代表链接等
           rwx rwx rwx 表示所有者,所属组、其他人 有读 写 操作的权限

1: 代表这个文件的总操作次数,为一次。
root: 所有者为root
root: 所属组为root组
28844: 文件大小为28844
Jun 25 2019: 最后一次修改文件的时间
anaconda-ks.cfg: 文件名称

1.3 -h

Use -l can view the detailed properties of the file, the file size of the unit is above the number, when we are not sure, you can use the -h parameter.

  • -h: how. User-friendly display.

Here Insert Picture Description
And more than ls commands it supports the -h option in other statistical files behind, of the command.

1.4 -d

If we directly use the ls command plus a directory name, we finally see the files in this directory, in order to =View a directory of property, we can use the -d option
Here Insert Picture Description
Here Insert Picture Description

1.5 -i

linux you love each file has its owninod No.It exists in the index system, the system looks for each user convenience.Equivalent ID number. The only sign of each file. We can view the file by the -i i node
Here Insert Picture Description

2.mkdir

  • Command name: mkdir
  • Command English original intent: make directories
  • Path where the command: / bin / mkdir
  • Execute permissions: All users
mkdir [-p] [目录名]
       -p:递归创建

When we want to create a new directory in the system, directmkdir + directory nameOn it, but to establish a multi-layer directory willAdd -p parameter, create recursive

Built directly

Here Insert Picture Description
-P superimposed without fail

Here Insert Picture Description
-P plus superimposed successfully established

Here Insert Picture Description
To directly with more established directories

Here Insert Picture Description

3.cd

  • Command name: cd
  • Catalog English original intent: change directory
  • Command the path: shell built-in commands
  • Execute permissions: All users
  • Description: Change directory
cd [目录]

You can use cdChange to the directory where you want to reach

Change directory

Here Insert Picture Description
Switching to the parent directory

Here Insert Picture Description
Switching back to the current directory

Here Insert Picture Description

4.pwd

  • Command name: pwd
  • Command English original intent: print working directory
  • Path where the command: / bin / pwd
  • Execute permissions: All users
  • Description: Displays the current directory
pwd 

When you are somewhere in the system, but you do not know the path, then again,Directly pwd you can get the absolute path location

Here Insert Picture Description

5.rmdir

  • Command name: rmdir
  • Command English original intent: remove empty directories
  • Path where the command: / bin / rmdir
  • Execute permissions: All users
  • Function: Delete empty directory
rmdir [目录名]

This command can only delete empty directories, if not empty can not be deleted. Have to delete, to delete all the files in this directory, you can finally use rmdir to delete this directory.

Delete empty directories

Here Insert Picture Description

Delete non-empty directory

Here Insert Picture Description

6.cp

  • Command name: cp
  • English intended command: copy
  • Path where the command: / bin / cp
  • Execute permissions: All users
  • Description: Copy a file or directory
cp -rp [原文件或目录][目标目录]

6.1 -r

canThe entire directory and copy all the files contained in the directorycome.

Here Insert Picture Description
It can also be aChange the nameOptions.

6.2 -p

canAll properties keep the source files to copy. In our daily work, you may have to back up the log, so we want to keep all the attributes of the contents of the log, to determine original data intact.

Here Insert Picture Description

7.mv

  • Command name: mv
  • Command English original intent: move
  • Path where the command: / bin / mv
  • Execute permissions: All users
  • Description: cut the file, rename
mv [原文件或目录][目标目录]

This command can also be counted as a rename command,As long as the same directory will only be renamed

Here Insert Picture Description

8.rm

  • Command name: rm
  • Command English original intent: remove
  • Path where the command: / bin / rm
  • Execute permissions: All users
  • Description: Delete a file or directory
rm [-rf] [文件或目录]

8.1 -r

The multi-layer directory delete

Here Insert Picture Description

8.2 -f

Forced to delete a directory, not repeatedly ask questions to determine the operational

Here Insert Picture Description
Use the time to take again and again whether you want to delete, When the use of the -f option must be cautious, best backup.

Published 10 original articles · won praise 0 · Views 242

Guess you like

Origin blog.csdn.net/mango_kid/article/details/104721112