Linux file and directory management
Preface
Linux directory structure as a tree structure, the top of the directory is the root directory /, all directories are hanging in the list below.
- Absolute path: from the root directory / write from
- Relative path: not by / written from
Get Command Help
Linux commands can be broadly divided into two categories: internal and external command command
internal commands: also known as shell commands embedded
external command: stored in a file, the file is defined in the $ PATH, only when it needs to be transferred to memory
type the command: You can view command type to distinguish between internal command or external command
Help command:
- help: can only be used for internal command, not for external command
format: - help command name
- -Help: for external command
format: - command name --help
Common command processing directory
- ls: List directory / file attributes
- cd: Change directory
- pwd: View the current working directory
- touch: create a new file, or update the file timestamps
- mkdir: create a new directory
- rmdir: delete empty directories
- du: assessment of the size of directories and files
- cp: copy files or directories
- rm: Remove files or directories
- Name move files and directories, or modify files and directories: mv
- ln: create connection files (soft connection, the equivalent shortcut)
- alias: Set command aliases
- unalias: Cancel Alias
- cat: the first line displays the file contents
-
LS - List:
[root @ Emma ~] # LS [option parameter] directory name or file name
options and parameters:
-a: All files, together with (The file begins with a) together to hide the file list (common)
- d: List only the directory itself, instead of listing the file data (commonly used) in the directory
-l: a serial data length, and contains the attribute data file permissions, etc. (common)
-R & lt if the directory has the file, then Beijing and Taipei are listed in order of the following documents (common)
-
Change Directory cd-:
[root @ Emma ~] # cd [target folder location] -
pwd- Print Working Directory:
View the current working directory -
Touch:
[Emma the root @ ~] Touch file name #
1, the time for a command to modify the properties of the file or directory, including access time and change time.
2, if the file does not exist, the system creates a new file.
-
the Make Directory mkdir-:
[root @ Emma ~] # mkdir [-p] directory name
options and parameters:
-m: the direct authority of the configuration file (if not configured, the system uses the default attributes)
-p: "recursive" create a directory
-
rmdir: delete empty directories
[root @ Emma ~] # mkdir [-p] directory name
options and parameters:
-p: recursive delete "empty" directory
-
du:estimate file space usage
[root@Emma ~]# du [选项] 目标或者文件…
参数(常用):
-a:显示目录中个别文件的大小
-s:仅显示总计
-h:提供易读容量单位(K,M,G),提高信息的可读性 -
cp:Copy
[root@Emma ~]# cp [选项] 原文件… 目标路径
选项与参数:
-r:递归持续复制,用於目录的复制行为(常用)
-p:保持原文件的属性不变
-f:强制覆盖 -
rm:Remove
[root@Emma ~]# cp [选项] 文件或目录
选项(常用):
-r:递归持续复制,用於目录的复制行为;(常用)
-p:保持原文件的属性不变
-f:强制覆盖 -
mv:Move
[root@Emma ~]# mv [选项] 原文件或目录 目标路径
选项:
-f :force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖
-i :若目标文件 (destination) 已经存在时,就会询问是否覆盖
-u :若目标文件已经存在,且 source 比较新,才会升级 (update) -
ln:Link
[root@Emma ~]# ln [-s] 原文件或目录… 连接路径路径 -
alias: Custom command aliases
[root @ Emma ~] # alias sh = 'shutdown -h now' -
alias: Cancel alias
[root @ Emma ~] # unalias sh -
CAT:
[root @ Emma ~] # CAT [options] file
options and parameters (common):
-b: lists the line number, line number only for do not blank the display
-E: The end of the line break bytes $ displayed ;
-n: Print the line number, along with a blank line will have line numbers, and the -b option different;
-T: the [tab] ^ I button to be displayed;
-v: Some lists do not see special character
The above is a concise version of the study notes, there is an error please point out -