Posts Tagged ‘permission’

setuid grants temporary access permission. A normal user inherits root privileges for the purpose of that process. setuid bit is represented by an S/s.
-rwSrw-rw- –> Setuid bit set, not executable
-rwsrw-rw- –> Setuid bit set, executable

syntax:

chmod 4*** file

e.g.: chmod 4644 /etc/passwd

setgid works the same way with setuid. The difference is; instead of the root, the group privileges are inherited. setgid is bit represented by an S/s.
-rw-rwSrw- –> Setgid bit set, not executable
-rw-rwsrw- –> Setgid bit set, executable
file should be a member of the group, to access privilege.

syntax:

chmod 2*** file

e.g.: chmod 2755 hexdump

stickybit keep programs in swap even after execution. Files in a directory with the sticky bit set can not be deleted by anyone other than the owner of the file, the owner of the directory, and the root user. Sticky bit is represented by an T/t.
-rw-rw-rwT –> Sticky bit set, not executable
-rw-rw-rwt –> Sticky bit set, executable

syntax:

chmod 1*** file

e.g.: chmod 1755 myfile

File Permissions

Posted: 08/23/2011 in Ubuntu Linux
Tags: , , ,

In Linux, users are able to control file access through the use of permissions.
The three modes of file access are:
read -view the file
write – change the file
execute – run the file

A file is different from a directory when talking about permissions. In a directory, the three mode of access are:
read – view directory’s contents
write – add, delete, rename files
execute – open a files or sub directories in a directory

Files and Directories can be accessed by:
file owner or user (u) – with an entry in /etc/passwd
member of the files’ group (g) – with an entry in /etc/group
anyone else or others (o)

Using ls -l command, all file’s attributes can be examined.

Changing File Permission

Permissions can be specified in absolute form or surgical form.
Absolute form use octal specification.

| u | g | o |
rwx rwx rwx
421 421 421
Here's a summary of numerical permission:
7     full
6     read and write
5     read and execute
4     read only
3     write and execute
2     write only
1     execute only
0     none

syntax:

chmod ### file

e.g
chmod 540 sample.txt

Surgical form use who/how/what specification

Who:
u - user 
g - group
o - other 
a - all (u+g+o)
How: 
+ - Add permission, existing unaffected 
- - Remove permission, existing unaffected 
= - Set permission, existing replaced
What:
r - read
w -write
x -execute

syntax:

chmod WhoHowWhat file

e.g.:
Add execute permission for the file’s owner: chmod u+x file.txt
Remove write permission from group and others: chmod go-w file.txt
Set the file to read only for everyone (kills existing permissions): chmod a=r file.txt