LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-06-2015, 04:46 PM   #1
green ice
Member
 
Registered: Jun 2015
Posts: 152

Rep: Reputation: Disabled
Interpreting chmod command


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?
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2015-09-07 03:28:34.jpg
Views:	30
Size:	186.8 KB
ID:	19514   Click image for larger version

Name:	Screenshot from 2015-09-07 03:43:27.jpg
Views:	31
Size:	123.8 KB
ID:	19515  
 
Old 09-06-2015, 05:06 PM   #2
hortageno
Member
 
Registered: Aug 2015
Distribution: Ubuntu 16.04 LTS
Posts: 234

Rep: Reputation: 65
Interpreting chmod command

d like directory
 
1 members found this post helpful.
Old 09-06-2015, 06:41 PM   #3
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 7,330

Rep: Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404
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?
 
1 members found this post helpful.
Old 09-07-2015, 04:27 AM   #4
tomwest
Member
 
Registered: Aug 2013
Posts: 58

Rep: Reputation: Disabled
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.

Last edited by tomwest; 09-07-2015 at 04:31 AM.
 
1 members found this post helpful.
Old 09-08-2015, 04:50 PM   #5
green ice
Member
 
Registered: Jun 2015
Posts: 152

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
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..."

Last edited by green ice; 09-15-2015 at 07:15 PM.
 
Old 09-08-2015, 04:57 PM   #6
green ice
Member
 
Registered: Jun 2015
Posts: 152

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
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?

Last edited by green ice; 09-08-2015 at 05:11 PM.
 
Old 09-08-2015, 05:07 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
Quote:
Originally Posted by green ice View Post
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 View Post
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.

Last edited by suicidaleggroll; 09-08-2015 at 05:09 PM.
 
1 members found this post helpful.
Old 09-08-2015, 05:08 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,552

Rep: Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112Reputation: 2112
Quote:
Originally Posted by green ice View Post
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.

Last edited by suicidaleggroll; 09-08-2015 at 05:11 PM.
 
1 members found this post helpful.
Old 09-08-2015, 05:10 PM   #9
hortageno
Member
 
Registered: Aug 2015
Distribution: Ubuntu 16.04 LTS
Posts: 234

Rep: Reputation: 65
Quote:
Originally Posted by green ice View Post
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
 
1 members found this post helpful.
Old 09-08-2015, 07:29 PM   #10
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: OSX Sierra
Posts: 8,573
Blog Entries: 14

Rep: Reputation: Disabled
Quote:
Originally Posted by green ice View Post
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.
 
1 members found this post helpful.
Old 09-08-2015, 07:33 PM   #11
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: OSX Sierra
Posts: 8,573
Blog Entries: 14

Rep: Reputation: Disabled
http://linuxsurvival.com/wp/?page_id=11&id=25
 
1 members found this post helpful.
Old 09-15-2015, 07:39 PM   #12
green ice
Member
 
Registered: Jun 2015
Posts: 152

Original Poster
Rep: Reputation: Disabled
[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

?
 
Old 09-15-2015, 08:39 PM   #13
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 7,330

Rep: Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404Reputation: 1404
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in interpreting command output Upendra Pratap Singh Linux - Newbie 6 08-02-2015 04:47 AM
Interpreting cpu line of top command fshim Linux - Newbie 1 12-22-2008 01:40 PM
Interpreting output of df -h command kushalkoolwal Debian 1 06-30-2007 08:29 AM
Interpreting the output of 'lspci' command. drminix Linux - Hardware 2 06-14-2005 04:20 AM
Interpreting Bash command firstchar=${1:0:1} Linh Programming 2 06-02-2004 05:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration