In this lab, we will learn, first-hand, the fundamentals of navigating and using the UNIX operating system. Read through and follow the exercises below.
If you know the command you want to read about, simply type
man command-nameIf you want to search the man pages index by keyword, type
man -k keywordA common convention for writing about UNIX commands is to include the chapter number when you write them. For example the command ls is often written ls(1) since it lives in chapter 1.
Man pages are written according to some conventions:
You can quit looking at a man page by typing "q".
Question 2. What are the standard sections of a man page? Read a few man pages so you can briefly describe the purpose of each section.
Question 3. Find all the man pages that mention the word "calendar". What man pages mention "calendar" and what chapters are they in?
pwd - print working directoryQuestion 4. What command-line option is required to list "hidden" files using "ls"?
cat - prints a file to the screen
ls - list files
cd - change directory
more, less - page-at-a-time display of files
wc - count words, lines, and characters
head - display the top lines of input
tail - display the bottom lines of input
mv - moves/renames a file
cp - copies a file
rm - removes a file
mkdir - makes a directory
rmdir - removes a directory (must be empty)
Question 10. *.c
Question 11. ??c.d.e??
Question 12. a*.c*d
Question 13. [ab]*cd?
Question 14. What job number and process id did emacs get?
Kill the process using the "kill" command. Type jobs.
Question 15. What did kill report when you ran it?
Question 17. What does the "-1" (one) option mean for ls?
Use the cat command to view the file /etc/passwd. /etc/passwd normally contains entries for each "standard" UNIX user.
Question 18. Create a UNIX command line which answers the question of how many users are listed in the file /etc/passwd.
The last field in the password table is the shell that the user uses.
Question 19. Create a UNIX command line that answers the question, how many users use the Bourne-Again Shell (bash).
There are N users.Where N is replaced by the actual number of people that can use the lab. Use "cat /etc/passwd" to get a full list of all users.
a. a*.cQuestion 2. Examine the file ~jmache/sec/grepme.txt. Create a grep command that prints out all lines that are not comments (i.e., print all lines that do not begin with a #).b. a[bcd]*([ef]*|[gh]+)ij
c. a?b*c+$
d. [ab]*[^cd]+ef?.*
Question 3. Create a grep command that prints out all lines whose first entry is "nisplus", i.e., "nisplus" appears after the colon.
Question 4. Create a "find" command that starts your home directory and prints out the names of all the files that haven't been changed in at least 60 days.
Question 5. Type "chmod 444 my.info". Create a "find" command that starts at the current directory and prints out all files that the owner (i.e. you) doesn't have write access to.
Question 6. Create a "find" command that starts in your home directory and finds all "regular" files and counts the number of lines in each of them. Hint: Use the "-exec" option.
Uncompress the archive using the gunzip(1) command.
List the contents of the archive with the '-t' flag of tar(1).
Question 7. What files are in the archive?
Extract the files from the archive with the '-x' flag of tar.
Question 8. Edit the file "gv" from the archive and add your name to the top. Save and print out the file "gv" .
Question 10. You suspect someone tried to break into the
system on September 5. You want to find all the users that
logged
in that day. The last(1) command prints out a list of the
all the users that have logged in in the last few days. Create a
command that prints out a sorted list of users that logged in on
September 5. You'll need the sort(1) command too.