RSS

User Management

25 Feb

User Management  Commands and explanation:

  1. useradd
  2. userdel
  3. usermod
  4. adduser
  5. chgrp
  6. chown
  7. finger
  8. groupadd
  9. groups
  10. groupmod
  11. passwd
  12. pwconv
  13. quota
  14. who
  15. whoami

These are some basic user management commands :

1.Command : useradd user_name

  • This command is used to create a new user
  • To check where the user is been created type in cat  /etc/passwd this shows the entire history of users
  • Example: useradd  linux1

To change the password or to create a password for the user :

Command : passwd  user_name

[root@localhost ~]# passwd linux1
Changing password for user linux1.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

This will be the output where we can create a new password for the username called linux1 using this command …

After creating a user we can set aging and timer i.e expiration date by:

Command : chage user_name

  • this is used to change the time of the users password

2. Command : userdel  user_name

  • This deletes a useraccount and related files
  • Example: userdel linux1

3. Command : usermod   [option]  login

  • This Command is used for user modification
  • This can be performed for different usages like we can modify the username or userpassword etc…
  • For the modification we must know some of the options :

-l, –login NEW_LOGIN               new value of the login name
-L, –lock                                            lock the user account
-m, –move-home                           move contents of the home directory to the new   location (use only with -d)

-p, –password PASSWORD       use encrypted password for the new password

  • Example : usermod  -l   linux_solaris    linux1
  • This will change the username from linux1 to linux_solaris

To modify the password using usermod:

  • sytax: usermod  -p  <new-password>  login_name
  • Example: usermod  -p  myunixlab  linux_solaris

This will modify the password as myunixlab in the linux_solaris user account…

Like wise we have more options in usermod to verify that check by typing man usermod or usermod –help

4. Command : adduser

  • This command is same like useradd command …
  • Example: adduser  linux2
  • This will create a new user named linux2

5. Command: chgrp   group_name  filename.txt

  • This command is used to change the group ID to the required file..
  • Example: chgrp   linux1   file.txt

[root@localhost ~]# chgrp linux1 file.txt
[root@localhost ~]# ls -l file.txt
-rw-r–r– 1 root linux1 22 Feb 25 09:15 file.txt

6. Command : chown  User_name    filename.txt

  • This command is used to change the ownership of respective file to the respective user ..
  • Example: chown linux1   file.txt

[root@localhost ~]# chown linux1 file.txt
[root@localhost ~]# ls -l file.txt
-rw-r–r– 1 linux1 root 22 Feb 25 09:15 file.txt

  • This will change the ownership to Linux1 …

We can also turn the entire directory ownership to respective user by using -R option ..

  • Example :  chown -R linux1  awk

[root@localhost ~]# chown -R linux1 awk
[root@localhost ~]# echo $?
0
[root@localhost ~]# ls -l | grep -i awk
drwxr-xr-x 2 linux1 root  4096 Feb 19 13:08 awk

  • Now this is a directory and we changed its ownership to linux1……

7. Command : finger  user_name

  • This will show the user informations
  • It has some options also -lspm each alphabet gives there corresponding output like the option individually finger  -s  user_name shows the login ,tty ,login time etc…
  • Example: finger  sridhar

[root@localhost ~]# finger sridhar
Login: sridhar                          Name: (null)
Directory: /home/sridhar                Shell: /bin/bash
Last login Tue Feb 22 16:18 (PST) on pts/3 from 192.168.1.103
No mail.
No Plan.

These are the info provided..

  • Example: finger -s linux1

[root@localhost ~]# finger -s linux1
Login     Name       Tty      Idle  Login Time   Office     Office Phone
linux1                *     *  No logins

Since the user name linux1 is newly created and not used it shows no logins…

8.Command : groupadd group_name

  • This will create a group
  • This is used to add existing users to the corresponding group
  • Example: Command: groupadd linugrp

This will create a group and to verify this type in the command: cat   /etc/groups

To add a user in the group:

  • Take some existing user ..
  • Command: usermod -G group_name   user_name
  • Example: Command: usermod  -G  linuxgrp  linux1

Again to verify the user is been added type in the command:cat  /etc/groups

To delete a group:

  • Command: groupdel  group_name

9. Command: groups

  • This command shows the groups where the user is in…………
  • If it is super user(root) then it shows the group in it

[root@localhost ~]# groups
root bin daemon sys adm disk wheel

10. Command : groupmod -n new_group existing_group

  • This command is used to modify the group name from existing group to new groupname
  • Example : groupmod -n newlinuxgrp  linuxgrp

11. Command: passwd  user_name(login_name)

  • This command is used to change the password of existing user
  • Example: passwd linux1
  • After this it will ask for new password and then it will reconfirm it again  thus a new password will be created for linux1 user account

12.

 

About these ads
 
Leave a comment

Posted by on February 25, 2011 in Linux, User Management

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: