Linux Common Commands 2 chmod, chown

Source: Internet
Author: User
Tags create directory

chmod Command

[Email protected] ~]# ls-l

Total 104

Drwxr-xr-x. 3 root root 4096 Jul 2 22:34 222

See here Drwxr-xr-x , R=4,w=2,x=1, so rwx=4+2+1=7,r-x=4+1=5, r-x=4+1=5, Therefore, the file permission can be represented as 755

[email protected] ~]# chmod 744 222// will be 222 Directory permission changed to 744,744 Permissions =rwxr--r--

[email protected] ~]# ls-ld 222// View permissions have changed  

Drwxr--r--. 3 root root 4096 Jul 2 22:34 222

[Email protected] ~]# chmod u=rwx,g=r--, o=r--222

// This method is used to chmod 744 222 achieve the same effect, u to be User Lord, g to be Group Group, o to be Other other

[Email protected] ~]# LS-LD 222

Drwxr--r--. 3 root root 4096 Jul 2 22:34 222

[email protected] ~]# chmod u-x 222//user minus x Permissions

[Email protected] ~]# LS-LD 222

Drw-r--r--. 3 root root 4096 Jul 2 22:34 222

[email protected] ~]# chmod u+x,g+w,o-r 222//u Plus x Permissions , G Plus W Permissions , O minus R Permissions

[Email protected] ~]# LS-LD 222

DRWXRW----. 3 root root 4096 Jul 2 22:34 222

[email protected] ~]# chmod a+r 222// all are added R permissions, All+r

[Email protected] ~]# LS-LD 222

Drwxrw-r--. 3 root root 4096 Jul 2 22:34 222

[Email protected] ~]# mkdir 222/234

[[Email protected] ~]# Tree 222

222

├── 111

│ └── 123.txt

└── 234

2 directories, 1 file

[Email protected] ~]# ls-l 222

Total 8

Drwxr-xr-x. 2 root root 4096 Jul 2 22:25 111

Drwxr-xr-x. 2 root root 4096 Jul 2 23:15 234

[Email protected] ~]# ls-l 222/111/

Total 48

-rw-r--r--. 1 root root 48308 Jul 2 22:25 123.txt

[email protected] ~]# chmod-r 222// make 222 file only Master has permission

[Email protected] ~]# ls-l 222

Total 8

drwx------. 2 root root 4096 Jul 2 22:25 111// The file all permissions are changed to the

DRWX------. 2 root root 4096 Jul 2 23:15 234

[email protected] ~]# umask// Default catalog file properties 0022

0022

[email protected] ~]# mkdir 1112// Create directory default permissions are 777-022

[Email protected] ~]# LS-LD 1112/

Drwxr-xr-x. 2 root root 4096 Jul 3 06:06 1112/

[[email protected] ~]# Touch 12.txt// the Create file default permission is 666-022 , (Files do not need X permissions)

[Email protected] ~]# ls-ld 12.txt

-rw-r--r--. 1 root root 0 Jul 3 06:07 12.txt

[email protected] ~]# umask 011// Change umask value

[Email protected] ~]# umask

0011

[Email protected] ~]# umask 022

Chown Command

[Email protected] ~]# ls-l

-rw-r--r--. 1 root root 48308 Jul 2 23:02 1.txt

[Email protected] ~]# chown Wangchao 1.txt

chown:invalid User: ' Wangchao '// no such user

[email protected] ~]# useradd Wangchao// Create user Wangchao

[email protected] ~]# Groupadd user1// Create a group User1

[email protected] ~]# chown:user1 1.txt// change file group to User1

[Email protected] ~]# ls-l 1.txt

-rw-r--r--. 1 root user1 48308 Jul 2 23:02 1.txt

[email protected] ~]# chown root:root 1.txt// Change master and group back Root , Root

[Email protected] ~]# ls-l 1.txt

-rw-r--r--. 1 root root 48308 Jul 2 23:02 1.txt

[email protected] ~]# chown-r wangchao:user1 1112/// Cascade Change subdirectory master, group

[email protected] ~]#!ls// perform the previous execution ls the command

Ls-l 1.txt

-rw-r--r--. 1 root root 48308 Jul 2 23:02 1.txt

[[Email protected] ~]# history// View the history commands used

654 ls-l 1.txt

655 history

[email protected] ~]#!654// in the Execution History command, section 654 Bar Command

Ls-l 1.txt

-rw-r--r--. 1 root root 48308 Jul 2 23:02 1.txt

This article is from the Linux Learning Notes blog, so be sure to keep this source http://9656134.blog.51cto.com/9646134/1676164

Linux Common Commands 2 chmod, chown

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.