You are on page 1of 4

Linux Academy
Live Show and Giveaway! (/cp/live/info) Help & Questions meyerjp

Return to Syllabus (/cp/modules/view/id/1)

Exercise: Introduction To The Linux Server


Note: This exercise can be completed on a lab server. However, some of the solutions
are specific to Debian/Ubuntu servers.
1. Start your Linux Academy server and login. Create two users, 'john and jeff'. Set their passwords and
login as both.
[root@localhost]# useradd -m jeff && useradd -m john
[root@localhost]# passwd jeff && passwd john
(&& means only perform the following command if the first one completed successfully)
2. Change the root password on your system to 'linuxtest'. Log out and log back in as root. Remove the
user 'user' from the system, including the removal of /home/user. Note: in order to do this you will need to
be sure to be logged into the system with your new user account. Do not use the user "user" or you will not
be able to remove the user account.
Type su to change the user to root
[root@localhost]# passwd
log back in to the root user by typing su on the command line
root@localhost]# userdel -r user (this will remove the user, user, and the users home directory)
3. Lock the user account added previously called 'john' and log out and verify the account can no longer
access the system. Create two new groups called 'lagroup1 and lagroup2'. Execute a command that will
add the account 'jeff' to both those groups. Use ONE command to add that account to both groups.
Open a new terminal/putty screen and connect to your server. Login as your user and then "su" into the
root user. You will now have two terminals, one for your root user to perform actions and one to test locking
users out.
From your root terminal type: passwd -l john. From your other terminal attempt to login to the system with
the user "john". You will notice it will not allow it. Now from your root terminal type "passwd -u john" and try
to login again. You will notice login is now allowed.
[groot@localhost]#groupadd lagroup1 && groupadd lagroup2
[root@localhost]#usermod -aG lagroup1,lagroup2 jeff

1 of 4

11/10/2015 20:44

Linux Academy

4. Add the user 'jeff' to the appropriate place so that user has the ability to execute commands with super
user/root privileges. While logged in as the user 'jeff', create a small text file with any content in the /root
As the root user edit /etc/sudoers. If /etc/sudoers does not exist you need to install sudo "apt-get install
sudo" or "yum install sudo".
You can use visudo to edit the /etc/sudoers file but for certification reasons you should know how to edit
the file manually.
Add jeff to the sudoers file, you can do this one of two ways.
Add the user directly in the file jeff



Make sure the "wheel" option is not commented out and exists %wheel
ALL if the wheel option is available we would then add jeff to the wheel group (% represents "group") at the
command line type "usermod -aG wheel jeff".
Debian/Ubuntu users might notice "sudo" and not "wheel" is the default group. You can use that in place of
Log out of the system then log back in as jeff. As the jeff user type "sudo touch file /root/test" without
quotes. This will create a file in the /root directory which only root can do.
5. Create a new directory in root's home directory called 'filemaintenance'. Change to that directory and
create three "dummy files", "file1", 'file2", and "file3". Move back to the parent directory (root's home
directory) and then copy the files located in filemaintenance to your home directory.
[root@localhost]# cd; mkdir filemaintenance (just typing cd will change you to your home directory)
[root@localhost]# cd filemaintenance; touch file1; touch file2; touch file3 (create three files in your home
[root@localhost]# cd ..
[root@localhost]# cp filemaintenance/* . NOTE THE . it is part of the statement and means "current
directory" (This command will copy all the files, directories and sub directories in /home/youruser
/filemaintenance directory into your /home/youruser directory (the filemaintenance parent directory)
6. Change back to your home directory root. Move the new 'filemaintenance' directory and all its contents
into another directory called 'movedfiles'
[root@localhost]# cd
[root@localhost]# mkdir movedfiles
[root@localhost]# mv filemaintenance/ movedfiles/
7. Log out of your system. Attempt to log in to the system three times using the recently locked user
account 'john'. After the third failed attempt, log into your system as root. List the last 10 lines of the
appropriate log file on the system that will show those failed login attempts.
If logged in then logout and attempt to login to the system with the "wrong" password three times
Log back into the system. Some systems use different auth logs now depending on your distribution and
version distribution it will be one of the log files listed below
tail /var/log/auth.log OR tail /var/log/syslog OR tail /var/log/secure
8. Logged in as a user with super user privileges, search the filesystem for a configuration file called
'' and display its location and path. List the contents of that file piped to a second file called
'' in your home directory.
Use locate to find the file.
[root@localhost]# updatedb - if the command is not found then apt-get install locate or yum install locate

2 of 4

11/10/2015 20:44

Linux Academy

[root@localhost]# locate

[root@localhost]# cat > ~/
9. Copy the following files into root's home directory:
a. /etc/hosts
b. /var/log/messages
c. /usr/bin/whoami
Change the permissions of each file as follows:
a. hosts - only your user id can read/write/execute, no group or world access
b. messages - user account can read/write, group and everyone can read/execute
c. whoami - everyone can execute, no other permissions
[root@localhost]# cp /etc/hosts ~/; cp /var/log/messages ~/; cp /usr/bin/whoami ~/;
[root@localhost]# cd ~/
[root@localhost]# chmod 700 hosts
[root@localhost]# chmod 655 messages
[root@localhost]# chmod 111 whoami
10. Change the owner of all the files above to be owned by the user you are logged in as.
[root@localhost]# chown username.username -R /home/username put the user you're logged in as in place
of username
[root@localhost]# ls -al to verify the changes have been made
11. Login as root to your system. Create a cron job that lists all users in the home directory every day at
noon and pipes that listing to a file in your home directory called 'cronoutput.out'.
[root@linuxacademy] crontab -e
Enter the following entry: 0 12 * * * ls /home > ~/cronoutput.out
12. Create another cron job that runs at 15 minutes after every hour
15 * * * * ls /home > ~/cronoutput.out
13. Create another cron job that runs every 3 minutes on the 1st day of the month
*/3 0 1 * * ls /home > ~/cronoutput.out
14. On a Ubuntu/Debian server execute the command to prepare your system for package installations
using apt-get. Search available packages and descriptions for any reference to the 'apache' web server.
Pipe those results to a file in the appropriate lab directory.
[root@localhost]# apt-get update
[root@localhost]# apt-cache search apache > ~/search.out
15. On an Ubuntu/Debian server install all available system updates for your system. Once that is
complete, using the information gathered in Lab 1, install the apache web server. When executing the
installation, pass the appropriate parameter to the command line so you are not asked to confirm
[root@localhost]# apt-get upgrade
[root@localhost]# apt-get install apache2 -y

3 of 4

11/10/2015 20:44

Linux Academy


4 of 4

Mark as Completed

11/10/2015 20:44