Lecture_02
Lecture_02
⚫ The who command will give you information about who is logged on the system.
⚫ With who am i the who command will display only the line pointing to your current
session
⚫ The w command shows you who is logged on and what they are doing
⚫ The id command will give you your user id, primary group id, and a list of the groups that
you belong to
− To become another user and also get the target user's environment, issue the su - command followed
by the target username.
Introduction to ROOT account
⚫ Imagine if you were the head Linux administrator at ABC Organization, and the only way to allow
users to perform admin tasks was to give them all the root password. What would happen if one
of those users were to leave the company?
⚫ You wouldn't want that person to still have the ability to log in to the systems, so you'd have to
change the password and distribute the new one to all of the other users. And what if you just
want users to have admin privileges only for certain tasks, instead of having full root privileges?
⚫ What we need is a mechanism that allows users to perform administrative tasks without incurring
the risk of having them always log on as the root user, and that would also allow users to have
only the admin privileges they really need to perform a certain job. In Linux and Unix,
⚫ Assign certain users full administrative privileges, while assigning other users only the privileges
they need to perform tasks that are directly related to their respective jobs.
⚫ Allow users to perform administrative tasks by entering their own normal user passwords so
that you don't have to distribute the root password to everybody and his brother.
⚫ Make it harder for intruders to break into your systems. If you implement sudo and disable the
root user account, would-be intruders won't know which account to attack because they won't
know which one has admin privileges.
⚫ Create sudo policies that you can deploy across an entire enterprise network, even if that
network has a mix of Unix, BSD, and Linux machines.
⚫ Improve your auditing capabilities because you'll be able to see what users are doing with their
admin privileges.
User Management
1. Sudo su
2. head -2 /etc/passwd
3. tail -2 /etc/passwd
5. tail -2 /etc/passwd
7. tail -2 /etc/passwd
Exercise (continue)
2. tail -2 /etc/passwd
4. tail -2 /etc/passwd
The easiest way to create a home directory is to supply the -m option with
useradd
A less easy way is to create a home directory manually with mkdir which also
requires setting the owner and the permissions on the directory with chmod
and chown
▪ mkdir /home/brown
▪ chown brown:brown /home/brown
▪ chmod 700 /home/brown
▪ ls - ld /home/brown/
▪ To delete home directory
▪ userdel -r brown
Chmod command
Permissions
▪ Read(r) – 4
▪ write(w) – 2
▪ execute(x) – 1
Access class
▪ Owner /user
▪ Group
▪ Others
For example
chmod 744 filename -
/etc/skel/
The /etc/skel/ directory contains some (usually hidden) files that contain
profile settings and default values for applications.
/etc/skel/ serves as a default home directory and as a default user profile
When using useradd the -m option, the /etc/skel/ directory is copied to
the newly created home directory.
Create a file named welcome.txt and make sure every new user will see
this file in their home directory.
▪ echo Hello > /etc/skel/welcome.txt
Run as root user
▪ ls - la /etc/skel/
/etc/shadow
Command Aliases
The SOFTWARE command alias can be assign to the SOFTWAREADMINS user alias:
SOFTWAREADMINS ALL=(ALL) SOFTWARE
Vicky and Cleopatra, as members of the SOFTWAREADMINS user alias, can now run the
dpkg, update, and apt commands with root privileges