1st year of the first cycle Higher School of Computer Science
Course : Introduction to operating system 1 Sidi Bel Abbes (ESI-SBA)
Lab assignment N°7
Process management and Intro-To-Linux administration
Module 1 :
1. Use the script utility to capture your session.
Solution.
script Lab7
2. Launch ps command with no option and with these options : -u, -f, -l, -e
Solution.
ps ; ps -u ; ps -f ; ps -l ; ps -e
3. Launch a data-intensive task (i.e., a command that holds up for such a long time) in background.
Look for its PID using ps command, and then stop suspend the process using kill command.
Solution.
cat &
ps
kill -9 2831
ps
4. Launch another data-intensive task in background. Suspend the process using killall command.
Solution.
cat &
ps
killall -9 cat
ps
5. Launch some data-intensive tasks in background. Quit your terminal, check to see what
processes are running using ps command.
Solution.
gedit
Ctrl-C // we observe that the process gedit terminates
gedit &
quit the terminal (exit) // we observe that also the process gedit terminates (parent-child
relationship).
6. Repeat the previous question, however use nohup command.
Solution.
nohup gedit &
quit the terminal (exit) // we observe that also the process gedit doesn’t terminate as we
detach the relationship between parent and child.
7. Launch a data-intensive task in foreground. Hit ctrl-z key sequence to suspend the process, and
then use bg and fg commands to switch between background and foreground process-running.
Solution.
cat &
fg
Ctrl-Z
fg
8. Look for a runaway processes using top command.
Solution.
top
9. Exit the script.
Solution.
exit
Module 2 :
1. Start script again and append to the existing output file of step 9.
Solution.
script -a lab7
2. Create a new user account with the useradd command.
Solution.
sudo adduser test-user
3. Set and reset a user’s password with the passwd command.
Solution.
sudo passwd test-user
4. Make changes to the created user account with the usermod command.
Solution.
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 to
change their attributes like password, login or home directory, …etc. In order to do that we use
the usermod command. The user information of the user is stored in the following files :
/etc/passwd ; /etc/shaow ; /etc/gshadow ; /etc/group ; /etc/login.defs
e.g.,
sudo usermod -c “This is a test-user” test-user // this will add a comment about the user or a
short description related to the user.
sudo usermod -d /home/test test-user // this will change the home directory of the test-user
sudo usermod -e 2023-02-01 test-user // to change the expiry data of user
sudo usermod -g grouptest test-user // to change the group of the user (e.g., from GroupA to
GroupB)
sudo usermod –l test-account test-user // to change the user login
sudo usermod –p test-passwd test-user // to set an unecrypted passwd for test-user
sudo usermod -L test-user // to lock the user
sudo usermod -U test-user // to unlock the user
5. Create a new group account using groupadd command.
Solution.
sudo groupadd test-group
6. Add the new created user to the new created group.
Solution.
sudo adduser test-user test-group
7. Delete both created user and group.
Solution.
sudo userdel test-user
sudo groupdell test-group
8. Switch off your machine from your terminal.
Solution.
sudo shutdown –P now
9. Exit out of script.
Solution.
exit