Download presentation
Presentation is loading. Please wait.
Published byClara Lloyd Modified over 8 years ago
1
Experiment No 4 Prepared by, Mr. Satish Pise
2
Objectives View the /etc/passwd file and describe its syntax. View the /etc/shadow file and describe its syntax. View the /etc/group file and describe its syntax. Create users, groups.Set permissions and ownership.
3
Useradd command Syntax - #useradd username options 1. How to Add a New User in Linux #useradd cse #passwd cse.. Once a new user created, it’s entry automatically added to the ‘/etc/passwd‘ file
4
Examples – Create a User with Different Home Directory # useradd -d /home/ty tycse Create a User with Specific User ID useradd -u 999 sp Create a User with Specific Group ID #useradd -u 1000 -g 500 poly #id tycse #id poly #groupadd admins,webadmin,developers Add a User to Multiple Groups #useradd -G admins,webadmin,developers cse Create a User with Account Expiry Date # useradd -e 2014-03-27 cse Create a User with Password Expiry Date # useradd -e 2014-04-27 -f 45 cse
5
Add a User without Home Directory #useradd -M satish #ls -l /home/satish Practice Change User Login Shell: # useradd -s /sbin/nologin tecmint # tail -1 /etc/passwd Add a User with Specific Home Directory, Default Shell and Custom Comment # useradd -m -d /var/www/ravi -s /bin/bash -c “cse Owner" -U ravi
6
Usermod Command Syntax - usermod [options] LOGIN Adding Comment to User Account # usermod -c "This is cse" cse Change User Home Directory # mkdir poly # usermod -d //poly/cse Set User Account Expiry Date # usermod -e 2014-11-01 cse # chage -l cse Change User Primary Group # usermod -g babin tecmint_test # id tecmint_test Adding Group to an Existing User # usermod -G tecmint_test0 tecmint # id tecmint
7
Change User Login Name # usermod -l developers programmer Deleting User using Userdel Syntax – #userdel username # userdel -r cse
8
Creating new groups Syntax - groupadd [options] group Example – #groupadd newgroup Modifying groups Syntax - groupmod [options] GROUP Examples : 1. Change the group “admins” to “cseaddmins”. # groupmod -n cseadmins admins 2. Change groupid of a group This command changes the groupid of cseadmins group to 777 # groupmod -g 777 cseadmins
9
Groupdel Command Delete a user security group. Syntax- groupdel group Example – #groupdel poly
10
Default File Permission # touch newfile # ls -al newfile Changing permissions using chmod command Following are the symbolic representation of three different roles: u - is for user, g - is for group, o - is for others. Following are the symbolic representation of three different permissions: r - is for read permission, w - is for write permission, x - is for execute permission.
11
Add single permission to a file/directory #chmod u+x filename Add multiple permission to a file/directory #chmod u+r,g+x filename Remove permission from a file/directory #chmod u-rx filename Change permission for all roles on a file/directory #chmod a+x filename Apply the permission to all the files under a directory recursively #chmod -R 755 directory-name Change execute permission only on the directories #chmod u+x *
12
Changing ownership using chown command Syntax -chown options owner[.group] file You can specify either the login name or the numeric UID for the new owner of the file: Syntax - chown options user:group file/folder #man chown #chown dan newfile # ls -l newfile
13
Change the owner of a file # chown root tmpfile Change the group of a file # chown :friends tmpfile Change both owner and the group # chown himanshu:friends tmpfile Change owner only if a file is owned by a particular user # chown --from=guest himanshu tmpfile # chown --from=root himanshu tmpfile Copy the owner/group settings from one file to another # chown --reference=file tmpfile
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.