Permissions In Linux
chmod - modify file access rights
su/sudo - temporarily become the superuser
chown - change file ownership
chgrp - change a file's group ownership
vivek@home:~$ ll craizy
-rw-rw-r-- vivek vivek 196 Sep 1 03:16 craizy
# ls -l Or ll
-rw------- 1 vivek lab1 576 Aug 8 1998 location.txt
drwxr-xr-x 6 vivek lab2 1024 Jun 26 1999 whether
-rw-rw-r-- 1 vivek lab1 276480 Jan 4 20:41 web_holder.tar
---------- ------ ----- ------- ---------- ----------- -------------
| | | | | |
| | | | | +---- File Name
| | | | |
| | | | +--------------- Modification Time
| | | |
| | | +------------------------------------- Size (in bytes)
| | |
| | +------------------------------------------------ Group
| |
| +-------------------------------------------------------- Owner
|
+----------------------------------------------------------------------- File Permissions
File Permission
- rwx rwx rwx
--- --- ---
| | | |
| | | |
| | | +------- Read,Write and Execute for all other users
| | |
| | +------------- R/W/E for the group owner
| |
| +-------------------- R/W/E for the owner only
|
+------------------------ File type - indicates file/ d indicates Directory/l indicates symbolic link
chmod
The chmod command is used to change the permissions of a file or directory.There are two ways to specify the permissions,octal notation method (numeric) is easy to use.
It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here's how it works:
rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000
and so on...
rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-x = 101 in binary = 5
r-- = 100 in binary = 4
4 read (r)
2 write (w)
1 execute (x)
7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)
How to set permission
chmod 666 test.txt read/write by anybody!
chmod 755 test.txt rwx for owner, rx for group and rx for the world
chmod 777 test.txt read, write, execute for all!
su/sudo
It is often necessary to become the superuser to perform important system administration tasks, but as you have been warned, you should not stay logged in as the superuser. In most distributions, there is a program that can give you temporary access to the superuser's privileges. This program is called su (short for substitute user)
In some distributions, most notably Ubuntu, an alternate method is used. Rather than using su, these systems employ the sudo command instead. With sudo, one or more users are granted superuser privileges on an as needed basis.
chown
Change the user ownership and group ownership of a file/dir by using the chown command.
Usage
# chown <username>.<groupname> file/dir
chgrp
The group ownership of a file/dir may be changed with chgrp command.
Usage
# chgrp <groupname> <filename>
Permissions In Linux
Reviewed by vivek sathisan
on
12:30
Rating:

No comments: