#3. File directory management for Linux

Source: Internet
Author: User

The structure of the directory begins with/starts, called the root directory, and the Linux directory structure is like an inverted tree structure.

(image from "Linux is this stylish" Zhao Xinlei, Zhang Jie) Folder Description Binbinary files for required commandsBootstatic files for the boot loaderDevDevice Filesetchost-specific system configurationLibrequired shared libraries and kernel modulesMediamount points of removable mediaMnttemporarily mount a file system mount pointOptExternal Application PackagesSbinRequired system-level binariesSrvdata files of the services provided by the systemTmpTemporary FilesUsrLevel Two hierarchyVarvariable DataFor further information, refer to FHS (Filesystem Hierarchy Standard (file system directory standards)). attached PDF of FHS
    1. #目录创建
    2. mkdir #目录名
    3. #目录删除
    4. rmdir #目录名
    5. #目录查看
    6. tree #以树状图显示目录
    7. CD #切换目录
File is path, absolute path and relative path, absolute path is like home address from County Town Street (village) number, relative path is you stand in town, tell others, where your home, based on the current, without having to tell the front of the provinces and counties.
    1. pwd #查看当前路径
Common commands about files
  1. #文件创建
  2. touch 文件名
  3. #显示文件
  4. ls 文件名#显示目录下文件列表,通常与-a 或-l使用
  5. less 文件名#分屏显示
  6. cat 文件名#查看文件内容
  7. head 文件名#显示文件头部
  8. tail 文件名#显示文件尾部
  9. #删除文件
  10. rm 文件名#常用 rm -rf 文件名 强制删除文件或目录内的所有文件
Special commands for files
  1. diff 文件名文件名#对比两个文件
  2. mv 文件名文件名#重命名
  3. mv 文件名路径#移动文件
  4. find /-name 文件名#在根目录下按文件名查找
  5. find /-d 目录名#在根目录下按目录名查找
  6. cmp 文件名文件名#对比两个文件差异
  7. lsattr 文件名#显示文件属性
  8. CP File name path #复制文件到某路径下
  9. #文件的编辑
  10. Vim file name
  11. VI file name
  12. Emacs file name
Permissions for files and directories take a look at-rw-rw-r--. 1 AAA AAA 0 July 10:31 1.txtdrwxrwxr-x. 2 AAA AAA 4096 July 11:01 Demod rwx rwx r-x 2 AAA AAA 4096 July 11:01 Demofiletypeowned bypermissions belong to group permissions other permissions link number owner user group file size file last modified time file namefile types are:-Files, D directories, l connections, B-block devices, C-character devices, S socket files, p command pipeline filesin the permissions here   rwx rwx r-x owner rights belong to user group permissions other user rightsr= Read =4w= Write =2x= Execution =1rwx=4+2+1=7---=0
    1. chmod 权限目录或文件#修改文件或目录的权限
    2. chgrp 组名目录或文件#修改文件或目录的群组
    3. chown 用户名:组名目录或文件#修改文件或目录的拥有者和组
Instance sudo the function of this command is for a normal user to execute the command, temporarily change to root user execution in the Debian-based release version of the normal user directly using sudo in the Redhat-based release of the need to modify the/etc/sudoers file can be used. Since the file is read-only file 440 by default, it needs to be modified into a readable writable file before it can be modified. Specific changes are as follows
  1. su -#切换到root用户
  2. chmod 774/etc/sudoers #修改sudoers文件的权限为可读可写
  3. vi /etc/sudoers #编辑文件,将普通用户添加进去如
  4. #使用i进入插入编辑模式,添加后,输入 :wq 保存退出
  5. chmod 444/etc/sudoers #将权限修改成之前的只读
Files extracted and archived in the Linux platform common compressed file format is: *.tar.gz, *.tar.bz2, *.TAR.XZ, collectively referred to as the TAR compression package, the difference is the compression rate, and the speed of compression, compression rate to XZ highest GZ lowest, the compression speed is the opposite of GZ the highest.
    1. #解压缩
    2. tar -vxf 压缩包名
  1. #压缩文件
  2. tar -zcvf 文件名.tar.gz 待压缩文件
  3. tar -jcvf 文件名.tar.bz2 待压缩文件
  4. tar -Jcvf文件名.tar.xz 待压缩文件
  5. #差别在于压缩的格式不相同
Files to be compressed can be filled with multiple



From for notes (Wiz)



List of attachments

#3. File directory management for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.