[User] add, change, delete user(account) and group

0. list users

# cat /etc/passwd

# cut -f1 -d: /etc/passwd

 

1. add user

# useradd -d /home/fish fish

creates new user(account) “fish”

option “-d” is for the directory where the user is created.

 

2. set password

# passwd fish

type password 2 times.

 

3. check information of user

# cat /etc/passwd | grep username

user:01:x:501:100:username:/home/username:/bin/bash

2nd column “x” : password (encoded)

3rd column “501” : UID

4th column “100” : GID

5th column “username” : explanation of account (option -c)

6th column “/home/username” : home directory of account

7th column “/bin/bash” : login shell

 

4. delete account

# userdel username : delete only account “username” without deleting directory and files

# userdel -r username : delete all include directory and files

 

5. intercepting login

change password value on “/etc/passwd” from (x) to *.

or

change shell information from “/bin/bash” to “/bin/false” on “/etc/passwd”.

 


 

<Group setting>

1. create group (addgroup)

# addgroup group_name

ex) addgroup giant

 

1.1. option: group ID

# addgroup -g id

ex) addgroup -g 1003

 

1.1.1. check group and ID

# cat /etc/group | grep giant

can see this message “giant:x:1003” <- group name: password:group id

 

2. add users to group (usermod)

form) usermod -a -G group user

ex) usermod -a -G giant human

 

2.0.1. add user to group by specific UID and GID

ex) useradd -u 511 -g 556 username

 

2.1. check group

# groups group_name

 

3. change group name

# groupmod -n new_name old_name

# groupmod -g NEWGID GROUP

ex) groupmod -g 555 mygroup (change instantly)

 

4. change password / management users

4.1. change group password

# gpasswd group_name

4.2. users

# gpasswd option user_name group_name

options:

-A user_name group_name : appoint the user as manager

-a user_name group_name : add the user as users of the group

-d user_name group_name : exclude the user from the group

 

5. delete group

groupdel group_name

 

Advertisements

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