User Administration in Ubuntu

To add a user use the following command

>useradd xyz

when you run the following command a bunch of config files from the /etc/skel directory on your system gets copied in the users home directory.

To set a user password we have to run the following command

passwd  <username>

The password gets stored in the /etc/shadow file and it is encrypted. In the /etc/passwd file our new user gets added in the following format

xyz:x:501:501:ZYX:/home/xyz:/bin/bash

which is

username:passsword:userid:userprivategp:comment:userhomedirectory:bashfile

adding a group

groupadd -r projectX

the -r in groupadd gives the group an id of below 500 in red hat linux as id greater than 500 is reserved for user private group

adding a user to a group

usermod -G projectX,projectY[,groups1,2,3] <username>

you will have to remember all the groups that user is already in if you dont include it the user gets removed from that group

File permissions for users

-(rwx)(rwx)(rwx) for files

user,group,other permissions

d(rwx)(rwx)rwx) for directories the starting ‘d’ indicates a directory

giving permissions to users

chmod g+w filename

or

chmod 777 filename

to give ownership of a directory or a file to the user

chown user.group <filename>

making a user admin of a directory

gpasswd -A <user> <group>

gpasswd -A bob projectX

now bob can add anyone he likes to the group without permissions from the admin

gpasswd -a alice

gpasswd -d alice to delete alice

activating the superuser in ubuntu 12.04

sudo passwd root

add  a password

then

sudo su

authenticate using the password added

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