Fedora Linux Support Community & Resources Center
  #1  
Old 29th May 2012, 06:05 AM
Socrates440 Offline
Registered User
 
Join Date: May 2012
Location: Aspen
Posts: 48
linuxfirefox
I don't understand this command

I am reading a textbook about how to use linux and I am in the chapter that introduces shell scripting. Here is the link if you would like to see the book/chapter that I am referring to (http://rute.2038bug.com/node10.html.gz).

Anyways, the book told me to create a file with the name <filename>.sh which I did. Next it asked me to use the command chmod 0755 myfile.sh. I have googled chmod and I have searched around and I don't understand what this command does. It is my understanding that Chmod changes permissions? Is that right? What will this command do?

Thanks!
Reply With Quote
  #2  
Old 29th May 2012, 06:30 AM
jpollard Offline
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,865
linuxfirefox
Re: I don't understand this command

It changes the file permissions.

When a file is created by default, it will get "-rw-rw-r--" (0334). This means the file is not executable... and only readable by world.

Group and owner can read and write (permitting users in the group to modify the file).

"chmod 0755 ..." changes the permissions to "rwxr-xr-x" (owner can read/write/execute, group can read/execute, and world can read/execute). The change of group write means that other members of the group cannot modify an executable, and introduce a security issue by getting something they want run to be run by you.
Reply With Quote
  #3  
Old 29th May 2012, 06:53 AM
Socrates440 Offline
Registered User
 
Join Date: May 2012
Location: Aspen
Posts: 48
linuxfirefox
Re: I don't understand this command

Thanks for the info!

What group are you refering to? Also, where are you getting the permission equivalents for those numbers? Is there a table that I can look up?
Reply With Quote
  #4  
Old 29th May 2012, 07:15 AM
jpollard Offline
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,865
linuxfirefox
Re: I don't understand this command

The group is whatever group is associated with the file. The default in Fedora is that the default group of the user is also assigned to the user... which makes both group and user equivalent. Some systems (or those modified by the admin) may be given a default group that has multiple users. The group can be shown by "ls -l", which will show the symbolic representation of the owner/group and permissions (as well as the size of the file).

You can find some tutorial information at http://www.tutorialspoint.com/unix/u...permission.htm
on the symbolic/numeric representations.

The information is actually in the chmod man page, but not in an easily read format. It used to be there in a table, but I think that was back with the BSD man pages.. and has been rewritten since...

For some information on all the access bits (and there are more) you can look at the "man 2 stat" (the man page for the stat system call) which goes into detail on each bit, though it doesn't go into the symbolic representation as used by the ls command.
Reply With Quote
  #5  
Old 29th May 2012, 07:51 AM
Socrates440 Offline
Registered User
 
Join Date: May 2012
Location: Aspen
Posts: 48
linuxfirefox
Re: I don't understand this command

I see where the permissions for user, group, and world (Who is world by the way? Doesn't everybody who is logged on have to be logged on as some form of user?). They come from the 755 right? 7=all permissions, 5 = rx 5=rx. What is the zero for though, and why are there four digits instead of 3?

Also, in the tutorial page you sent me, it gives the example:
amrood]$chmod o+wx testfile
[amrood]$ls -l testfile
-rwxrwxrwx 1 amrood users 1024 Nov 2 00:10 testfile


Who is o?
Reply With Quote
  #6  
Old 29th May 2012, 12:17 PM
george_toolan Offline
Registered User
 
Join Date: Dec 2006
Posts: 2,078
linuxfirefox
Re: I don't understand this command

Those numbers are octal. Wikipedia has a nice explanation including the missing table. See http://en.wikipedia.org/wiki/Filesystem_permissions

o is short of "others" read other users who a logged into the system, but are not the owner (u like "user") of the file and not a member of the "group" (g). See

Code:
man chmod
Reply With Quote
  #7  
Old 29th May 2012, 02:44 PM
jpollard Offline
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,865
linuxfirefox
Re: I don't understand this command

BTW, having an executable file rwxrwxrwx is a way to have a virus - the executable (script or binary) can be replaced by anyone... So you no longer have any control over what the program/script does.
Reply With Quote
Reply

Tags
command, understand

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
i don't quite understand this .. jasonwatkins Using Fedora 3 16th July 2007 03:15 AM
I need to understand what I've done. melm2 Using Fedora 5 15th February 2007 09:44 PM
Don't understand sudo command.... rappermas Using Fedora 15 21st December 2005 02:08 AM
Trying to understand LVM rtcary Using Fedora 7 9th May 2005 07:50 AM


Current GMT-time: 14:41 (Friday, 24-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Kostrzyn nad Odra - Toba Tek Singh Photos on Instagram - Tufanganj Instagram Photos