Commands (CHMOD)
sabato 30 gennaio 2010
Can change the permission set for files or directories using the chmod command. Either the owner of the file or directory, or the root user can use the chmod command to change permissions. The chmod command can change permissions specified in either symbolic mode or octal mode. The symbolic mode uses combinations of letters and symbols to add or remove permissions for each type of user. The octal mode uses octal numbers to represent each permission.

chmod symbolic_mode filename
The syntax for the chmod command in the symbolic mode is: chmod symbolic_mode filename The symbolic_mode option consists of three parts: the user category (owner, group, or other) affected, the function performed, and the permissions affected. For example, if the option is g+x, the executable permission is added for the group.


ex:
$ ls -l test
-rw-r--r-- 1 m171c0 other 0 Jan 30 09:56 test
$ chmod o-r test
$ ls -l test
-rw-r----- 1 m171c0 other 0 Jan 30 09:56 test


To remove the read permission for the group:

$ chmod g-r test
$ ls -l test
-rw------- 1 m171c0 other 0 Jan 30 09:56 test


Exampels Using the symbolic mode.

To adde an execute permissio for the owner ande permission for teh group and other:

$ ls -l test
-rwx------ 1 m171c0 other 0 Jan 30 09:56 test

to assing read adn write permissions for owner,group,and other:

$ chmod a=rw test
$ ls -l test
-rw-rw-rw- 1 m171c0 other 0 Jan 30 09:56 test


The chmod command syntax in octal_mode filename
The chmod command syntax in octal mode is: chmod octal_mode filename The octal_mode option consists of three octal numbers, from 0–7, which represent a combination of permissions for the file or directory. The table on the screen shows the octal values for each individual permission.

Octal Value

Permission

Sets binary

7

rwx

111 (4+2+1)

6

rw-

110 (4+2+0)

5

r-x

101 (4+0+1)

4

r--

100 (4+0+0)

3

-wx

011 (0+2+1)

2

-w-

010 (0+2+0)

1

--x

001 (0+0+1)

0

---

000 (0+0+0)


Octal Value

Permission

644

rw-r--r--

755

rwxr-xr-x

775

rwxrwxr-x

777

rwxrwxrwx





Examples using octal mode
To set perimssions so that owner grupo ande other haver read and exectue acess only:

$ chmod 555 test
$ ls -l test
-r-xr-xr-x 1 m171c0 other 0 Jan 30 09:56 test


to change owner and group permissions to include wirte access
$ chmod 775 test
$ ls -l test
-rwxrwxr-x 1 m171c0 other 0 Jan 30 09:56 test



to change the group permission read an execute only:

$ ls -l test
-rwxr-xr-x 1 m171c0 other 0 Jan 30 09:56 test

With 't' set, only the owner of a file can delete it.

chmod +t directorySet the sticky bit on a directory
chmod -t directory Remove the sticky bit from a directory


$ chmod +t somedir/


$ ls -l

drwxr-xr-t 2 root root 2 Feb 1 01:30 somedir




postato da Eduardo Kislanski @ 00:51  

0 Commenti:

Posta un commento

<< Home page

MARVEL and SPIDER-MAN: TM & © 2007 Marvel Characters, Inc. Motion Picture © 2007 Columbia Pictures Industries, Inc. All Rights Reserved. © 2007 Sony Pictures Digital Inc. All rights reserved.