top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is "chmod" command? What do you understand by this line “r-- -w- --x?

+1 vote
755 views
What is "chmod" command? What do you understand by this line “r-- -w- --x?
posted Dec 9, 2015 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

chmod changes the permissions of each given file according to mode, where mode describes the permissions to modify. Mode can be specified with octal numbers or with letters. Using letters is easier to understand for most people.

$chmod

mode
The octal (0-7) value is calculated by adding up the values for each digit
User (rwx) = 4+2+1 = 7
Group(rx) = 4+1 = 5
World (x) = 4+1 = 1

chmode mode = 0751

Specific Mode
In the above example 0751 first digit 0 is the specific mode which can have following values

Execute only if the file is a directory 
(or already has execute permission for some user)                       X
Set user or group ID on execution                                       s
Save program text on swap device                                        t   
The permissions that the User who owns the file currently has for it    u
The permissions that other users in the file's Group have for it        g
Permissions that Other users not in the file's group have for it        o

Alternate Way of Specifying the mode

Deny execute permission to everyone: 
$ chmod a-x file

Allow read permission to everyone:
$ chmod a+r file

Make a file readable and writable by the group and others: 
$ chmod go+rw file

Make a shell script executable by the user/owner 
$ chmod u+x myscript.sh

Allow everyone to read, write, and execute the file and turn on the set group-ID: 
$ chmod =rwx,g+s file 
answer Dec 9, 2015 by Salil Agrawal
0 votes

chmod command is used to change permission of a file or directory in UNIX. The line you see shows the permission for three different set of people : user, group and others. User is the currently logged in user, while group is for all other member which are part of certain group and others means anyone other than user and group member. Each group has three permissions rwx stands for read, write and execute and they are written as user_group_others. So in above line, user has only read permission, group members has write permissions and other people has only execute permission. If it is a directory then you need execute permission to go inside that directory.

answer Dec 9, 2015 by Shivaranjini
...