7.9 Miscellaneous Commands

   

Here are few other commands that are not used directly to modify file permissions but are related to this process.

The newgrp Command

If a user is a member of more than one group, all new files created by that user belong to the current group . If the user wants the new files to belong to another group, the newgrp command changes the current group membership temporarily. In the following example, user boota belongs to group users (default group) and class . See how the new files created by the touch command are affected by changing the group membership.

 $  touch file1  $  ll file1  -rw-rw-rw-   1 boota   users     0 Sep  8 18:06 file1 $  newgrp class  $  touch file2  $  ll file2  -rw-rw-rw-   1 boota   class     0 Sep  8 18:06 file2 $ 

File file1 belongs to group users , while file2 belongs to group class .

The su Command

The switch user ID ( su ) command is used to change the user ID temporarily just as you used the newgrp command to change the group ID. You need to know the password for the user you are changing to. The following command changes the user ID to jim .

 $  su jim  Password: $ 

To switch back to the actual user ID, use the exit command. After changing the user ID, all new files created belong to the new user. The environment related to user jim is not loaded until you use the su - jim command instead of su jim .

If you don't specify any user name with the su command, it will change to user root . You can become the superuser temporarily by using this command if you know the root password.

Note

Many system administrators work under a user ID other than root and change the ID to root only if required. This is done to avoid any accidental damage to files with commands like rm .


The id Command

The id command is used to display the current user and group IDs. A typical result of this command is:

 $  id  uid=415 (boota), gid=100 (users) $ 

The command shows that the current user is boota having a user ID of 415. The current group membership is users and the group ID is 100.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net