linux basic commands ④

On this blog mainly linux directory management command

The first step should be to learn to manage the directory to create the directory, or directory at all, let alone manage!
Here are the commands to create a directory

mkdir directory name

: Create Directory
options:
-p recursively create
-v display information creating procedure detailed
examples:
Continuous Create a directory: mkdir -p / tmp / 111/ 222
to create a single directory: mkdir / tmp / aaa
create multiple directories: mkdir / tmp / bbb / tmp / ccc = mkdir / tmp / {bbb, ccc}
Here Insert Picture Description
Note:
1. create a directory already exists, then we will prompt Linux Linux can not create it.
2, without any parameters to run mkdir command creates a directory in the current directory.
3, do not bring -p, if the new file parent directory does not exist will not be successfully executed this statement is wrong. Plus or not plus front -p directory will not have to in turn create.
4, the first condition is to create a directory, in the path of the target directory you want to create must have access.

Now create a directory finished, you should learn to delete the directory, as follows

rmdir directory name

: Delete empty directory
example: delete the specified empty directory: rmdir / tmp / aaa
  Here Insert Picture Description
  Note: Because this command only delete empty directories, application in practice much, we explain later rm command instead.

Above to create and delete finished, it is to copy the directory, as follows

cp

: Copy files or directories
options:
-r copy directories
attribute -p preserve file
examples: for example, we will root copy initial-setup-ks.cfg file in the directory to tmp directory
Here Insert Picture Description
 after rename can be used to copy files, such as we will root copy the initial-setup-ks.cfg file in the tmp directory to the copyinitial-setup-ks.cfg file
 Here Insert Picture Description
 when copying multiple files at the same time also pay attention to copy the directory to add the -r option. After the original file will add -p attribute some properties such as modification time, also intact copy of the past. If you do not add -p attribute, then copy the file after modification time is the current system time.

Copy finished, it's time to say the Cut command, as follows:

mv

: Cut a file or directory
Example: Create a directory in the tmp directory tmp1, and then create a directory tmp1_1 in tmp1 directory, then the command mv / tmp / tmp1 / tmp1_1 / tmp directory will tmp1_1 under tmp1 cut to the next tmp directory.
Here Insert Picture Description
The above finished copy and cut, followed by another command to delete the most commonly used, as follows:

rm

: Delete a file or directory
option:
-f enforcement
-r delete a directory
example: There are two directories tmp1 and tmp1_1 In tmp directory, rm -r tmp1_1 is to remove this directory, but you need to enter y to confirm

rm -rf tmp1 tmp1 is forced to delete a directory, enter y do not need to confirm that this approach is very simple, but easy to accidentally deleted files, there is no chance to go back

rm -rf tmp1 tmp2 delete two files
Here Insert Picture Description
Next we in terms of the last command of this chapter, the following

install

: Copy the file and specify the attributes
options:
-d create directories
-m assign permissions
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/fanyanluohua/article/details/92431611