linux command - file directory operation command

First, the basic format of the command

  • 1, the command prompt
[root@love2 ~]# 
[]:这是提示符的分隔符号,没有特殊含义。
root:显示的是当前的登录用户。
@:分隔符号,没有特殊含义。love2:当前系统的主机名(默认主机名是 localhost.localdomain,我已经修改了)。
~:代表用户当前所在的目录,此例中用户当前所在的目录是家目录。
#:命令提示符。超级用户是#,普通用户是$
  • 2, the basic format of the command
[root@love2  ~]# 
命令 [选项] [参数] 
ls 是最常见的目录操作命令,主要作用是显示目录下的内容。
命令名称:ls。
英文原意:list。 
所在路径:/bin/ls。
执行权限:所有用户。
功能描述:显示目录下的内容

Second, the commonly used commands.

2.1, directory operations command
    1. ls command
[root@love2 ~]#ls [选项] [文件名或目录名] 
选项:  
-a:    显示所有文件  
--color=when: 支持颜色输出,when的值默认是always(总显示颜色),也可以是never(从不显示颜色)和auto(自动)  
-d:    显示目录信息,而不是目录下的文件  
-h:    人性化显示,按照我们习惯的单位显示文件大小  
-i:    显示文件的i节点号  
-l:    长格式显示 


The first column: authority. After the description of the specific permissions blog again.
Second column: reference count. File reference count represents the number of hard links to the file, directory and reference count represents the number of the directory has a subdirectory.
The third column: the owner, that is, the files belong to which users. The default is the owner of the establishment of user files.
The fourth column: owning group. The default owning group is to establish an effective set of files the user, under normal circumstances is to set up a user's group.
Fifth column: size. The default bytes.
The sixth column: file modification time. File modification time status or data file modification time will change this time, note that this time is not the time to create the file.
Seventh column: the file name.

  • 2.cd command
    cd command is to switch the directory
    name of the command: cd
    English original intent: change directory
    path where: Shell built-in command
    execute permissions: All users.
    Functional Description: Switch directory

  • 3.pwd command
    pwd command is to query the directory where the command
    command name: pwd
    English original intent: print name of current / working directory
    path where: / bin / pwd
    execute permissions: All users.
    Description: Discover where the working directory

  • 4.mkdir command
    mkdir command to create a directory,
    the command name: mkdir.
    English original intent: make directories.
    The path: / bin / mkdir.
    Execute permissions: All users.
    Description: Create an empty directory.
[root@love2 ~]# mkdir [选项] 目录名 选项
-p:  递归建立所需目录
  • 5.rmdir command
    to delete the directory command rmdir
    command name: rmdir
    English original intent: remove empty directories
    path where: / bin / rmdir
    execute permissions: All users
    Description: Delete empty directory
[root@love2 ~]# rmdir [选项] 目录名 选项
-p:  递归删除目录  
#rmdir 命令的作用十分有限,因为只能删除空目录,所以一旦目录中有内容,就会报错。
2.2, file manipulation commands
    1. touch command
      creates an empty file or modify file time
      command name: touch
      English original intent: change file timestamps
      path where: / bin / touch
      execute permissions: All users
      timestamps modify files: Function Description
    1. stat command
      stat is a command to view file details, and you can see three times the file
      name of the command: stat.
      English original intent: display file or file system status
      path where: / usr / bin / stat
      execute permissions: All users.
      Details of the file or the file system: Description
  • 3. The cat command
    cat command to view the contents of the file.
    Command name: cat
    English original intent: concatenate files and print on the standard output
    path where: / bin / cat
    execute permissions: All users.
[root@love2 ~]# cat [选项] 文件名 选项:  
-A: 相当于-vET选项的整合,用于列出所有隐藏符号  
-E: 列出每行结尾的回车符$  
-n: 显示行号  
-T: 把Tab键用^I显示出来  
-v: 列出特殊字符
  • 4. more command
    more is split screen display command file
    command Name: more
    English original intent: file perusal filter for crt viewin
    path where: / bin / more
    execute permissions: All users
    Description: split-screen display file contents.
    The more command is relatively simple, generally do not have any options, the command will open an interactive interface, you can identify some interactive commands. Common interactive commands as follows:
    spacebar: Down
    B: page up
    ENTER: Scroll line
    / string: search string specified
    q: exit.

    1. less command
      less command and command more similar, but more is split screen display command, and the less is the branch display command.
      Command name: less
      English original intent: opposite of more
      paths where: / usr / bin / less
      execute permissions: All users
      Description: Branch display file contents
    1. head command head is used to display the beginning of the file command
      command name: head
      English original intent: output the first part of files
      where the path: / usr / bin / head
      execute permissions: All users
      Description: display the contents of the beginning of the file
[root@love2~]# 
head [选项] 文件名
-n 行数: 从文件头开始,显示指定行数  
-v:   显示文件名  
  • 7. tail command
    displays the command at the end of the file.
    Command name: tail.
    English intent: output the last part of files
    path where: / usr / bin / tail.
    Execute permissions: All users
    Description: display the contents of the end of the file.
命令格式 [root@love2 ~]# 
tail [选项] 文件名 
选项:  
-n 行数: 从文件结尾开始,显示指定行数  
-f:  监听文件新增内容。
    1. ln command
      command name: ln
      English original intent: make links between file.
      the path: / bin / ln
      execute permissions: All users
      Description: establish links between files
8.1 Basic use
[root@love2 ~]# ln [选项] 源文件 目标文件 
选项:  
-s: 建立软链接文件。如果不加“-s”选项,则建立硬链接文件  
-f: 强制。如果目标文件已经存在,则删除目标文件后再建立链接文件 
8.2 Create a soft link
[root@love2 ~]# ln -s edu.txt /tmp/
软链接特征:
#软链接和源文件拥有不同的 Inode 和 Block
#两个文件修改任意一个,另一个都改变 
#删除软链接,源文件不受影响;删除源文件,软链接不能使用
#软链接没有实际数据,只保存源文件的 Inode,不论源文件多大,软链接大小不变
#软链接的权限是最大权限 lrwxrwxrwx.,但是由于没有实际数据,最终访问时需要参考源文件权限
#软链接可以链接目录 
#软链接可以跨分区
#软链接特征明显,建议使用软连接 
8.3, hard links
ln edu.txt /tmp/ (不写名字,和原文件名一致)
#也就是 /root/edu.txt 和 /tmp/edu.txt 是硬链接文件
#硬链接特征:
#源文件和硬链接文件拥有相同的 Inode 和 Block
#修改任意一个文件,另一个都改变
#删除任意一个文件,另一个都能使用
#硬链接标记不清,很难确认硬链接文件位置,不建议使用 
#硬链接不能链接目录
#硬链接不能跨分区 
2.3 commands, directories and files can be operated
  • 1. rm command
    rm is a powerful command to delete, not only can delete files, you can also delete the directory
    name of the command: rm
    English original intent: remove files or directories
    path where: / bin / rm
    execute permissions: All users
    Description: Delete a file or directory
[root@love2 ~]# rm [选项] 文件或目录 
选项:  -f:  强制删除(force)  
-i:  交互删除,在删除之前会询问用户  
-r:  递归删除,可以删除目录(recursive) 
  • 2. cp command
    cp command is used to copy the
    name of the command: cp.
    English original intent: copy files and directories
    path where: / bin / cp.
    Execute permissions: All users
    Description: copying files and directories.
命令格式 [root@love2 ~]# cp [选项] 源文件 目标文件 
选项:  
-a:  相当于-dpr选项的集合
-d:  如果源文件为软链接(对硬链接无效),则复制出的目标文件也为软链接  
-i:  询问,如果目标文件已经存在,则会询问是否覆盖  
-p:  复制后目标文件保留源文件的属性(包括所有者、所属组、权限和时间)  
-r:  递归复制,用于复制目录 
  • 3. mv command
    mv command is used to cut the
    command name: mv
    English original intent: files move (rename)
    path where: / bin / mv
    execute permissions: All users.
    Description: move or rename files.
命令格式 [root@localhost ~]# mv [选项] 源文件 目标文件 
选项:  
-f:  强制覆盖,如果目标文件已经存在,则不询问,直接强制覆盖  
-i:  交互移动,如果目标文件已经存在,则询问用户是否覆盖(默认选项)  
-v:  显示详细信息 

Guess you like

Origin www.cnblogs.com/hjnzs/p/11916943.html