Click to See Complete Forum and Search --> : wanting to understand chmod


airedale
02-22-2001, 05:47 PM
Ok, I have come to the point where chmod should be my best friend in linux, but it has become a foe! I know how to turn files into executables by doing chmod 700 filename

What I don't know, is what I should set a file to, so I can then download it off of my ftp. What I am doing right now, is downloading files in XIRC and having them save into my ftp directory. The only problem is that XIRC does something with CHMOD and I can not download the files!

Does anyone know what I need to do so I can download my files!? :confused:

Jeepsta
02-22-2001, 06:08 PM
not sure exactly what you want but chmod 444 will give everyone "read" permission and no one "write" or "execute" permission. Let me know EXACTLY what you want and I can help you.

EDIT: You have to remember that there are three different levels: USER, GROUP, & OTHER. chmod 700 gives rwx permission only to USER.

Zach

[ 22 February 2001: Message edited by: Jeepsta ]

bsh152s
02-22-2001, 08:18 PM
Here's a breakdown of chmod:

USER GROUP OTHER
R W X R W X R W X
1 1 1 1 0 0 0 0 0
\ / \ / \ /
7 4 0

1 means permission is granted, 0 means it isn't. The 740 is just the binary representation converted to octal.

If you don't give "others" permission, they probably aren't going to be able to access the files via ftp.

njcajun
02-22-2001, 10:56 PM
This may be a bit clearer... always helps to see something in more than one way...

RWXRWXRWX =
421421421

Just look at the first set of RWX permissions. The 'R' is 'worth' 4. I always call it 'the 4 bit'. The 'W' is worth 2, and 'E' is worth one.

If you don't already know, the first set of 'RWX' permissions applies to the creator of the file or directory. The second is for the people in the group that own it, and the last set is for anyone else who comes along.
So if I want to give the creator all rights, I enable the 'R' or '4' bit, the 'W' or '2' bit, and the 'X' or '1' bit. Add together 4+2+1, and you get '7'. If I don't want to give anyone else any rights, then here's what I have:

RWX------ =
421000000 =
7 0 0
\ /
chmod 700 <filename>

Here's one more example to make sure you got it:

I wanna give the creator all rights, and everyone else just gets read and execute rights - they can't write!

RWXR-XR-X =
4214-14-1 =

7 5 5 =
\ /
chmod 755 <filename>

See? Just start reading the permissions as '421421421' and you'll be changing permissions on the fly in no time!

Good Luck. :cool:

[ 22 February 2001: Message edited by: njcajun ]

[ 22 February 2001: Message edited by: njcajun ]

[ 22 February 2001: Message edited by: njcajun ]

[ 22 February 2001: Message edited by: njcajun ]

njcajun
02-22-2001, 11:04 PM
WTF is up with this BBS software? It gets rid of spaces! Sorry about all the edits - in the end I couldn't get it to look good anyway :confused:

error27
02-22-2001, 11:52 PM
this is a test of the UBB spa ci n g.
---------------------------------------------

after I pressed the "code" button.



the 00 in 700 means that no one not logged in as you can read/copy/write to/execute the files.

anyways instead of using the numbers it's easier to just say chmod u+r programname to make stuff readable for the user. etc.

pbharris
02-23-2001, 12:47 AM
chmod USER USERS_GROUP EVERYONE filename

mods:
1 executable
2 write
3 write+execute
4 read
5 read+execute
6 write+read
7 write+read+execute

so to give me read and write permision on a file called poo ,my group read access and everyone else no access I would type
chmod 640 poo

aph3x
02-23-2001, 04:58 AM
okay, im drunk and trying to explain file permissions, so please excuse the typos and unclear explanation... :p

Set UID permissions = s = any combo of the below preceeding any of the combos below
Read permissions = r = 4
Write permissions = w = 2
Execute permissions = x = 1

in my personal opinion, the easiest way to chmod a file to to use the numbers method... it's kinda confusing at first, but much easier once you get the idea of it (again, in my opinion).

first, understand what an ls -l represnts:

you have a file called foo

-r--r--r-- 1 root users foo

this means the owner (root in this case), the group (users in this case), and everyone else has read permissions on the file foo. the first "-" tells you whether it is a file (-), directory (d), etc.

as you read on, keep this in mind: the first number is reserved for suid (another topic, another post), the second number is reserved for the owner permissions of the file, the third number is reserved for the group members' permissions of the file, and the fourth number is reserved for everyone else's permissions of the file (for those who are not the owner, not in the group, or both)

so,

-r--r----- 1 root users foo

means the owner (root in this case), and the group (users in this case) have read permissions, but everyone else does not... the "root" signfies who the owner is, the "users" signfies the name of the group...

now, as mentioned above, r==4, w==2, x==1...

so to make foo executable for the owner of foo, (root in this case), you would type the following:

chmod 0100 foo

if you want foo to be executable and writeable for user root, you would add the corresponding numbers together:

1 (for executable) + 2 (for writeable) = 3

chmod 0300 foo

now, if foo needs to be readable, writeable, and executable for user root, do the math:

1 (for executable) + 2 (for writeable) + 4 (for readable) = 7

chmod 0700 foo

okay, "what if its readable and writable, but not executable for user root?" you say...

2 (for writeable) + 4 (for readable) = 6

chmod 0600 foo

now, say you want read, write, and execute permissions for user root, but only read permission for those users belonging to the "users" group:

chmod 0740 foo

and to further elaborate, if you want read, write, and execute permissions for user root, read and write permissions for the "users" group, and only read permissions for everyone else:

chmod 0764 foo

follow me? i hope so, cause im gonna go pass out now... :p

hope that helps! :D

[ 23 February 2001: Message edited by: aph3x ]