User Management:
What is a shell?
A shell is a user interface where we execute commands/scripts
There are diifferent Shells available:
1. ksh (K Shell)
2. sh (Born Shell)
3. bash Born Again Shell
4. csh
5. tcsh etc.,
/etc/shells: contains list of shells installed in our machine
/etc/passwd: contains information about all user accounts
fields Description
1 username
2 password(Encrypted)
3 User ID
4 Group ID
5 GCOS (fullname, phoneno. etc., information about user)
6 home dir
7 shell
useradd: used to add a user account
syn: useradd <-options> username
-g: to set primary group to a user
-G: to set secondary group(s) for a user
-s: to specify shell
-d: to set home directory
* what are options used to set UID,GCOS
ex: #groupadd dba
#useradd -g dba -G users -s /bin/sh -d /home/dba1 king
#id King [display information about user King]
#useradd -g dba -G users,uclid01 -d /home/dba2 -s /bin/sh Raju
user ID for root -- 0
user Id's: 1 to 499 -- system accounts
500 and above -- users
usermod: to modify user account
usermod <-options> username
ex:
#usermod -G wheel King
[replaces existing secondary group(s) with new group]
#usermod -aG users King
[append a new group into secondary group list]
userdel: to delete a user account
#userdel King [delete the user, but home directory still exists]
#userdel -r King [delete the user and his home directory also]
echo $USER == shows currunt user name
echo $SHELL == shows currunt shell of the user
----------------------------------------------------------------------------
chown: used to change owner & group of a file/dir
syn: chown owner:group filename
ex: chown madhu /home/madhu/hello.txt -- only owner is changed
chown madhu:dba /home/madhu/hello.txt -- owner&group is changed
chown :dba /home/madhu/hello.txt -- only group is changed
chgrp: to change group of a file./dir
chgrp -R dba /home/madhu
---------------------------------------------------------------------------
chage: USed to manage password Aging
chage [-options] username
options:
-m: used to specify no. of days before changing password
-M: no. of days before password change is required
-W: no. of days when warning shoould be displayed before change password is required
-I. No, of days after password change required to inactiavte the account
-E - to set account expiry in no. of days from 1st jan 1970 (or) specify date when account should expire.
chage -m 10 -M 100 -W 5 -I 5 -E 2015-12-31 King
-d: used to set password change days
if set to '0' it will ask user to change password in next login
ex: chage -d 0 King
How to Lock a user account:
usermod -L King
How to Unock a user account:
usermod -U King
/etc/shadow: contains password ageing info
------------------------------------------------------------------------------
Chmod (Special Permissions):
Set UID: to set default owner for a script/process
(can be assigned only for files)
chmod u+s hello.sh
set GID:
file - to set default group for a script/process
chmod g+s hello.sh
dir - if a directory is set with GID, who ever may create files in this direcotry, the file group will be the currunt directory group.
Sticky Bit - set only to a directory, if any body creates a file in this direcotry, only owner of the file can delete it.
chmod o+t directory
How to set these special permissions in numaric mode?
Comments
Post a Comment