Sie sind auf Seite 1von 3

Questions:

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 successf
ully)
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 /ho
me/user. Note: in order to do this you will need to be sure to be logged into th
e 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
[root@localhost]#logout
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 t
he account can no longer access the system. Create two new groups called 'lagrou
p1 and lagroup2'. Execute a command that will add the account 'jeff' to both tho
se 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 t
o 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
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 'j
eff', create a small text file with any content in the /root directory.
As the root user edit /etc/sudoers. If /etc/sudoers does not exist you need to i
nstall sudo "apt-get install sudo" or "yum install sudo".
You can use visudo to edit the /etc/sudoers file but for certification reasons y
ou 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
ALL=(ALL)
ALL
Make sure the "wheel" option is not commented out and exists %wheel
ALL=(
ALL)
NOPASSWD: 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. Yo
u can use that in place of wheel.
Log out of the system then log back in as jeff. As the jeff user type "sudo touc
h file /root/test" without quotes. This will create a file in the /root director
y which only root can do.
5. Create a new directory in root's home directory called 'filemaintenance'. Cha
nge to that directory and create three "dummy files", "file1", 'file2", and "fil

e3". 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 y
our home directory)
[root@localhost]# cd filemaintenance; touch file1; touch file2; touch file3 (cre
ate three files in your home directory)
[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' direc
tory 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 y
our system as root. List the last 10 lines of the appropriate log file on the sy
stem that will show those failed login attempts.
If logged in then logout and attempt to login to the system with the "wrong" pas
sword 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 liste
d 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 c
onfiguration file called 'ld.so.conf' and display its location and path. List th
e contents of that file piped to a second file called 'ld.so.conf.out' in your h
ome directory.
Use locate to find the file.
[root@localhost]# updatedb - if the command is not found then apt-get install l
ocate or yum install locate
[root@localhost]# locate ld.so.conf
[root@localhost]# cat ld.so.conf > ~/ld.so.conf.lab
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]#
~/;
[root@localhost]#
[root@localhost]#
[root@localhost]#
[root@localhost]#

cp /etc/hosts ~/; cp /var/log/messages ~/; cp /usr/bin/whoami


cd ~/
chmod 700 hosts
chmod 655 messages
chmod 111 whoami

10. Change the owner of all the files above to be owned by the user you are logg
ed 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 d
irectory 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 mont
h
*/3 0 1 * * ls /home > ~/cronoutput.out
14. On a Ubuntu/Debian server execute the command to prepare your system for pac
kage 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 a
ppropriate 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 sys
tem. Once that is complete, using the information gathered in Lab 1, install the
apache web server. When executing the installation, pass the appropriate parame
ter to the command line so you are not asked to confirm installation.
[root@localhost]# apt-get upgrade
[root@localhost]# apt-get install apache2 -y

Das könnte Ihnen auch gefallen