Previous Page | Next Page

  1. Agustin's Linux Manual
  2. System Administration
  3. About the Author
  4. Contents
  5. Administration
  6. Terminals
  7. Command Basics
  8. Root Directory
  9. Executing Commands
  10. File specs
  11. File Permission
  12. How permissions are assigned
  13. Change ownership chown
  14. Running multiple commands
  15. Killing Processes
  16. Bash configuration files
  17. VI Editor
  18. Creating path environment
  19. Midnight Commander
  20. Linuxconf Utility
  21. Networking
  22. Domain Name Service DNS
  23. Router and Gateway
  24. Adding Users
  25. User Accounts
  26. Managing Groups
  27. Mounting File System
  28. NFS Mounts
  29. Disk Quotas
  30. Run levels
  31. Linuxconf Control
  32. Mandrake Control Center
  33. Creating a Boot Disk
  34. Switching Boot Mode
  35. Hardware Configurations
  36. Printer Configuration
  37. Installing Printers
  38. Samba Printer
  39. Managing services
  40. Managing Users
  41. Program Scheduler
  42. Software Management
  43. Installing CUPS

How permissions are assigned?

The basic format of chmod is: chmod xyz file
The xyz represent value that goes from 0-7; each number represents permissions in a group.

For instance:

xwould be for the owner of the file
ywould be for the group that owns the file(group the user belongs to)
zwould be for everybody
filename of the file being modified

Refer to the following table for a better understanding

0None = can not read, write or execute
1Can execute, but can not read or write
2Write only, can not read or execute
3Can write, can execute
4Read only, can not write to or execute
5Read only, executable, can not write to
6Writeable, readable file, but not executable
7Readable, writeable and executable file
Table 3.3

There are several ways to give permission to a file as you could see on the last two tables. You could basically use any part of the table to assign these permissions.

I will use the numerical part of the first table to assign permission to an html file that can be viewed over the Internet.

[root@server2 collections]#chmod 644 internal.html

How I determined that? I simply added 400+200+40+4 = 644 from table 3.2

  • Read by owner
  • Write by owner
  • Read by group
  • Read by others

If I do an ls –l that would look like this:

[root@server2 collections]#ls –l
-rw-r--r--  1 root   root  6    Aug    17   09:09   afile
-rw-r--r--  1 root   root  19  Aug    18   12:47 internal.html			
[root@server2 collections]#

What would happen if I make that writeable by others (I would be a dumb administrator), but for demonstration purposes lest make that file writeable by others.

[root@server2 collections]# chmod 646 internal.html
Now I do an: ls –l

[root@server2 collections]#ls –l
-rw-r--r--  1 root	  root	6    Aug    17   09:09   afile
-rw-r--rw-   1 root	 root	19   Aug 18 12:47 internal.html

[root@server2 collections]#

Now internal.html is world writeable…be careful how you assign permissions. Normally, don't leave a file as 777 (that is full access to the file), anyone can replace or delete it.