Additions and deletions to Linux files and directories
1)
echo displays a line of content.
Touch if the file/directory does not exist, create a new file/directory, or if the file exists, it is the last access time to update the file.
Usage touch [-ACM] [-R Ref_file] File ...
touch [-ACM] [mmddhhmm[yy]] file ...
touch [-ACM] [-t [[cc]yy]mmddhhmm[. SS]] File ...
mkdir Create directory (must have permission to create directory)
Usage mkdir [-M mode] [-p] dirname ...
mkdir. Photo Create hidden folder ". Photo"
mkdir Dir1/dir2 in Dir1 under the construction of DIR2
mkdir dir13 DIR4 DIR5 built multiple
mkdir ~/games User Home directory (created by default in the current directory)
Mkdir-p DIR6/DIR7/DIR8 forces the creation of DIR8; Dir6 and DIR7 are created automatically if there is no previous directory.
Without-p, if there is no dir6/dir7, the creation fails.
2) CP Copy File/directory
CP source file target file Copy file, if existing file is overwritten
Cp-r Source directory directory to replicate directory, if existing directory to copy the source directory to the target directory,
When there is no target directory, it is equivalent to fully replicating the source directory, except for the file name.
CP beans Apple Dir2 copy beans, Apple files to the Dir2 directory
Cp-i beans Apple to increase whether or not to overwrite the hint
Assignment Folder Cp-r Workspace Workspace.bak
mkdir Demo
Cp-r Workspace Demo
Option-R means recursive assignment of all subdirectories and file contents
3) MV Move or rename files/directories
Usage mv [-f] [-i] F1 F2
MV [-F] [-i] F1 ... fn d1
MV [-F] [-i] D1 D2
MV source file name destination file name if the destination file name is not yet, the source files are renamed to the target files, if the target files already exist,
The source file overwrites the destination file. Eg:mv. Photo photo
MV source file name destination directory move file
MV Source Directory Destination directory if the destination directory does not exist, the source directory is renamed, if the target directory already exists, the source directory is moved to
The target directory.
4) RM Delete File/directory
Usage rm [-firr] File ...
RM file name to delete the file. Eg: delete files: RM file1 file2 file3 ...
Rm-r Directory name to delete directory. Eg: Delete directory: RM-RF dir1 dir2 ... Add:-R recursively delete all subdirectories and files
The rm–f file can be forcibly deleted with this command parameter as long as it is the owner of the file or directory, whether or not it has permission to delete it.
RM-RF * Delete all files and directories
RmDir Delete Empty directory. Only empty directories can be deleted.
5) ln Creates a hard link or soft link, hard link = multiple names of the same file; soft link = Shortcut
Usage ln [-f] [-n] [-s] F1 [F2]
ln [-f] [-n] [-s] F1 ... fn d1
ln [-f] [-n]-s D1 D2
ln file1 FILE1.LN creates a hard link. Feel is the same file, delete one, have no effect on another; two must be removed
Count deleted.
Ln-s file1 file1.sln Create a soft link. Can operate across the system, break the operational rights, is also a shortcut.
- This article is from: Linux Learning Tutorial Network
Additions and deletions to Linux files and directories