BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   System Admin (http://bzupages.com/51-system-admin/)
-   -   Chmod permission to files in linux ; Linux Terminal Commands; (http://bzupages.com/f51/chmod-permission-files-linux-%3B-linux-terminal-commands%3B-9227/)

.BZU. 08-04-2010 10:47 PM

Chmod permission to files in linux ; Linux Terminal Commands;
 
------------
Show long listing of the root directory.
The first column shows the permission strings, which grants permission for accessing files and directories.
The second column shows the number of hard links to a file or a directory.
Third column shows the owning user.
Fourth column shows the group that owns the file or directory.
Fifth column shows the file size.
Next column shows the creation date and time the file or directory was created.
Next column shows the file or directory name.
------------
Let's take a permission string as an example.

drwxr-xr-x

The first 'd' means it's a directory.
If the first letter is 'l', it's a link.
If it's a '-', it's a normal file.
Positions 2 to 4 is the permission of the owning user.
'r' means permission to read is granted.
'-' means permission to read is denied.
'w' means permission to write is granted.
'-' means permission to write is denied.
'x' means permission to execute is granted.
'-' means permission to execute is denied.
Positions 5 to 7 are the permissions to the owning group.
The last three positions are permissions for other users. Other users are those who are not owners, or are not members of the owning group.

This permission string -rw-r--r-- means it's a normal file. Read/Write permission is granted to the owner. Read permission is granted to both the owning group and all other users.

To deny the read access of the file to all other users, run
Code:

chmod o-r tmpfile1
'chmod' stands for change mode.
'o' stands for other which means all other users
'-' stands for remove permission
'r' stands for read permission
'tmpfile1' is the file name.

Now, the permission string becomes '-rw-r-----' as the read permission for all other users is removed.

To remove the read and write permission of the owning group, run
Code:

chmod g-rw tmpfile1
where g means 'owning group'.

Now, the permission string becomes '-rw-------' as the read and write permissions of the owning group are removed.

To grant read permissions to the all users, run
Code:

chmod ugo+r tmpfile1
where '+' stands for grant.

Now, the permission string becomes '-r--r--r--' as the read permission for all users has been granted.

To allow the owner to execute the file, run

Code:

chmod u+x tmpfile1
where x stands for the execution permission.

The execute permission is granted to the owner.


All times are GMT +5. The time now is 02:13 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.