0% found this document useful (0 votes)
11 views41 pages

Linux(Chapter 5)

Uploaded by

jadhashrikant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views41 pages

Linux(Chapter 5)

Uploaded by

jadhashrikant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

LINUX OPERATING SYSTEM

SYSTEM
ADMINISTRATION IN
LINUX

SYSTEM ADMINISTRATOR OR SUPPER USER


 The person who is responsible for setting up and maintaining the
system is called as the system administrator or in short sysadmin.
 System administrators may be members of an information technology
department.
 Much of what a system administrator does is work that ordinary users
do not have permission to do.
 When performing one of these tasks, the system administrator logs in as
root to have system wide powers that are beyond those of ordinary
users: A user with root privileges is referred to as Superuser.
 The username is root by default.
 When you are running with root (Superuser) privileges, the shell by
convention displays a special prompt to remind you of your status.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 By default, this prompt is or ends with a pound sign (#).


 When you are working on the computer, especially when you are
working as the system administrator, perform any task while using the
least privilege possible.
 When you can perform a task logged in as an ordinary user, do so.
 When you must be logged in as Superuser, do as much as you can as an
ordinary user, log in or use su so you have root privileges, complete the
part of the task that has to be done as Superuser, and revert to being an
ordinary user as soon as you can.
 Because you are more likely to make a mistake when you are rushing,
this concept becomes more important when you have less time to apply
it.
 You can gain or grant Superuser privileges in a number of ways:

1. When you bring the system up in single-user mode, you are Superuser.

2. Once the system is up and running in multiuser mode, you can log in as
root. When you supply the proper password, you will be Superuser. In
Linux system we should remember that ‘root’ is the superuser. We can log
in to the root by giving following information:

Login User : root

Password : Will be the password given at the time of installation

3. You can give an su (substitute user) command while you are logged in as
yourself and, with the proper password, you will have Superuser
privileges.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

o In Linux operating system, a superuser is a user with unrestricted


access to all files and commands. The user name of superuser’s
account is root. Nearly all administrative everyday jobs and their
associated commands need super user status. You can become a
super user by executing the su (substitute user) command after
logging in under another user name (normal user) as shown below.

$su

Password: ********

o Use the id utility to display the changes in your user and group ID
and in the groups you are associated with:

$id

uid=500(rshukla) gid=500(rshukla) groups=500(rshukla)

$su

Password: ********

#id

uid=0(root) gid=0(root) groups=0(root), 1(bin), 2(daemon),


3(sys), ...

o If you want to log in to sub user (student1) in same console 1 then


there are 2 types of log in.

1. Log in by changing your current working directory

2. Log in without changing your current working directory

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

Log in by changing your current working directory

o Consider that you are logged in as root and your working directory will
be root and you want to switch to user ‘student1’. Then you have to use
the following command:

#su – student1

o Now you are logged in as ‘student1’ and your current working directory
will be home (~) folder of ‘student1’.
o Note: Since you are switching from ‘root’ to ‘student1’ the shell prompt
will not ask for password to log in since root will be having full
permission to access other users.
o However if you want to switch from subuser to other subuser or root
(eg student1 to student2) shell prompt will be asking for password to
log in.

Log in without changing your current working directory

o Consider that you are logged in as root and your working directory will
be root and you want to switch to user ‘student1’. Then you have to use
the following command

#su student1

o Now you are logged in as ‘student1’ , however your current working


directory will be unchanged that is it will be root folder.

4. You can use sudo selectively to give users Superuser privileges for a limited
amount of time on a per-user and per-command basis.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

o The sudo utility is controlled by the /etc/sudoers file, which must be set
up by root.
o sudo (Super User DO) command in Linux is generally used as a prefix
of some command that only superuser are allowed to run.
o If you prefix “sudo” with any command, it will run that command with
elevated privileges or in other words allow a user with proper
permissions to execute a command as another user, such as the
superuser.
o This is the equivalent of “run as administrator” option in Windows.
o The option of sudo lets us have multiple administrators.
o These users who can use the sudo command need to have an entry in
the sudoers file located at “/etc/sudoers”. Remember that to edit or
view the sudoers file you have to use sudo command.
o By default, sudo requires that users authenticate themselves with a
password which is the user’s password, not the root password itself.

sudoers file:

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

MANAGING USER ACCOUNTS


 When a computer is used by many people it is usually necessary to
differentiate between the users, for example, so that their private files
can be kept private.
 This is important even if the computer can only be used by a single
person at a time, as with most microcomputers.
 Thus, each user is given a unique username, and that name is used to log
in. There is more to a user than just a name, however.
 An account is all the files, resources, and information belonging to one
user.
 Users can be either people, meaning accounts attached to physical users,
or accounts that exist for specific applications to use.
 Groups are logical expressions of organization, tying users together for a
common purpose.
 Users within the same group can read, write, or execute files owned by
the group.
 Each user and group have a unique numerical identification number
called a userid (UID) and a groupid (GID) respectively.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 When a file is created, it is assigned a user and group owner. It is also


assigned separate read, write, and execute permissions for the owner,
the group, and everyone else.
 The user and the group to which a file belongs, as well as the access
permissions on the file, can be changed by the root user or, in most
cases, by the creator of the file.
 Proper management of users and groups, and effective management of
file permissions are among the most important tasks a system
administrator undertakes.

User and Group Management Tools

 The easiest way to manage users and groups is through the graphical
application, User Manager.
 The following command line tools can also be used to manage users and
groups:
o useradd, usermod, and userdel – Industry-standard methods of
adding, deleting and modifying user accounts.
o groupadd, groupmod, and groupdel – Industry-standard methods
of adding, deleting, and modifying user groups.

Following are important Files that hold user information:

o /etc/passwd - Where the user’s name, and other pertinent


information are stored. This includes the password unless your
system is using shadow passwords.
o /etc/shadow - Where the user’s password is stored if you are
using shadow passwords.
ASST. PROF. ZEENAT SULTANA
LINUX OPERATING SYSTEM

o /etc/group - Where group names are stored.


o /etc/aliases - Where the user’s name is matched to a nickname for
e-mail.
o /etc/sudoers - A list of users with special privileges along with the
commands they can execute.

Adding User in Linux

 Linux/Unix is multi user and multi-tasking OS. There are two types of
users in Linux operating system- system users and normal users.
o User always get created with primary group
o One Primary Group per User
 Each user is identified by a unique integer, the user id or uid, because
numbers are faster and easier for a computer to process than textual
names.
 A separate database outside the kernel assigns a textual name, the
username, to each user id.
 The database contains additional information as well. To create a user,
you need to add information about the user to the user database and
create a home directory for him. It may also be necessary to educate the
user and set up a suitable initial environment for him.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

useradd COMMAND
 useradd is a command in Linux that is used to add user accounts to
your system.
 It is just a symbolic link to adduser command in Linux and the
difference between both of them is that useradd is a native binary
compiled with system whereas adduser is a Perl script which uses
useradd binary in the background.
 It make changes to the following files:
o /etc/passwd
o /etc/shadow
o /etc/group
o creates a directory for new user in /home
Syntax:
useradd [options] name_of_the_user

Working with useradd Command

1. To add a simple user


sudo useradd test_user

This command will add the user named “test_user”.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

2. To give a home directory path for new user


sudo useradd -d /home/test_user test_user

This will set the home directory of the us”/home/test_user”.

3. To create a user with specific user id


sudo useradd -u 1234 test_user

This will create a new user with the user-id “1234” and the name “test_user”.

4. To create a user with specific group id


sudo useradd -g 1000 test_user

This will create a new user with the group id “1000” and the name
“test_user”.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

5. To create a user without home directory


sudo useradd -M test_user

This will create the user with the name “test_user” and that too without a
home directory.

6. To create a user with expiry date


sudo useradd -e 2020-05-30 test_user

This will create the user named “test_user” with the expiry date of 30th May
2020.

7. To create a user with a comment


sudo useradd -c "This is a test user" test_user

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

This will create a user with a short comment or description of the user.

8. To create a user with a changed login shell


sudo useradd -s /bin/sh test_user

This will create a user named “test_user” with the default shell /bin/sh.

 The /etc/passwd file is a colon-separated file that contains the


following information:

 User name
 Encrypted password
 User ID number (UID)
 User's group ID number (GID)
 Full name of the user (GECOS)
 User home directory
 Login shell

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

9. To set an unencrypted password for the user


sudo useradd -p test_password test_user

This will create a new user with the name “test_user” and an unencrypted
password “test_password”.

 As with the /etc/passwd, each field in the shadow file is also separated
with “:” colon characters as follows:
1. Username : A valid account name, which exist on the system.
2. Password : Your encrypted password is in hash format. The
password should be minimum 15-20 characters long including
special characters, digits, lower case alphabetic and more.
3. Last password change (lastchanged) : The date of the last
password change, expressed as the number of days since Jan 1,
1970 (Unix time). The value 0 has a special meaning, which is that
the user should change her password the next time she will log in
the system. An empty field means that password aging features
are disabled.
4. Minimum : The minimum number of days required between
password changes i.e. the number of days left before the user is
allowed to change her password again. An empty field and value 0
mean that there are no minimum password age.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

5. Maximum : The maximum number of days the password is valid,


after that user is forced to change her password again.
6. Warn : The number of days before password is to expire that user
is warned that his/her password must be changed
7. Inactive : The number of days after password expires that
account is disabled.
8. Expire : The date of expiration of the account, expressed as the
number of days since Jan 1, 1970.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

10. To display help


sudo useradd --help

This command will display the help section of the useradd command.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

userdel COMMAND
 The userdel command in Linux system is used to delete a user account
and related files.
 This command basically modifies the system account files, deleting all
the entries which refer to the username LOGIN. It is a low-level utility
for removing the users.
Syntax:
userdel [options] LOGIN

 To remove a user, you first remove all his files, mailboxes, mail aliases,
print jobs, cron and at jobs, and all other references to the user. Then
you remove the relevant vlines from /etc/passwd and /etc/group
(remember to remove the username from all groups it’s been added
to). It may be a good idea to first disable the account (see below),
before you start removing stuff, to prevent the user from using the
account while it is being removed. Remember that users may have files
outside their home directory. The find command can find them:

#find / -user username

 However, note that the above command will take a long time, if you
have large disks. If you mount network disks, you need to be careful so
that you won’t trash the network or the server.

Options with Example:


 userdel -f: This option forces the removal of the specified user account. It
doesn’t matter that the user is still logged in. It also forces the userdel to

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

remove the user’s home directory and mail spool, even if another user is
using the same home directory or even if the mail spool is not owned by
the specified user.
 Mail spool shows emails that are waiting to be delivered or have
returned an error. You can apply filters and take action on these emails.
Mail logs. Mail logs show the list of all emails. You can filter these by the
action taken and scanning outcome.
Example:
sudo userdel -f neuser

 userdel -r: Whenever we are deleting a user using this option then the
files in the user’s home directory will be removed along with the home
directory itself and the user’s mail spool. All the files located in other file
systems will have to be searched for and deleted manually.
Example:
sudo userdel -r newuser2

 userdel -h : This option display help message and exit.


Example:
userdel -h

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

usermod COMMAND
 usermod command or modify user is a command in Linux that is used
to change the properties of a user in Linux through the command line.
 After creating a user we have to sometimes change their attributes like
password or login directory etc. so in order to do that we use the
usermod command. The information of a user is stored in the following
files:

o /etc/passwd
o /etc/group
o /etc/shadow
o /etc/login.defs
o /etc/gshadow

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 When we execute usermod command in terminal the command make


the changes in these files itself.
 Note: usermod command needs to be executed only as a root user.

Working with usermod command

1. To add a comment for a user


sudo usermod -c "This is test user" test_user

This will add a comment about the user or a short description related to the
user.

2. To change the home directory of a user


sudo usermod -d /home/manav test_user

This will change the home directory of the user to /home/manav.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

3. To change the expiry date of a user


sudo usermod -e 2020-05-29 test_user

This will change the expiration date of account “test_user”

4. To change the group of a user


sudo usermod -g manav test_user

This command will now change the group of test user from test_user to
manav

5. To change user login name


sudo usermod -l test_account test_user

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

This will now change the login name of the user “test_user”.

6. To lock a user
sudo usermod -L test_user

This will lock the “test_user” account and will display a! sign in shadow file
before the username

7. To unlock a user
sudo usermod -U test_user

This will unlock the “test_user” which was locked by the previous command

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

8. To set an unencrypted password for the user


sudo usermod -p test_password test_user

This will set the password “test_password” in the unencrypted form for the
user “test_user”

10. To change the user id of a user


sudo usermod -u 1234 test_user

This command will change the user id of “test_user” to 1234

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

MANAGING GROUP ACCOUNT


 /etc/group

 It stores group information or defines the user groups i.e. it defines the
groups to which users belong. There is one entry per line, and each line
has the following format (all fields are separated by a colon (:)

Fig.01: Sample entry in /etc/group file


 Where,
1. group_name: It is the name of group. If you run ls -l command,
you will see this name printed in the group field.
2. Password: Generally password is not used, hence it is
empty/blank. It can store encrypted password. This is useful to
implement privileged groups.
3. Group ID (GID): Each user must be assigned a group ID. You can
see this number in your /etc/passwd file.
4. Group List: It is a list of user names of users who are members of
the group. The user names, must be separated by commas.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

More About User Groups

 Users on Linux and UNIX systems are assigned to one or more groups
for the following reasons:

o To share files or other resource with a small number of users


o Ease of user management
o Ease of user monitoring
o Group membership is perfect solution for large Linux (UNIX)
installation.
o Group membership gives you or your user special access to files
and directories or devices which are permitted to that group

groupadd COMMAND
 groupadd command creates a new group account using the values
specified on the command line and the default values from the system.

 The new group will be entered into the system files as needed.

Options

Tag Description

This option causes the command to simply exit with success


status if the specified group already exists. When used with -
-f, --force
g, and the specified GID already exists, another (unique) GID
is chosen (i.e. -g is turned off).

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

Create a system group.

The numeric identifiers of new system groups are choosen in


-r, --system
the SYS_GID_MIN-SYS_GID_MAX range, defined in login.defs,
instead of GID_MIN-GID_MAX.

The numerical value of the group's ID. This value must be


unique, unless the -o option is used. The value must be non-
negative. The default is to use the smallest ID value greater
-g, --gid GID
than 999 and greater than every other group. Values
between 0 and 999 are typically reserved for system
accounts.

-h, --help Display help message and exit.

Overrides /etc/login.defs defaults (GID_MIN, GID_MAX and


others). Multiple -K options can be specified.
-K, --key
KEY=VALUE Example: -K GID_MIN=100 -K GID_MAX=499

Note: -K GID_MIN=10,GID_MAX=499 doesn't work yet.

-p, --
The encrypted password, as returned by crypt. The default is
password
to disable the password.
PASSWORD

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

Example-1:

This example would create a new group called "newgroup".

# groupadd newgroup

output:

to verify greoup created , search in /etc/group

# grep test /etc/group


test:x:1002:

Example-2:

To create new group with specific groupid

# groupadd -g 9090 newgroup

output:

# grep newgroup /etc/group


newgroup:x:9090:

Example-3:

To create group in user defined range ( not range from system i.e
/etc/login.defs)

# groupadd newgroup -K GID_MIN=8888 -K GID_MAX=9999

output:

# grep newgroup /etc/group


newgroup:x:9091:

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

groupdel COMMAND
 groupdel command is used to delete a existing group. It will delete all
entry that refers to the group, modifies the system account files, and it
is handled by superuser or root user.
Syntax:
groupdel [options] GROUP

Files:
 /etc/group : It contains the account information of the Group.
 /etc/gshadow : It contains the secure group account information.
Exit values: This command exits with the following values.
 0: Success
 2: Invalid Command Syntax.
 6: Specified group doesn’t exist.
 8: Can’t remove users primary group.
 10: Can’t update group file.
Options:
 -f –force: It used to delete a group even if it is the primary group of a user.
 -h –help: It displays the help message and exit.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

groupmod COMMAND
groupmod command in Linux is used to modify or change the existing group
on Linux system. It can be handled by superuser or root user. Basically, it
modifies a group definition on the system by modifying the right entry in the
database of the group.
Syntax:
groupmod [option] GROUP

Files: The groupmod command has following files.


 /etc/group: Group Account Information.
 /etc/gshadow: Secured group account information.
 /etc/login.def: Shadow passwd suite configuration.
 /etc/passwd: User account information.
Exit Values:
 0: Success.
 2: Invalid command Syntax.
 3: Invalid argument to option.
 4: specified group doesn’t exist.
 6: specified group doesn’t exist.
 9: group name already in use.
 10: can’t update group file.
Options: There are following option available in groupmod command.
 -g, –gid GID: The group ID of the given GROUP will be changed to GID.
 -n, –new-name NEW_GROUP: The name of group will change into
newname.
 -h, –help: This option display help massage and exist.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 -p, –password PASSWORD: This gives the encrypted password.


Example: Below command will change group group_old to group_new using -
n option.
groupmod -n group_new group_old

chown COMMAND
 Different users in the operating system have ownership and
permission to ensure that the files are secure and put restrictions on
who can modify the contents of the files. In Linux there are different
users who use the system:

o Each user has some properties associated with them, such as a


user ID and a home directory. We can add users into a group to
make the process of managing users easier.
o A group can have zero or more users. A specified user can be
associated with a “default group”. It can also be a member of
other groups on the system as well.
 Ownership and Permissions: To protect and secure files and
directory in Linux we use permissions to control what a user can do
with a file or directory.
 Linux uses three types of permissions:
o Read: This permission allows the user to read files and in
directories, it lets the user read directories and subdirectories
stores in it.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

o Write: This permission allows a user to modify and delete a


file. Also it allows a user to modify its contents (create, delete
and rename files in it) for the directories. Unless the execute
permission is not given to directories changes does do affect
them.
o Execute: This permission on a file allows it to get executed.
For example, if we have a file named php.sh so unless we don’t
give it execute permission it won’t run.
 Types of file Permissions:
o User: These type of file permission affect the owner of the file.
o Group: These type of file permission affect the group which
owns the file. Instead of the group permissions, the user
permissions will apply if the owner user is in this group.
o Other: These type of file permission affect all other users on
the system.
 Note: To view the permissions we use:
ls -l

 chown command is used to change the file Owner or group. Whenever


you want to change ownership you can use chown command.
Syntax:
chown [OPTION]… [OWNER][:[GROUP]] FILE…

chown [OPTION]… –reference=RFILE FILE…

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 Example: To change owner of the file:


chown owner_name file_name

In our case we have files as follows:

 Now if I use file1.txt in my case, to change ownership I will use the


following syntax:
chown master file1.txt

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 where the master is another user in the system. Assume that if you are
user named user1 and you want to change ownership to root (where
your current directory is user1). use “su do” before syntax.
sudo chown root file1.txt

Options with Examples:


 -v: It is used to show the verbose information for every file processed.
Example:
chown -v master file1.txt

 To Change group ownership In our case I am using group1 as a group


in the system. To change ownership we will use
chown :group1 file1.txt

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

You can see that the group permissions changed to group1 from root, if you
use -v option it will report that. We just need to add a “:” to change group.

 To change the owner as well as group: Again taking master as user


and group1 as a group in the system
chown master:group1 greek1

Here, greek1 is a file.

 To change the owner from particular ownership only: Suppose we


want to change ownership from master to root where current owner
must be master only.
chown --from=master root greek1

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 To change group from a particular group:


chown --from=:group1 root greek1

Here, the output of the above command is, the group of greek1 is changed to
root.

 To copy ownership of one file to another:


chown --reference=greek1 greek2

 To change ownership of multiple files:


chown master:group greek2 greek3

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

chgrp COMMAND
 chgrp command in Linux is used to change the group ownership of a
file or directory.
 All files in Linux belong to an owner and a group. You can set the
owner by using “chown” command, and the group by the “chgrp”
command.
Syntax:
chgrp [OPTION]… GROUP FILE…

chgrp [OPTION]… –reference=RFILE FILE…

 Note: First we need to have administrator permission to add or delete


groups. We can Login as root for this purpose or using sudo. In order to
add a new group we can use:
sudo addgroup geeksforgeeks

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

Example 1: To change the group ownership of a file.


sudo chgrp geeksforgeeks abc.txt

Here the group name of the file abc.txt was changed from kcVirtual
to geeksforgeeks. Note that when files are created the groupname of the file is
same as the owner under which the file was created.

Example 2: To change the group ownership of a folder.


sudo chgrp geeksforgeeks GFG

Example 3: To recursively change the group ownership of a folder and all of


its contents.
sudo chgrp -R geeksforgeeks GFG

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

As we can see the group of the folder GFG and its contents F1, F2 was all
kcvirtual initially and they were changed to geeksforgeeks with the single
command.

Example 4: Using the groupname of a reference file to change the group of


another file or folder.
sudo chgrp -R --reference=abc.txt GFG

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

The groupname of the reference file abc.txt was used to recursively change
the group of the folder GFG and all its contents using the –reference option.

Sharing folders with other users


 When multiple users need access to the same set of directories of files
then we need to create shared folders to be used by the users.

 In Linux there is concept of users and groups which can be given certain
level of permissions that will enable them to share the data.

 Below are the steps how to create the shared folders where users can and
update the files individually.

Step 1 − Create the folder to be shared


Assuming we are setting up the shared folder from scratch, lets create the
folder. The -p will create the directory and would ignore any errors if the
directory already exists.

sudo mkdir -p /bigproject/sharedFolder

Step 2 − Create a user group


Next, we create a user group that will be used by users requiring access to this
folder.

sudo groupadd SharedUsers

Step 3 − Give permissions

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

Now we assign the new group to become owner of the shared folder and give
them appropriate permissions which can also be inherited by the
subdirectories.

sudo chgrp -R SharedUsers /bigproject/sharedFolder

sudo chmod -R 775 /bigproject/sharedFolder

Step 4 − Add users to the group


Now we add usernames to this group show that they can use the shared folder.

useradd -D -G SharedUsers user1

useradd -D -G SharedUsers user2

passwd COMMAND
 Any user can change their password at any time. It is good practice to
frequently change your password, and to not reuse or rotate passwords.

1. Open a terminal.
2. Type in the passwd command to start the password change process.
Passwd may look like a spelling mistake, but it is the command to work with
passwords on the terminal.
$ passwd
3. Type in your current password and press Enter.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

4. Type in your new password, press Enter. Then type it in again to


confirm that it is correct. Note that Linux will not echo (print) the password to
the screen, nor will it show any asterisk indicating password length.

Change Another User's Password

 If you are an administrator of many users, there will come a time where
a user forgets their password and it will fall to you, or someone with
sudo privileges to reset their password.

 To change another user's password we use the same command, but


specify the user’s name.

1. Open a terminal.
2. Type in the passwd command along with the user name. To use this
command you will either need to be root, or be part of the “sudo” group. In the
code example we assume that you are in the sudo group.
3. Change the user’s password, and confirm the change.

ASST. PROF. ZEENAT SULTANA


LINUX OPERATING SYSTEM

 The passwd command has a number of useful arguments (parameters)


that we can pass when using the command. Here are some examples.

 Checking the status of a user’s password is a useful tool for system


administrators when it comes to audits and housekeeping. Here our test
account, Tom, is audited.

 Open a terminal and run the command with the -S switch. This will
show the status of the account.

$ sudo passwd -S tom

 The output is formatted to show

The username
Password status Locked (L), No Password (NP), Password (P)
Date of last password change
Minimum password age
Maximum password age
Warning period (the number of days given to the user to change their
password before it expires)
Inactivity period (number of days after a password expires before it is
locked)

 If we wanted to set the number of days for Tom’s warning period to 14


days, we would use this command.

$ sudo passwd -w 14 tom

ASST. PROF. ZEENAT SULTANA

You might also like