Linux Command Learning Series 11-umask,file,find

Source: Internet
Author: User
Tags chmod file permissions

Previous section review:

1. File/directory Details

2. Modify Permissions command: chmod command

3. Modify file Owner: Chown command

4. Modify file All groups: Chgrp command

Job: Create file Test.txt, modify the file permissions for the owner has read and write permissions, all groups have read and write permissions, other people have access to the permission to change the file owner is User1

Touch Test.txt

chmod u=rwx,g=rw,o=r Test.txt

Chown user1 Test.txt

1. default permissions and Umask

By looking at the files we create ourselves, we can discover that the permissions are: 644

The permissions for the directory are: 755

This is the default permissions that the system gives when creating files and directories, the default permissions are computed by Umask mask 777 to get the default permissions of the directory, umask the default permissions of the file after masking 666, and the system will set different umask,umask values according to the user's ID can be viewed The/etc/profile file concludes

You can see that the UID is greater than 199 and the group name equals the user name, umask take 002, otherwise take 022.

How the mask is calculated, with the above as an example, 777 of the permission is the rwxrwxrwx,022 permission is----w--w-,022 will be 777 of all groups and other users of the W permission to cover, the Rwxr-xr-x is 755.

Similarly, 777 masks after 002 is 775, if we create a directory with User1, the default permission is 775, we can do an example:

2. View File types: Files command

Usage is simple, file/directory name, return file type and more information, such as

3. Find a file: find command

Find command: Basic usage: Find path –name file name

The path refers to the path under which to look for, for example, to find in the headlines record, use/. For example, to find the file nginx.conf in the root directory, use the command: Find/-name nginx.conf

Let's say we narrow it down, look under/etc, Find/etc–name nginx.conf

You can use the * number (wildcard character) for fuzzy lookups, for example, to find the. Log end, find/-name *.log

Common parameters:

-perm Search based on file permissions

-user Search by user name

-mtime–n/+n find files that have been changed in n days and/or days ago

-atime–n/+n find files accessed in n days/N days ago

-ctime–n/+n find files created in n days before/n days

-newer filename Lookup Change time than filename new file

-type b/d/c/p/l/f/s Find files of the appropriate type

-size Search by File size

-dept n Max file find directory depth

Job: Create a Test.txt file in the/tmp directory, view the file's default permissions, use the Find command to find the file you just created, and use the file command to view the type of files you just created


Video tutorials to pay attention to the public number "kick genius" get

Linux Command Learning Series 11-umask,file,find

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.