Linux Common Command Collation (ii)

Source: Internet
Author: User

Permission Settings

chmod changing the permissions of a file or directory
Format chmod parameter file name
R-Read W-write X-Execute
U-user owner G-group belongs to group o-others others a-all everyone
+ Add a permission
-Cancel a permission
= gives the given permission and cancels all original permissions
In addition, you can use numbers to represent permissions
R = 4
W = 2
x = 1
For example: chmod 777 a means that the permission to modify file A is-rwxrwxrwx
Other permissions are similar


Chown change the owner of a file or directory
Format chown User file name


CHGRP change a file or directory belongs to a group
Format CHGRP user group file name
Prerequisites: This user group must be present in the system


Umask setting limits the mask for new files
The default mask in Linux is 022.
We directly enter the Umask command, the display is 0022, where the first bit is a special permission, the following three bits is the mask of our permission, the mask is 777 minus the file permission of the number representation.
The default permissions for our files are 755,777-755=022, so the mask here is 022.


Soft and hard link file

Create a soft link to file a
Ln-s a A.soft
Create a hard connection to file a
Ln-d a A.lnk

Hard Links
Because files under Linux are identified by an index node (inode), a hard link can be considered a pointer to a pointer to a file index node, and the system does not redistribute the inode for it. Each add a hard link, the number of links to the file is added 1.
Soft links
Soft links overcome the lack of hard links, without any file system restrictions, any user can create symbolic links and can create symbolic links for the table of contents. It is now more widely used, it has greater flexibility, and can even link files across different machines and networks.

Contrast
(1) Soft links can cross the file system, hard links are not available.
(2) questions about the inode. Hard links no matter how many, are pointing to the same inode, will increase the number of inode links, as long as the inode link number is not 0, the file exists, regardless of whether you delete the source files or linked files. As long as there is a existence, the file exists (in fact, there is no source file linked files, because they point to the same inode). When you modify the source file or any one of the linked files, the other files will be modified synchronously. Soft links do not use inode numbers directly as file pointers, but instead use file path masterpieces as pointers (soft links are not the same as the inode of the source file). So deleting a linked file has no effect on the source file, but deleting the source file will not find the file you want to point to. The soft link has its own inode, and there is a small space on the disk to store the path name
(3) Soft links can link to a nonexistent file name
(4) Soft links can be linked to the directory


Common Find Commands

Find/-amin-10 #查找在系统中最后10分钟访问的文件
Find/-atime-2 # finds files accessed in the last 48 hours of the system
Find/-empty # finds files or folders that are empty in the system
Find/-mmin-5 # finds files that have been modified in the last 5 minutes of the system
Find/-mtime-1 #查找在系统中最后24小时里修改过的文件
Find/-nouser #查找在系统中属于作废用户的文件
Find/-user Fred #查找在系统中属于FRED这个用户的文件
Find/home/admin-mtime-1 #查找 files in the/home/admin directory within 1 days of modification
Find/home/admin-name *.txt-mtime-1 #查找/home/admin files with a file name of. txt that is within 1 days of the modified directory

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.