Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Unix :: General :: chmod.txt

Understanding what you see when you type ls




     _|_|_|  _|        _|     _| _|     _|  _|     _|    _|_|_|   _|      _|_|_|
     _|      _|      _|  _|  _| _| _|  _| _| _|  _|  _|  _|   _|  _|      _|
     _|_|    _|      _|_|_|  _|    _|  _|    _|  _|_|_|  _|_|_|   _|      _|_|
     _|      _|      _|  _|  _|    _|  _|    _|  _|  _|  _|   _|  _|      _|
     _|      _|_|_|  _|  _|  _|    _|  _|    _|  _|  _|  _|_|_|   _|_|_|  _|_|_|


                  _|_|_|   _|  _|  _|_|_|  _|_|_|  _|_|_|  _|_|_|
                  _|   _|  _|  _|  _|      _|      _|      _|
                  _|_|_|   _|_|_|  _|_|    _|      _|_|    _|_|_|
                  _|       _|  _|  _|      _|      _|          _|
                  _|       _|  _|  _|_|_|  _|_|_|  _|_|_|  _|_|_|


			     http://www.pheces.org
		"The wise man doesn't give the right answers,
		    he poses the right questions." - Claude Levi-Strauss


öööööööööööööööööööööööööööööööö

Title:      |||| Linux Modes (chmod) ||||

Date:       July 18, 1999
Author:     rootwurm

öööööööööööööööööööööööööööööööö

the linux command prompt provides a whole lot of information right before your eyes.
if you do a long listing of the files (ls -al) you'll see pretty much something like this:

	drwx--x---   4 root     root         1024 Jul 18 18:13 ./
	drwxr-xr-x  21 root     root         1024 Jun 17 23:28 ../
	-rw-r--r--   1 root     root         6543 Jul 18 19:15 .bash_history

taking this apart we get:

d rwx --x ---  4 root  root  1024  Jul 18 18:13  ./
^ ^^^ ^^^ ^^^  ^ ^^^^  ^^^^  ^^^^  ^^^^^^^^^^^^  ^^
|  |   |   |   |  |     |     |         |        |
|  |   |   |   |  |     |     |         |        the filename (or dir name)
|  |   |   |   |  |     |     |         |
|  |   |   |   |  |     |     |         the date the file was created (or modified)
|  |   |   |   |  |     |     |
|  |   |   |   |  |     |     the filesize
|  |   |   |   |  |     |
|  |   |   |   |  |     the group the file (or dir) belongs in)
|  |   |   |   |  |
|  |   |   |   |  the owner of the file (or dir)
|  |   |   |   |
|  |   |   |   the number of the files there are*
|  |   |   |
|  |   |   the permissions EVERYONE has on that file (or dir)
|  |   |
|  |   the permissions the group has
|  |
|  the permissions the owner of the file (or dir) has
|
it's a directory (notice .bash_history has no (d))


* This i'm not really sure on yet.  It looks to me like, it tells how many dirs are in
  the dir.  sounds confusing, but there are actually 4 dirs in ./, and 21 dirs in ../
  beats me, but i've never had to use it.


okay, with that understood, lets take a closer look at the file permissions (drwxr-xr-x)

if the first letter is a _d_, it means the filename is a directory.  if it's a - then its
a normal file.

the next three letters (or dashes) concern the permissons the owner has, the following
three are the permissions the group has, and the final three are the permsissions that
everyone has.

there are four letters used in the file permissions:
	d = directory
        l = link  (kinda like a shortcut...a symbolic link pointing to a file or dir)
	r = read
	w = write
	x = execute (for dirs, it means that person has access to it)

you've seen HOWTO's and INSTALL's and README's and most every Perl script that tells you to
'chmod 777 file'.  Well, so have i, but i've always wondered exactly what i'm doing.

the chmod command is formated like so: chmod 000 file(or dir) and the three numbers represent
| 0 owner | 0 group | 0 everyone |

the chmod numbers correspond as follows:
	1 = --x  (execute (or read access if its a dir)
	2 = -w-  (write)
	3 = -wx  (execute (access, for dirs) write)
	4 = r--  (read only)
	5 = r-x  (read execute or access for dirs :-)
	6 = rw-  (read-write)
	7 = rwx  (read-write-execute (or access)

so if you 'chmod 777 filename.txt', then the permissions become: -rwxrwxrwx
if you 'chmod 400 filename.txt', the permissions become: -r--------
if you 'chmod 634 filename.txt', the permissions become: -rw--wxr--
and so on.

hope that helped you in understanding the prompt, permissions, and chmod.



later,

rootwurm

(((((((((((((((((((((((((((((((((((((((((((((#yep)))))))))))))))))))))))))))))))))))))))))))))


TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2014 AOH