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
groupadd
to define presidents, governors, mayors, and senators groups.
- Record the current GID for senators.
- Use
groupmod
to change the GID for senators.
- Use
groupmod
to restore the GID for senators.
- Use
groupdel
to delete the senators group.
- Use grep to search
/etc/group
for group names and GIDs.
- Use
useradd
to 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
usermod
to change the shell to /bin/sh
for lincoln.
- Login to the lincoln account and verify that the shell has changed
to
/bin/sh
.
- Use
sudo
and passwd to change the password for grant.
- Stop being root.
- Use
su grant
to 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
userdel
to 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
ps
with the -e
, -f
options.
- List only the processes owned by root.
Use
ps
only—no grep
or 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
top
with half-second between screen updates.
- rerun
top
only with your processes.
- Launch a gedit session and find its PID using
ps
and the -C
option.
- If
gedit
isn’t installed, then install it.
- Kill the
gedit
session using the kill command with the SIGKILL signal.
Part 3 — Periodic Processes
- In another window:
- Look at the manpage for
crontab
:
-e
to edit, -l
to list, -r
to remove.
- Create a crontab file using crontab commands with the following attributes:
- Runs every minute, every weekday, every month, etc.
- Executes find
-print
from your home directory into R2.cron
.
- Verify that the crontab is executing:
grep -i cron /var/log/syslog
- Write a bash script called
R2.script
that executes ls -l
in your home directory.
- The script should log results to a file called
R2.cron
in 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.script
and R2.cron
into R2.log
.
Part 4 — Credit
- Terminate the
script
command 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.*
.