Monday, October 18, 2010

User Account & Shell



    When a new user account is created in UNIX, a lot of attributes are defined for the new user. The following are the ones :
  • User Name
  • User Id
  • Group Id
  • Home directory
  • Default Shell
   User name is the name given to the new user in the system. In any account, to find out the user who is currently working or logged in:

#echo $USER
blogger
  USER is an environment variable which will tell the user who is currently logged in.

 User Id is a unique id is given to the user. The operating system recognizes the users using the User-Id assigned. Similarly, every user created belongs to a group. If the group is not explicitly mentioned while user creation, the user gets created under a default group. 

To find out the user id or group-id or to the groups which the user belongs to:
#id
uid=500(blogger) gid=500(blogger)groups=500(blogger)
 Home directory is the location which the user will be at when he logs-in to his account. All the user files and directories are created under the user's home directory. To find out the home directory of the user logged in:
#echo $HOME
/home/blogger
 Shell is the default shell which the user will be in when he logs in to his account. The default shell can be specified at the time of user creation. To find out the default shell of the user:
#echo $SHELL
/bin/bash
  All the above mentioned user attributes are saved in a file, /etc/passwd, during the time of user creation. The group details are present in the /etc/group file.

To get the /etc/passwd record, we can simply do a grep of the user name in the file as shown:
#grep blogger /etc/passwd
In Sun OS or HP-UX flavors, pwget command gets the needful:
#pwget -n blogger
 where blogger is the user name.

 We will see in one of our future articles how to create a user account in UNIX flavors.

P.S: The above shown output are as per RedHat Linux.

No comments:

Post a Comment