I. Absolute path and relative path
For example, the command to modify the NIC configuration file
Vi/etc/sysconfig/network-scripts/ifcfg-ens33
Over here
/etc/sysconfig/network-scripts/ifcfg-ens33
is the absolute path, the absolute path is from the root directory to the location of the file;
such as execution
cd/etc/
And then enter
CD Sysconfig
Path Sysconfig is relative to, etc folder, which is the relative path (as opposed to the current folder path)
Second, CD command
cd/etc/
is entered in the ETC directory;
To enter the last directory in which it was located
For example: The directory where I am now is/etc/sysconfig
Enter the CD at this time-
The ETC directory is returned
Enter the CD again-
and returned to the/etc/sysconfig directory.
Returns to the user's home directory, as with the individual CD parameter results
Execute CD here ~
Re-enter PWD to view the current directory
Now you can see that the directory is/root
This command is returned to the previous level directory,
Like in.
/etc/sysconfig
Input
Cd..
Then enter PWD to view the current directory
At this time, you can see that the current directory is, etc
CD again:
The root directory is returned.
Enter the man CD to see the specific usage of the CD
Iii. Creating and deleting catalogs Mkdir/rmdir
mkdir command to create a directory
For example
Mkdir/tmp/123
The/tmp/123 directory is created at this time;
mkdir/tmp/123/456/789 this time error, 456 directory does not exist, that is, the mkdir command can not cascade Create folder execution Mkdir-p/tmp/123/456/789 The directory/tmp/123/456/789 is created,- The P option is to cascade the creation of the directory
The rmdir command is used to delete directories and can only be used to delete empty directories, if there are files or subdirectories in the target directory, then the target directory cannot be deleted, RMDIR-P can cascade delete directory, if the directory is empty
Like I do.
Rmdir-p/tmp/123/456/789
This will show that the TMP directory cannot be deleted because the TMP directory has other files in addition to the 123 directory, and the directory/123/456/789,/123/456,/123 have been deleted.
Four, RM command
RM commands can be used to delete files and directories
For example, I first create a directory
Mkdir-p/tmp/123/456/789
And then create a text
Touch/tmp/123/456/789/123.txt
Perform
Rm/tmp/123/456/789/123.txt
Will ask whether to delete the normal empty file/tmp/123/456/789/123.txt Enter Y for Yes, delete the file;
rm/tmp/123/456/789
This will show that/tmp/123/456/789 is a directory that cannot be deleted,
Create txt text again
Touch/tmp/123/456/789/123.txt
After RM, add-R
Rm-r/tmp/123/456/789
Need to press several times Y, more trouble, at this time after R plus an F
Input
rm-rf/tmp/123/456/789
The directory and its files are deleted successfully
;
V. Supplementary knowledge
rm-rfv/tmp/123/456/789
Enter history to see the most recently entered commands
Input! Touch can quickly enter the last touch command executed,
Linux Learning Notes (vi) relative and absolute paths, CD commands, creating and deleting directories Mkdir/rmdir, RM commands