LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Interpreting chmod command (https://www.linuxquestions.org/questions/linux-newbie-8/interpreting-chmod-command-4175552776/)

green ice 09-06-2015 03:46 PM

Interpreting chmod command
 
2 Attachment(s)
we have 3 types of permissions r w x
and 3 entities we can give these permissions to u, g, o

[username as root] ~ $ ls -l .ICEauthority
-rw------- 1 [username] [username] 2590 Sep 7 01:43 .ICEauthority

in other words, I, as root, have rw on .ICEauthority

"-rw-rw-r--. 1 bob bob 0 Mar 16 19:04 file-1"
This line means u has read/write
g has read/write
but o has only read.

IN this command:
chmod uo+x, g-w
user and others are being given execution permission
the group to which user and group belong is being deprived of write permission


In the line
[test3@centOS -] $ chmod uo+x, g-w test1

This means test3 as root is changing permissions for user test1
test3 gives test1 and others execution permission
but for the group test1 belongs to test3 removes write permission
Is this the correct interpretation of this command, please?

in the screenshot is the line
drwxr-xr-x
this is brought up by ls -l, so is not a command but a report.
what does the d in front of rwxr mean?
what does this statement mean, please?

hortageno 09-06-2015 04:06 PM

Interpreting chmod command
 
d like directory

yancek 09-06-2015 05:41 PM

Quote:

This means test3 as root is changing permissions for user test1
The command changes permissions for the file test1 which apparently is in the /home/test3 directory and you arent' logged in as root as the $ sign shows a normal user. No sudo prefix to the commands either.

The chmod and chown commands change permissions for files and/or directories. In the case of directories, you can do it recursively to include all files in a directory but that isn't usually a good idea unless it is some user created directory.

You asked "what does this statement mean, please?" What statement are you referring to?

tomwest 09-07-2015 03:27 AM

Quote:

in the screenshot is the line
drwxr-xr-x
this is brought up by ls -l, so is not a command but a report.
what does the d in front of rwxr mean?
what does this statement mean, please?
As mentioned in #2, the d at the start of the line means that that line is referring to a directory. In your pic, the dash, - , at the start of a line refers to a file, and the letter l at the start of the line means that entry is a link to another file.

Quote:

The chmod and chown commands change permissions for files and/or directories.
What's missing from this sentence is that chown changes ownership of files, whereas chmod changes the permissions for files and directories (which are themselves just a special sort of file).

When you use chmod and give a file +x so that it can be executed, that is different to when you +x for directories. Directories cannot be executed as if they are executables since they are just folders that hold other files. So if you give +x to a directory, it means that you are granting access to that directory for the user, group, other or combinations of those. In the pic, for example, there is a Music directory which has +x for others. This means that others (anyone) can access that directory, and not that they can execute the directory, because that makes no sense. So, x means 2 different things, one for files and one for directories.

chown changes ownership of files and directories, not permissions. In the pic files are owned by root and test1. chown can change these owners to other owners on the system.

green ice 09-08-2015 03:50 PM

Quote:

Originally Posted by yancek (Post 5416789)
You asked "what does this statement mean, please?" What statement are you referring to?

Referring to line 6 in the purple screenshot:
drwxr-xr-x

So d in front means directory
someone already has this set of permissions I assume over this directory.
the user has "drwx-..."
the group has execute and read "...xr..."
others have execute "...x"

Is that correct reading of the line?
I think I am getting this wrong because in the second series x comes before r which does make sense to me yet.

also, in the first set, drwxr..., why is there an r at the end (unless the final r relates to the x after the hyphen)?

In other words x-r means a particular action: "drwxr-x..."

green ice 09-08-2015 03:57 PM

Quote:

Originally Posted by yancek (Post 5416789)
The command changes permissions for the file test1 which apparently is in the /home/test3 directory ....

Referring to the white screenshot, which comes from an online course offered by EDX/Linux Foundation:

The user test3@CentOS inputs ls -l to find out about file test1
The answer is, going I think by what you imply, that user test2@CentOS has rw,

the group he belongs to has rw

others have r

then test3@CentOS wants to change permissions so he types
chmod uo+x (meaning he wants himself and other to have execute permission over file test1)?

If the user test3@CentOS is not root then the answer will be permission denied unless he has special permissions given him by root. Apparently he has because he types ls -l again and permission for file test1 have changed:

-rwxr--r-x

now user has rwx (I don't know what the final r means)
group has r
other has x

Is this the correct reading?

suicidaleggroll 09-08-2015 04:07 PM

Quote:

Originally Posted by green ice (Post 5417648)
Referring to line 6 in the purpose screenshot:
drwxr-xr-x

So d in front means directory
someone already has this set of permissions I assume over this directory.
the user has "drwx-..."
the group has execute and read "...xr..."
others have execute "...x"

Is that correct reading of the line?
I think I am getting this wrong because in the second series x comes before r which does make sense to me yet.

You're splitting on the wrong columns

drwxr-xr-x
d means directory
rwx means the user "u" has read, write, execute permissions
r-x means the group "g" has read and execute permissions
r-x means others "o" have read and execute permissions.

Quote:

Originally Posted by green ice (Post 5417648)
also, in the first set, drwxr..., why is there an r at the end (unless the final r relates to the x after the hyphen)?

There isn't an r at the end, that r is the start of the group permissions.

There are 10 columns. The first one tells you if it's a directory, file or link. The next three are the user's permissions, the next three are the group permissions, the last three are the "other" permissions.

suicidaleggroll 09-08-2015 04:08 PM

Quote:

Originally Posted by green ice (Post 5417649)
if permissions for file test1 are being changed, who are they being changed for?

for user, test3@CentOS?

It doesn't matter who is running the command. What matters is the file's user and group. Those are who the permissions are being changed for.

When you run "chmod g+w file", you're allowing any members of the same group as the file write permission to it. It makes no difference who you are when you run that command, except of course that you will need permission to change the file's permissions, otherwise you'll get a permission denied error.

hortageno 09-08-2015 04:10 PM

Quote:

Originally Posted by green ice (Post 5417648)
Referring to line 6 in the purpose screenshot:
drwxr-xr-x

So d in front means directory
someone already has this set of permissions I assume over this directory.
the user has "drwx-..."
the group has execute and read "...xr..."
others have execute "...x"

Is that correct reading of the line?
I think I am getting this wrong because in the second series x comes before r which does make sense to me yet.
also, in the first set, drwxr..., why is there an r at the end (unless the final r relates to the x after the hyphen)?

In other words x-r means a particular action: "drwxr-x..."

No, there are three groups of permissions with 3 characters each. Each of these groups has one set of rwx (read, write, execute) in this order. If one character is replaced by a minus, then it means "not". This link probably explains it better than I do ;)

https://www.linux.com/learn/tutorial...le-permissions

Habitual 09-08-2015 06:29 PM

Quote:

Originally Posted by green ice (Post 5416748)
we have 3 types of permissions r w x
and 3 entities we can give these permissions to u, g, o

[username as root] ~ $ ls -l .ICEauthority
-rw------- 1 [username] [username] 2590 Sep 7 01:43 .ICEauthority

in other words, I, as root, have rw on .ICEauthority

Not correct.
As root, those permissions do not apply to you.
user.group has those permissions/restrictions, not root.

Habitual 09-08-2015 06:33 PM

http://linuxsurvival.com/wp/?page_id=11&id=25

green ice 09-15-2015 06:39 PM

[QUOTE=hortageno;5417657]No, there are three groups of permissions with 3 characters each. Each of these groups has one set of rwx (read, write, execute) in this order. If one character is replaced by a minus, then it means "not". This link probably explains it better than I do ;)

What would these 2 phrases mean
g+x
g-x

?

yancek 09-15-2015 07:39 PM

Quote:

What would these 2 phrases mean
g+x
g-x
The commands above using chmod, the first adds execute permissions for the group, the second removes execute permissions for the group.


All times are GMT -5. The time now is 09:05 AM.