1 / 12

File ownership and permissions

File ownership and permissions. File ownership. Every file in Linux must have the following:- File user owner File group owner File permissions There are 3 types of file permissions:- r - read w - write x - execute

Télécharger la présentation

File ownership and permissions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. File ownership and permissions

  2. File ownership • Every file in Linux must have the following:- • File user owner • File group owner • File permissions • There are 3 types of file permissions:- • r - read • w - write • x - execute • These file permissions are further grouped into the following categories:- • (u)ser owner • (g)roup owner • (o)thers

  3. To view all the information discussed on the previous slide. We can use the ‘-l’ option of the ‘ls’ command. To modify file ownership and permissions, use the ‘chmod’, ‘chgrp’ or ‘chown’ command.

  4. chmod Usage The ‘chmod’ is used to change file permissions. Every file has the following permission bits To change the permission of a file, we use the chmod command with the following options shown on the next slide.

  5. chmod options

  6. Example chmod options chmodu+x<filename> chmod -w<filename> chmodug+w<filename> chmod all=x<filename> Where <filename> is the name of the file to change permissions on.

  7. Changing file group and user owner To change a file’s group owner, we use the ‘chgrp’ command. Only the root user can change the user owner of a file. To change the user owner, use the ‘chown’ command.

  8. Directory permissions Directories are treated in the same way as files. We use the same commands and options to change permissions and ownership. The only difference is the e(x)ecute bit. In directories, ii does not make sense to execute a directory. Rather, it is use by the kernel to permit access to the directory.

  9. Octal notation for chmod command Each permission bit for the (u),(g) and (o) categories are given a value as shown below:- All octal notation need to have 3 digits to work. The value of the 3 digits are the sum of the activated permission bits of the 3 categories.

  10. Example octal notation chmod 666 <filename> - means the file will have rw bits set for all the categories. chmod 777 <filename> - means the file will have all permission bits set for all categories. chmod 750 <filename> - means the file have all permissions set for owner, rx bits only for group, no permission bits set for others.

  11. Umask Default permission for Linux files are 666. Default permission for Linux directories are 777. But when we logon, there is a special variable called umask. This umask controls the default permissions for file and directory creation. Default value for umask is 002. To change the umask value after logon. Use the umask command.

  12. Understanding umask • Default kernel file permissions:- rw-rw-rw- means 666 umask 002 default file create permissions 664 • Default kernel directory permissions:- rwxrwxrwx means 777 umask 002 default dir create permissions 775

More Related