My Linux path----Linux directory file management

Source: Internet
Author: User
Tags create directory

    1. Several commands related to the directory:

      mkdir Creating a Directory

      -P cascade creation, for example: In the/root directory, create 11 directory, mkdir 11, can be created successfully, but if you create a multi-level directory, for example, to create 11/22/33/44, at this time, mkdir 11/22/33/44 will not be able to create a prompt, This is because the parent directory does not create a subdirectory, like, no father where the son Ah!

      [Email protected] ~]# mkdir 11/22/33/44

      mkdir: Unable to create directory "11/22/33/44": No file or directory

      What to do, add a-P option, mkdir-p 11/22/33/44 at this time to create the success.

    2. RmDir Deleting a directory

      RmDir cannot delete a non-empty directory, this command is not very useful, generally with the following command instead.

    3. RM can delete directories or files

      -RF This is the strongest combination option,-R recursively deletes directories and contents,-f enforces deletions, ignores nonexistent files, and does not prompt for confirmation.

      Note: This command should be cautious, where it is, barren.

    4. CP Replication (copy)

      CP SourceFile Destinationfile

      -r This option is for the directory

    5. MV to move or rename the source file or directory

      When moving the MV directory, the source directory is moved to the target directory if the target directory exists.

Several common commands related to text

  1. Cat View text content

    Tac View text content as a flashback

    Less View large text, you can use the search function, flip page

       /word search down

       ?word Search

       ctrl+f Page DOWN

       ctrl+b page up

       J,K,G,G J cursor down one line, K cursor up one line, G moves the cursor to the first line, and G moves to the last row.

    Head-n View the first few lines of a file

    Tail-n View the last few lines of a file

  2. File or directory properties

    You can view files or destination properties

    -rw-r--R--. 1 root root  3482 September  12 07:40 install.log.syslog

    For example:

    First:-Delegate file

         d for directory

         s for sockets

        & Nbsp;l link file

         P pipe symbol

         B block device files, such as: hard disk, USB external connection device.

         C character device

    2,3,4 bit is the permission of the file owner

    5,6,7 the permissions of the group to which the file belongs

    8,9,10 bit is the permission of the other person

    Number 1 That represents a few files after the

    Root represents the file to which the primary is the root

    and then the root on behalf of the group that the file belongs to is root

    After 3482 for file size

    File permissions rwx=421, The newly created directory default permission is 755

              The newly created file default permission is 644, that is, the file is a

    with no execute permission. We use the Umask command to see the 666-022=644 of the 77-022=755

    File umask=022 the

    Directory.

  3. Change permissions

    1.chown change owner, owning group

     chown username Change owner

     chown:groupname Change owning group

     chown username:groupname owner and group, change together.

     chown-r The owning of all cascading directories also changes

    2.chmod Change permissions (rwx)

     u,g,o,a Rep: User,group,others,all.

     u+r/w/x= added

     u-r/w/x= minus

    3.chattr 

     +a (append append, add) After setting this parameter, can only add data to the file, not delete, more for the server log file security, only root can set this property.

     +i Add this permission, which is worse than the one above, and none of the additions.

      View using the lsattr command, add the-r option to see which file has special permissions.

    4.cat/etc/issue View System version number

     uname-a View System kernel version number

     yum update system upgrade version

     yum-y The difference between update and YUM-Y upgrade is that the

     yum update package, upgrade the system kernel and the system version

     yum upgrade just upgrade the package, other unchanged

  4. Set_uid,set_gid,sticky_bit Special Permissions

    Suid has the permissions of the owner of the file, which is equivalent to owning the

    Sgid has the permissions of the group to which the file belongs, equivalent to owning the file all groups in the operation

    Stid set this permission, it is for the directory, if the directory is set stick bit (sticky bit), then the file in addition to the file creator and root user can delete and modify the/tmp directory stuff, other users cannot move others, this is the role of sticky bit.

chmod u+s XXX # set setuid permissions

chmod g+s XXX # set Setgid permissions

chmod o+t XXX # set stick bit permissions for directory

chmod 4775 XXX # set setuid permissions

chmod 2775 XXX # set Setgid permissions

chmod 1775 XXX # set stick bit permissions for directory

Note: Sometimes you set the S or T permission, you will find it becomes s or T, this is because in that position you do not give it X (executable) permissions, so that the setting is not valid, you can first give it an X permission, and then give S or T permissions.

E. Search

    1. Which used to find where the command is.

    2. Whereis is used to find where the command is, and the Man manual for the command is listed

    3. Located lookup speed is quite fast, equivalent to local search, need to updatedb update. Otherwise not found,

    4. Find uses the most, also the most useful

      -type

      -name

      -mtime or-mmin

      -ctime or-cmin

      -atime or-amin

      -size

      -user

      -perm

      Fine./root/xxx-exec command {} \; This is a good command, too.

    5. Stat filename can view three time of a file


This article is from the "My Linux Road" blog, so be sure to keep this source http://8641765.blog.51cto.com/8631765/1696144

My Linux path----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.