You are not logged in. Login Now
 0-15          
 
Author Message
tlk
chmoding files Mark Unseen   Feb 24 14:50 UTC 2006

Hey there people,

Sorry, maybe it's noobish but that could be right because im new here. 
Could anyone tell me how to chmod files? I am following this tutorial: 
http://www.happyhacker.org/gtmhh/shella3.shtml to learn and learn. So, 
could anyone help me? Thanks
15 responses total.
keesan
response 1 of 15: Mark Unseen   Feb 24 16:02 UTC 2006

chmod +x filename  - makes a file executable by anyone.  You can probably find
lots of information about chmod on the web with a search engine, in simpler
language than the manual (man) pages.  (or does +x make is executable only
by root?  I am always root).
nharmon
response 2 of 15: Mark Unseen   Feb 24 16:38 UTC 2006

chmod g+x  gives the group execute permission.
chmod o+r  gives the owner read permission.

chmod 755  gives the owner read/write/execute permission, while only
           giving read and execute permission to the group and 
           everybody else.

Chmodding is something you gotta read about to do it. Can't really be 
shown.
cross
response 3 of 15: Mark Unseen   Feb 24 17:12 UTC 2006

This would be better in the Unix conference, but....

chmod +x makes a file executable by anyway.

Unix file permissions work like this: There are three separate permission
bits: Read, Write, and Execute.  These are replicated for three separate
classes of users: The user who owns the file, the *group* that `owns' the
file, and everybody else.

The chmod bit changese these permission bits.  (There are a few others,
but we needn't go into them right now).  You may either specify permissions
symbolically, or in octal.  In the latter, you use numbers to specify what
the permissions should be.  You usually give a three digit number that
specifies read, write, and execute for user, group, and world all at once.
04 is read, 02 is write, and 01 is execute.  You add these together to
get what permissions you want.  So, 04 + 02 = 06 is read and write.
04 + 02 + 01 = 07 is read, write, and execute.  04 + 01 = 05 is read and
execute.  You then give three digits, so 755 is read, write, and execute
for user, and read and execute for both group and other.  To apply these
to a file, you would type, e.g., `chmod 755 file'.

In the symbolic system, permission bits are represented by letters,
`r' for read, `w' for write, and `x' for execute.  You use `+' or
`-' to set.  E.g., `chmod +x file' adds execute permissions for
everybody while, `chmod -x file' removes them.  Similarly for
`chmod +r file', `chmod -r file', `chmod +w file' and `chmod -w file'.
You can combine these in an obvious way to set multiple bits at once.
E.g, `chmod +rx file' to make the file readable and executable at once.
Note that in the octal system, all permissions are set at once.  In
the symbolic system, you modify permissions.  So, if a file is writable,
doing `chmod +x file' doesn't make it *unwritable* whereas,
`chmod 111 file' does.  Octal sets permissions absolutely, symbolic
modifies them.

You can also change permissions for group or owner individually in
the symbolic system.  For instance, `chmod u+w file' makes the file
writable by the user, but doesn't affect anything else.  `chmod go-w file'
makes it *unwritable* by group and other (note that `o' stands for `other'
not `owner,' and similarly, `u' is for `user').

There's also the `=' system of doing things, which sets bits absolutely in
the symbolic system, but this should be enough to get you started.
keesan
response 4 of 15: Mark Unseen   Feb 24 18:22 UTC 2006

Is there a linux equivalent of attr +r - to make a file unerasable by
accident?
kingjon
response 5 of 15: Mark Unseen   Feb 24 18:34 UTC 2006

I'm not on my Linux system now, but I believe it's chattr +i (for "immutable").
(Finding some such files that you didn't put there is a nearly-sure sign that
you've been hacked.)

mcnally
response 6 of 15: Mark Unseen   Feb 24 19:29 UTC 2006

 re #4:
 >  Is there a linux equivalent of attr +r - to make a file unerasable
 >  by accident?

 Deleting a file in Unix is actually an operation on the containing 
 directory and not on the file itself, so there's no way I know of
 (using normal Unix file permissions) to do that on a per-file basis.

 If you have trouble with deleting stuff accidentally you can prevent
 some of it by aliasing your rm, mv, and cp commands to include the -i
 flag.
keesan
response 7 of 15: Mark Unseen   Feb 24 20:33 UTC 2006

Can you make an entire directory non-erasable?
kingjon
response 8 of 15: Mark Unseen   Feb 24 20:36 UTC 2006

A directory (in *nix, anyway) is just a special kind of file, so you can use
the same procedure you would on any other kind of file.

cross
response 9 of 15: Mark Unseen   Feb 25 04:53 UTC 2006

Check the man page for the `chflags' command.
naftee
response 10 of 15: Mark Unseen   Feb 25 06:10 UTC 2006

CHFAGS<>  AH
remmers
response 11 of 15: Mark Unseen   Feb 25 13:38 UTC 2006

Re #9:  Ah, thanks.  I seemed to recall that OpenBSD had some sort of
extended file attribute support but didn't remember how to access it. 
In particular, "chflags uchg FILE" makes FILE "immutable", which seems
to mean undeletable and uneditable (even if the file and its directory
have write permission set).  "ls -lo" lists the extended attributes.
spooked
response 12 of 15: Mark Unseen   Feb 25 22:30 UTC 2006

To the best of my knowledge and quick googling:

The  chflags  is available on BSD (i.e. main ones being FreeBSD, NetBSD, 
and OpenBSD) systems and Mac OS X (i.e. Darwin) kernels.

Similar functionality on Linux is available via the  chattr  command, 
assuming your filesystems are ext2 or ext3.

Windows filesystems do NOT, surprisingly, support tagging files as 
immutable via their ACL mechanism.  Nor do Solaris/Trusted Solaris 
(being phased out)/Solaris 10 with Solaris Trusted Extensions via RBAC.


naftee
response 13 of 15: Mark Unseen   Feb 26 06:25 UTC 2006

unlucky
triludaa
response 14 of 15: Mark Unseen   Feb 26 21:17 UTC 2006

totally wrong place for this item, however, a totally good item. i'd say best
item besides idle killer coop has ever offered.
jesuit
response 15 of 15: Mark Unseen   May 17 02:16 UTC 2006

TROGG IS DAVID BLAINE
 0-15          
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss