Linux Directory file Management

Source: Internet
Author: User
Tags temporary file storage touch command

Linux System main directory and its contents

Directory
Content
/bin
Commands required to build a minimal system (most commonly used commands)
/boot
Kernel and boot files
/dev
Various device files
/etc
System software startup and configuration files
/home
User's home directory
/lib
C Compiler's Library
/media
Mounting points for removable media
/opt
Optional Application Package
/proc
Image of the process
/root
Superuser Root's home directory
/sbin
Commands related to system operations
/tmp
Temporary file storage points
/usr
Non-system programs and commands
/var
System-specific data and configuration files


  1. Resume catalogue mkdir.

    MkDir can create one or more directories.

    mkdir ducument Piciture # #建立2个目录

    mkdir ~/piciture/temp # #在主目录下建立名为temp的目录

    MKDIR provides the-p option for the complete creation of a subdirectory structure

    Mkdir-p ~/tempx/job # #当目录中不存在tempx目录时, the system tries to create it and then creates the job directory.

  2. Resume an empty file touch.

    You need to follow the file name as a parameter after touch

    Touch Hello # #创建名为hello的空文件

    Another use of the Touchu command is to update the date and time the file was created

  3. Move and rename: MV

    MV Hello bin/# #把hello文件移动到bin目录下

    MV Piciture/bin/# #把picture目录移动到bin目录下

    The MV command does not have any information during execution, which may seem a bit serious, in order to prevent users from removing important content, MV provides the-I option for discovering such situations

    mv-i Hello test/# #mv: whether to overwrite Test/hello. During the move, you are prompted to move the files to the test directory. Reply Y is ok

    The MV does not have the concept of renaming. The MV moving in the same directory is the renaming of the file.

    CD ~/picture # #进入到picture目录

    mv./hello./hello~ # #在同一个目录里, move the hello file to hello~, which is the renaming of the Hello file

  4. Copy files and directories: CP

    CP Command and MV Command exception, CP overwrites the file with the same name in the target directory by default. You can use the-I option to prompt for this situation. No more demonstrations here.

  5. Delete files and directories: RmDir and RM

    RmDir for deleting directories. This command is simple, just follow the directory name you want to delete as a parameter. Note RmDir can only delete empty folders

      $sudo mkdir remove   # #创建一个名为remove的文件夹

      $sudo rmdir remove & nbsp; # #删除这个目录 the

    RM command to delete one or more files at a time.

      $sudo RM test/*.php     # #删除test目录下所有的php文件

    RM and MV commands do not have any prompts during the removal process. Files deleted through RM will disappear forever from the system and will not be placed in the Recycle Bin. A more secure way to use the RM command is to use the-I option, which prompts you before deleting a file and waits for the user to confirm that

      $sudo rm-i test/test.php  # #rm: Delete the normal file test.php?

    RM provides the-f option to avoid such an interaction, forcing the delete file

    RM provides the-r option to recursively delete all files and subdirectories under the directory.

       $sudo rm-r picture/   # #删除picture目录下的所有的文件和子目录

    Use the RM command with extreme care to avoid deleting important files and directories

  6. Permissions for directories and files: Read (R), write (w), and execute

    You can clearly see the properties of a file, including permissions, by viewing the file properties ls-l command.

    $ls-L/bin/login

    -rwxr-xr-x 1 root root 38096 2016-06-05 14:54/bin/login

    A. The first character of the first field represents a file type. (-) plain files, (d) directory files, (c) character device files, (b) block device files, (s) local domain sockets, (p) known channels, (l) symbolic connections

    B. The second field represents a permission. Rwxr-xr-x, these 9 characters should be such a broken bit, rwx,r-x,r-x, respectively, the owner, belong to the group, and other people have permissions.

    C. Jinzhao This permission field represents the number of connections for the file. Here is 1, indicating that the file has only one hard link

    D. The third field represents the owner, and the fourth field represents the genus group, in this case the owner of the login file is the root user and the group is the root group

    E. The last field represents the file size (38096 bytes), the last modification date and time, and the full path of the file

  7. Change file ownership chown and CHGRP

  8. Change file Permissions chmod

  9. Octal representation of file permissions. Rwx=4+2+1=7 is expressed as 111,r--=4,---= 0 for 000,-w-= 0+2+0 = 2 for 010,--x 0+0+1 = 1 for 001,rwxr-xr-x=755, and so on.

Summary:

    • Linux directory organization and windows are very different

    • Linux mounts file systems to a specific directory, and the root filesystem "/" is the file system that was originally created

    • Each system directory for Linux has its own specific features

    • mkdir command to create an empty directory

    • Touch command to create an empty file

    • MV command to move or rename files and directories

    • CP command to copy a file or directory

    • rmdir command to delete an empty directory. The RM command can delete files and directories.

    • Linux defines permissions for files that belong to the owner, group, and other users

    • Permissions to the file directory are read (r), write (w), and execute (x)

    • The ls-l command lists the full properties of the file. To view the properties of a file using the LS-LD command

    • Chown command to change the owner and owner of a file, chgrp only change the genus Group

    • chmod command changes the permissions of the file, there are many ways to express, octal is the most commonly used expression.

    • There are a total of 7 file types in Linux. (-) plain files, (d) directory files, (c) character device files, (b) block device files, (s) local domain sockets, (p) known channels, (l) symbolic connections


This article is from the "Ah Cool blog source" blog, please make sure to keep this source http://aku28907.blog.51cto.com/5668513/1786216

Linux Directory file Management

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.