go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Comments & Suggestions » Linux/Unix Command Examples
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Linux/Unix Command Examples
EricJ
member
offline   
 
posts: 50
joined: 02/22/2007
from: CA
  posted on: 05/22/2009 11:38:22 AM    Edit  |   Quote  |   Report 
Linux/Unix Command Examples
chmod Command

We use the chmod command to change the access mode of a file. This command comes in many flavors, but we'll be talking primarily about one of them.
chmod who=permissions filename

This gives “who” the specified permissions for a given filename.

Who
The “who” is a list of letters that specifies whom you’re going to be giving permissions to. These may be specified in any order.

Letter Meaning 
  u    The user who owns the file (this means “you.”)  
  g    The group the file belongs to.  
  o    The other users  
  a    all of the above (an abbreviation for ugo)  


Permissions
Of course, the permissions are the same letters that you see in the directory listing:
  r    Permission to read the file.  
  w    Permission to write (or delete) the file.  
  x    Permission to execute the file, or, in the case of a directory, search it.  



chmod Examples

Let’s change some of the permissions as we discussed a couple of pages ago. Here’s the way our files are now:

-rwxr-xr-x  joe  acctg  archive.sh 
-rw-rw-r--  joe  acctg  orgchart.gif
-rw-rw-r--  joe  acctg  personnel.txt
-rw-r--r--  joe  acctg  publicity.html
drwxrwxr-x  joe  acctg  sales
-rw-r-----  joe  acctg  topsecret.inf
-rwxr-xr-x  joe  acctg  wordmatic


First, let’s prevent outsiders from executing archive.sh
 Before: -rwxr-xr-x  archive.sh 
Command: chmod o=r archive.sh 
  After: -rwxr-xr--  archive.sh  


Take away all permissions for the group for topsecret.inf We do this by leaving the permissions part of the command empty.
 Before: -rw-r-----  topsecret.inf  
Command: chmod g= topsecret.inf 
  After: -rw-------  topsecret.inf  


Open up publicity.html for reading and writing by anyone.
 Before: -rw-r--r--  publicity.html  
Command: chmod og=rw publicity.html 
  After: -rw-rw-rw-  publicity.html  


 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.