CT320: Admin                
The purpose of this assignment is to learn (or review) some of the standard
system administration functions on a Linux system, including account
administration, process control, and periodic processes. Use the script
command to capture the output of all commands in R2.log, for submission at
the end of the recitation.
                
Part 0 — How sudo and su work                
sudo and su don’t really “change” your current user id.
They run another instance of bash, called a sub-shell,
with the permissions that you asked for. To stop having those
permissions, type “exit” to terminate the shell, and you’ll go
back to your previous shell with the previous permissions.
                
Use the id command to find out what user you are, at any time.
                
Part 1 — Account Administration                
- Become the root user with
sudo -s - Use
groupaddto define presidents, governors, mayors, and senators groups. - Record the current GID for senators.
- Use
groupmodto change the GID for senators. - Use
groupmodto restore the GID for senators. - Use
groupdelto delete the senators group. - Use grep to search
/etc/groupfor group names and GIDs. - Use
useraddto add users with the following attributes:
| User Name | Home Directory | Password | Shell | Primary Group | Secondary Group |
|---|---|---|---|---|---|
| taft | /home/taft | william | /bin/bash | users | presidents |
| wilson | /home/wilson | woodrow | /bin/bash | users | presidents |
| lincoln | /home/lincoln | abe | /bin/bash | users | presidents |
| adams | /home/adams | john | /bin/sh | users | presidents |
| grant | /home/grant | ulysses | /bin/sh | users | presidents |
- Login to the lincoln account and verify that the shell is
/bin/bash. - Use
usermodto change the shell to/bin/shfor lincoln. - Login to the lincoln account and verify that the shell has changed
to
/bin/sh. - Use
sudoand passwd to change the password for grant. - Stop being root.
- Use
su grantto login to the grant account.- Try the old password, to prove that it doesn’t work.
- Use the new password to log in.
- Go back to being root.
- Use
userdelto delete all the accounts that you added.
Part 2 — Process Control                
- Stop being root. Do everything else as user ct320.
- In another window:
- look at the manpage for ps.
- List the processes using
pswith the-e,-foptions. - List only the processes owned by root.
Use
psonly—nogrepor other filtering commands. - List the process tree using the pstree command.
- In another window:
- look at the manpage for the top command.
- list the processes using
top. - rerun
topwith half-second between screen updates. - rerun
toponly with your processes.
- Launch a gedit session and find its PID using
psand the-Coption.- If
geditisn’t installed, then install it.
- If
- Kill the
geditsession using the kill command with the SIGKILL signal.
Part 3 — Periodic Processes                
- In another window:
- Look at the manpage for
crontab:-eto edit,-lto list,-rto remove.
- Look at the manpage for
- Create a crontab file using crontab commands with the following attributes:
- Runs every minute, every weekday, every month, etc.
- Executes find
-printfrom your home directory intoR2.cron.
- Verify that the crontab is executing:
grep -i cron /var/log/syslog - Write a bash script called
R2.scriptthat executesls -lin your home directory. - The script should log results to a file called
R2.cronin your home directory. - The script should log the date and time each time it runs.
- Remove the original crontab entry and substitute a new one with the script.
- Have the script run with the same period as the previous crontab.
- Verify that the crontab is executing correctly by examining
R2.cron. - Use cat to list
R2.scriptandR2.cronintoR2.log.
Part 4 — Credit                
- Terminate the
scriptcommand with control-D. - Edit your output to have only the relevant commands, filtering out all extraneous commands and output.
- Show it to the TA
- After the TA verifies things, delete the cron script, and remove
R2.*.