Linux Commands for Beginners-- Changing Permissions --chmod command

   In this part, I go over changing permissions of files and folders.

   
1.COMMAND:
    chmod
  DESCRIPTION:
     change file mode bits
  SYNOPSIS:
     chmod [OPTION] [ugoa][+-=][rwx]  FILE
    
  OPTION:
     -R recursive, include objects in subdirectories
    
   u user the owner of the file
   g groupusers who are members of the file's group
   o othersusers who are neiter the owner of the file nor members of the file's group
   a allall three of the above, same as ugo
 
   + adds the specified modes to the specified classes
   - removes the specified modes from the specified classes
   = the modes specified are to be made the exact modes for the specified classes


   r read    read a file or list a directory's contents
   w writewrite to a file or directory
   x executeexecute a file or recurse a directory tree


 

    If you have any problem in reading following example,maybe you need to know more about file permission.Want more information?You can click my previous tutorial File Permission



Example:
   
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
-rw-rw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt
piniheaven@fish:~/Documents/tutorial$
sudo chmod u+x essay.txt #give user the permission to execute essay.txt
[sudo] password for piniheaven: 
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
-rwxrw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt


piniheaven@fish:~/Documents/tutorial$ sudo chmodu-r essay.txt  #remove user's permission of reading essay.txt
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
--wxrw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt


piniheaven@fish:~/Documents/tutorial$ sudochmod uo+r essay.txt#give user and others the permission of reading essay.txt
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
-rwxrw-r-- 1 jack piniheaven 0 Aug 25 21:42 essay.txt




piniheaven@fish:~/Documents/tutorial$ sudo chmod a=x essay.txt  #assign user,group and others only the permission to execute essay.txt
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
---x--x--x 1 jack piniheaven 0 Aug 25 21:42 essay.txt



piniheaven@fish:~/Documents/tutorial$sudo chmod ugo+rwx essay.txt  #assign user,group and others with the permission of read,write and excute
piniheaven@fish:~/Documents/tutorial$ ls -l
total 0
-rwxrwxrwx 1 jack piniheaven 0 Aug 25 21:42 essay.txt


piniheaven@fish:~/Documents/tutorial$
cd ..
piniheaven@fish:~/Documents$sudo chmod -R a=rx tutorial #assign user,group and others with the permission of read and excute, including it's subdirectories

piniheaven@fish:~/Documents$ ls -l
total 32
drwxrwxr-x  4 piniheaven piniheaven 4096 Aug 22 12:16 assemble
......
......
dr-xr-xr-x  2 jack       piniheaven 4096 Aug 25 21:42 tutorial
piniheaven@fish:~/Documents$ ls -l tutorial/
total 0
-r-xr-xr-x 1 jack piniheaven 0 Aug 25 21:42 essay.txt









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值