0% found this document useful (0 votes)
13 views

CoSc3063 - NSA - Chapter - 2 - Lesson 2

dasdsx

Uploaded by

peter haile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

CoSc3063 - NSA - Chapter - 2 - Lesson 2

dasdsx

Uploaded by

peter haile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

CoSc 3063-System and Network

Administration
Chapter 2: Host And User Manegment
Computer science 3rd Year, 1st Sem.
Fitsum Gizachew (BSc students_2014)
Topics to be covered
Lesson 2: User Management • Source
– How Linux user account work
• “Principles of Network and
– Managing user account
System Administration” (2nd
– How Linux group work Edition), John Wiley and Sons
– Manage ownership, permissions, Ltd, Mark Burgess, 2004.
and quotas • “Essential System
Administration”, 3rd Edition,
O’Reilly and Associates Inc.,
Ǽleen Frisch, 2003.

2
Manage users account

 Linux user accounts


 How Linux user accounts work?
 Where Linux user accounts are stored?
 Creating and managing user accounts from the command line?

3
How Linux User Accounts Work

 Username
 Password
 By default, all user home directories are created and

maintained in the /home directory.


 However, the root user’s home directory is /root

4
 Where Linux User Accounts Are Stored

 Linux is a very flexible operating system. One of its


flexible features is the location of user accounts on the
system.
When you originally installed the system, there are
several options for where you wanted to store your user
accounts.

5
Cont…
 /etc/passwd: file contains the user account information
for your system.
 /etc/shadow: file contains passwords for your user
accounts.
 /etc/group: file contains your system’s groups.

6
Creating and Managing User Accounts from the
Command Line

 Using useradd: to Adding user account


 Using passwd: to change password of user
account
 Using usermod: to Modifying user account
 Using userdel: to Deleting user account

7
Using useradd

 Used to add user into Linux system.


 Syntax: useradd options username
 Suppose I want to create user called student
 useradd student
student account is created using the default parameters
 You can also view these default values by entering useradd –D
at the shell prompt.

8
You can also view these default values by
entering useradd –D at the shell prompt.
Option
–c Includes the user’s full name
–e Specifies the date when the user account will be disabled
–f Specifies the number of days after password expiration before the account is
disabled.
–g Specifies the user’s default group
–G Specifies additional groups that the user is to be made a member of.

–M Specifies that the user account be created without a home directory.


–m Specifies the user’s home directory.
–p Specifies the user’s password.

9
- Using passwd
 The passwd utility is used to change an existing user’s
password
 You can find out this information using the –S option
with passwd
 Syntax: passwd username

10
Options

–l Locks the user’s account


–d Removes a user’s password.

–n Sets the minimum number of days required before a password can be


changed.
–x Sets the maximum number of days before a password must be changed.

–w Sets the number of days prior to password expiration when the user will be
warned of the pending expiration.

–i Sets the number of days to wait after a password has expired to disable the
account.

11
- Using usermod
 From time to time, you will need to modify an existing user account.
Syntax: usermod options username
Options

–c Edits the user’s full name.

–e Sets the date when the user account will be disabled. Format the date as yyyy-mm-dd.

–f Sets the number of days after password expiration before the account is disabled. Use a value of –1 to disable this
functionality.

–g Sets the user’s default group.

–G Specifies additional groups that the user is to be made a member of.

–l Changes the username.

–L Locks the user’s account. This option invalidates the user’s password

–m Sets the user’s home directory

–p Sets the user’s password.

–s Specifies the default shell for the user.

–u Sets the UID for the user.

12 Unlocks a user’s account that has been locked.


–U
- Using userdel
 From time to time you will need to remove user account from Linux
system. this can be done from shell prompt using userdel utility.
 Syntax:userdel username
 example: userdel student
 It’s important to note that, by default, userdel will not remove the
user’s home directory from the file system. If you do want to remove
the home directory when you delete the user, you need to use the –r
option in the command line.
 For example, entering userdel –r student will remove the account
and delete her/his home directory.

13
2. How Linux Groups Work
 How Linux groups work
 Managing groups from the command line
• Linux Groups
 If your Linux system has been configured to use local
authentication, your groups are defined in the /etc/group
file. Each record is composed of the following four fields:
Group:Password:GID:Users
 Group Specifies the name of the group.
 Password Specifies the group password.
 GID Specifies the group ID (GID) number of the group.
Users Lists the members of the group.
 14
Managing groups account from the
command line

 Using groupadd
 Using groupmod
 Using groupdel

15
- Using groupadd

 Syntax:
groupadd options groupname
Options:
–g Specifies a GID for the new group.
–p Specifies a password for the group.
–r Specifies that the group being created is a system group.

16
- Using groupmod
 To modify a group, including adding users to the group
membership, you use the groupmod utility.
 Syntax:
groupmod options group
 Options:
–g Changes the group’s GID number.
–p Changes the group’s password.
–A Adds a user account to the group.
–R Removes a user account from the group.
 If we wanted to add student to the group, we would enter
 groupmod –A “student” at the shell prompt.

17
- Using groupdel

 Syntax: groupdel group_name


 ex: groupdel student

18
3. Manage ownership, permissions

 Managing ownership
 Managing permissions
Managing ownership

 How ownership works


 Managing ownership from the command line

19
• How ownership works

 Anytime a user creates a new file or directory,


his or her user account is assigned as that file or
directory’s “owner.”
 By right-clicking on this file in the system’s
graphical user interface and selecting Properties
| Permissions, you can view who owns the file.
 You can also view file ownership from the
command line using the ls –l command

20
• Managing ownership from the
command line
 You can specify a different user and/or group as the
owner of a given file or directory. To change the
user who owns a file, you must be logged in as root.
To change the group that owns a file, you must be
logged in as root or as the user who currently owns
the file.
 Using chown
 Using chgrp

21
- Using chown

 The chown utility can be used to change the user


or group that owns a file or directory.
Syntax chown user.group file or directory.
Ex: If I wanted to change the file’s owner to the
ncth1 user, I would enter
chown ncth1 /tmp/myfile.txt

22
chown

If I wanted to change this to the users group, of


which users is a member, I would enter
chown .users /tmp/myfile.txt
Notice that I used a period (.) before the group
name to tell chown that the entity specified is a
group, not a user account.
Ex: chown student.users /tmp/myfile.txt
Note: You can use the –R option with chown to
change ownership on many files at once recursively.

23
- Using chgrp

 In addition to chown, you can also use chgrp to


change the group that owns a file or directory.
 Syntax:
chgrp group file (or directory)‫‏‬
 For example:
chgrp student /tmp/newfile.txt.

24
Managing permissions

 How permissions work


 Managing permissions from the command line
 Working with default permissions

25
 Access to files in Linux is based on permissions
 Each user and group has different permissions regarding access
to files
 Available permissions
 read, write, execute, and no permission
 Three types of users in Linux
 User: username of the person who owns the file
 Group: set of users
 Other: user who isn't the owner of the file and doesn't belong
in the same group the file does
 Everyone else other than user and group

26
- How permissions work

27
- Managing Permissions from the Command
Line with chmod
chmod entity=permissions filename

28
29
Thank you
?
30

You might also like