You are on page 1of 6

HND2

Network and Security

Linux Network Administration: NWS


1_PRACTICAL

Lecturer : Mavel TATKEU Email : maveltatkeu@gmail.com

Page 1 / 6
Linux: Exercises

1- Directories
These are some exercises to help you get the feel.
• Enter the command cd blah
-> What happens?
• Enter the command cd ..
Mind the space between "cd" and ".."! Use the pwd command.
-> What happens?
• List the directory contents with the ls command.
-> What do you see?
-> What do you think these are?
-> Check using the pwd command.
• Enter the cd command.
-> What happens?
• Repeat step 2 two times.
-> What happens?
• Display the content of this directory.
• Try the command cd root
-> What happens?
-> To which directories do you have access?
• Repeat step 4.
Do you know another possibility to get where you are now?
2- Files
• Change directory to / and then to etc. Type ls; if the output is longer than your screen, make the
window longer, or try Shift+PageUp and Shift+PageDown.
The file inittab contains the answer to the first question in this list. Try the file command on it.
-> The file type of my inittab is .....
• Use the command cat inittab and read the file.
-> What is the default mode of your computer?
• Return to your home directory using the cd command.
• Enter the command file.
-> Does this help to find the meaning of “.”?
• Can you look at "." using the cat command?
• Display help for the cat program, using the --help option. Use the option for numbering of output
lines to count how many users are listed in the file /etc/passwd.
3- Getting help
• Read man intro
• Read man ls
Page 2 / 6
• Read info passwd
• Enter the apropos pwd command.
• Try man or info on cd.
-> How would you find out more about cd?
• Read ls --help and try it out.
4- Paths
• Display your search path.
• Export a senseless path by entering, for instance, export PATH=blah and try listing directory content.
• What is the path to your home directory? How would another user reach your home directory starting
from his own home directory, using a relative path?
• Go to the tmp directory in /var.
• Now go to share in /usr using only one command. Change to doc. What is your present working
directory?
5- Tour of the system
• Change to the /proc directory.
• What CPU(s) is the system running on?
• How much RAM does it currently use?
• How much swap space do you have?
• What drivers are loaded?
• How many hours has the system been running?
• Which filesystems are known by your system?
• Change to /etc/rc.d | /etc/init.d | /etc/runlevels and choose the directory appropriate for your run level.
• What services should be running in this level?
• Which services run in graphical mode that don't run in text mode?
• Change to /etc
• How long does the system keep the log file in which user logins are monitored?
• Which release are you running?
• Are there any issues or messages of the day?
• How many users are defined on your system? Don't count them, let the computer do it for you!
• How many groups?
• Where is the time zone information kept?
• Are the HOWTOs installed on your system?
• Change to /usr/share/doc.
• Name three programs that come with the GNU coreutils package.
• Which version of bash is installed on this system?
6- Manipulating files
• Create a new directory in your home directory.
• Can you move this directory to the same level as your home directory?
• Copy all XPM files from /usr/share/pixmaps to the new directory. What does XPM mean?
• List the files in reverse alphabetical order.
• Change to your home directory. Create a new directory and copy all the files of the /etc directory
Page 3 / 6
into it. Make sure that you also copy the files and directories which are in the subdirectories of /etc!
(recursive copy)
• Change into the new directory and make a directory for files starting with an upper case character and
one for files starting with a lower case character. Move all the files to the appropriate directories. Use
as few commands as possible.
• Remove the remaining files.
• Delete the directory and its entire content using a single command.
• Use grep to find out which script starts the Font Server in the graphical run level.
• Where is the sendmail server program?
• Make a symbolic link in your home directory to /var/tmp. Check that it really works.
• Make another symbolic link in your home directory to this link. Check that it works. Remove the first
link and list directory content. What happened to the second link?
7- File permissions
• Can you change file permissions on /home?
• What is your standard file creation mode?
• Change ownership of /etc to your own user and group.
• Change file permissions of ~/.bashrc so that only you and your primary group can read it.
• Issue the command locate root. Do you notice anything special?
• Make a symbolic link to /root. Can it be used?

8- Filters
These exercises give more examples on how to combine commands. The main goal is to try and use the
Enter key as little as possible.
All exercises are done using a normal user ID, so as to generate some errors. While you're at it, don't forget
to read those man pages!
• Use the cut command on the output of a long directory listing in order to display only the file
permissions. Then pipe this output to sort and uniq to filter out any double lines. Then use the wc to count
the different permission types in this directory.
• Put the output of date in a file. Append the output of ls to this file. Send this file to your local mailbox
(don't specify anything <@domain>, just the user name will do). When using Bash, you will see a new
mail notice upon success.
• List the devices in /dev which are currently used by your UID. Pipe through less to view them properly.
• Issue the following commands as a non-privileged user. Determine standard input, output and error for
each command.
• cat nonexistentfile
• file /sbin/ifconfig
• grep root /etc/passwd /etc/nofiles > grepresults
• /etc/init.d/sshd start > /var/tmp/output
• /etc/init.d/crond start > /var/tmp/output 2>&1
Now check your results by issuing the commands again, now redirecting standardoutput to the file /
var/tmp/output and standard error to the file /var/tmp/error.
Page 4 / 6
• How many processes are you currently running?
• How many invisible files are in your home directory?
• Use locate to find documentation about the kernel.
• Find out which file contains the following entry:
root:x:0:0:root:/root:/bin/bash
And this one:
system: root
• See what happens upon issuing this command:
> time; date >> time; cat < time
• What command would you use to check which script in /etc/init.d starts a given process?
9- Preocesses
• Run top in one terminal while you do the exercises in another.
• Run the ps command.
• Read the man pages to find out how to display all your processes.
• Run the command find /. What effect does it have on system load? Stop this command.
• In graphical mode, start the xclock program in the foreground. Then let it run in the background. Stop
the program using the kill command.
• Run the xcalc directly in the background, so that the prompt of the issuing terminal is released.
• What does kill -9 -1 do?
• Open two terminals or terminal windows again and use write to send a message from one to the other.
• Issue the dmesg command. What does it tell?
• How long does it take to execute ls in the current directory?
• Based on process entries in /proc, owned by your UID, how would you work to find out which processes
these actually represent?
• How long has your system been running?
• Which is your current TTY?
• Name 3 processes that couldn't have had init as an initial parent.
• Name 3 commands which use SUID mode. Explain why this is so.
• Name the commands that are generally causing the highest load on your system.
10- Booting, init etc.
• Can you reboot the system as a normal user? Why is that?
• According to your current run level, name the steps that are taken during shutdown.
• How do you change the system run level? Switch from your default run level to run level 1 and vice
versa.
• Make a list of all the services and daemons that are started up when your system has booted.
• Which kernel is currently load at startup?
• Suppose you have to start some exotic server at boot time. Up until now, you logged in after booting the
system and started this server manually using a script named deliver_pizza in your home directory.
What do you have to do in order to have the service start up automatically in run level 4, which you
defined for this purpose only?

Page 5 / 6
11- Scheduling
• Use sleep to create a reminder that your pasta is ready in ten minutes.
• Create an at job that copies all files in your home directory to /var/tmp within half an hour. You
may want to create a sub-directory in /var/tmp.
• Make a cronjob that does this task every Monday to Friday during lunch.
• Check that it works.
• Make a mistake in the crontab entry, like issuing the nonexistent command coppy instead of cp. What
happens upon execution of the task?

Page 6 / 6

You might also like