Ubuntu directory and permissions (create directory, change directory owner, change directory permissions)

Source: Internet
Author: User
Tags chmod create directory mkdir parent directory file permissions

1.Ubuntu Create directory
Command format:
mkdir [options] directory ...
Command features:
The mkdir command enables you to create a directory named with the specified name at the specified location. The user who created the directory must have write permissions to the parent directory of the directory being created. Also, the directory you create cannot have the same name as the other directory in its parent directory (case-sensitive).
Command parameters:
-M, set permissions < mode > (similar to chmod)
-p, recursively set up a multilevel directory;
-V, display information
–help displays this help information and exits
–version output version information and exits
mkdir Test Create test directory
mkdir test1 test2 test3 Create multiple catalogs
mkdir–p test1 test12 test123 recursively create directory
Mkdir–m 777 test Create a set of permissions directory
Mkdir–v test1 test2 test3 Create directory , prompting you to create process information

2.Ubutnu Change Permissions
command format:
chmod [-CFVR] [--help] [--version] Mode file ...
Command features:
Linux/unix file invocation permissions are divided into three levels: file owners, groups, and others. You can use chmod to control how files are invoked by others.
Command parameters:
Mode: Permission set string, in the following format: [Ugoa ...] [[+-=][RWXX] ...] [,...] where
U represents the owner of the file, G means that the owner of the file belongs to the same group (group), and O means the other person, and a means all three. The
+ indicates an increase in permissions,-a cancellation of permissions, = A unique set of permissions.
R means readable, W is writable, X is executable, x means only if the file is a subdirectory, or the file has been set to executable.
-C: If the file permission does change, it displays its change action
-F: Do not display error messages if the file permissions cannot be changed
-V: Displays details for permission changes
-r: The same permission changes are made to all files in the current directory and subdirectories (that is, the The way recursion is changed one by one)
–help: Show Secondary description
–version: Show version
chmod ugo+r file1.txt (chmod a+r) to file1.txt files Set to all people can read the
chmod ug+w,o-w file1.txt file2.txt the file file1.txt and File2.txt as the owner and the same group can write, the user is not writable
Chmod-r A+r * will be the current All files and subdirectories under the directory are set to anyone who can read the

In addition chmod can also use numbers to represent permissions, which are:
Each of these a,b,c is a number, representing the permissions of user, Group, and other respectively.
To rwx the property is 4+2+1=7;
To rw-the property is 4+2=6;
To r-x the property is 4+1=5.
chmod 777 File1.txtfile1.txt open to all users

3.Ubuntu Change Owner
Command format:
chown [-CFHVR] [–help] [–version] user[:group] File ...
Command function:
Change the owner and group of a file or directory.
Command parameters:
-R handles all files in the specified directory and its subdirectories
-V Display detailed processing information
Chown Wang Shiyan.c changed the owner of the file shiyan.c to Wang.
Chown-r Wang.users/his The owner of the directory/his and all the files and subdirectories under it to Wang, and the group changed to users

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.