Linux file and directory management --Linux learning

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_43522055/article/details/101036781

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
    Here Insert Picture Description
  • Relative path: not by / written from
    Here Insert Picture Description

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
Here Insert Picture Description

Help command:

  1. help: can only be used for internal command, not for external command
    format: - help command name
    Here Insert Picture Description
  2. -Help: for external command
    format: - command name --help
    Here Insert Picture Description

Common command processing directory

  1. ls: List directory / file attributes
  2. cd: Change directory
  3. pwd: View the current working directory
  4. touch: create a new file, or update the file timestamps
  5. mkdir: create a new directory
  6. rmdir: delete empty directories
  7. du: assessment of the size of directories and files
  8. cp: copy files or directories
  9. rm: Remove files or directories
  10. Name move files and directories, or modify files and directories: mv
  11. ln: create connection files (soft connection, the equivalent shortcut)
  12. alias: Set command aliases
  13. unalias: Cancel Alias
  14. 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)
    Here Insert Picture Description

  • 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.
    Here Insert Picture Description

  • 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
    Here Insert Picture Description

  • rmdir: delete empty directories
    [root @ Emma ~] # mkdir [-p] directory name
    options and parameters:
    -p: recursive delete "empty" directory
    Here Insert Picture Description

  • 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 -

Guess you like

Origin blog.csdn.net/weixin_43522055/article/details/101036781