In this lab, we will learn, first-hand, the fundamentals of navigatingand using the UNIX operating system. Read through and follow theexercises 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 chapternumber when you write them. For example the command ls is oftenwritten 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 arethey in?
pwd - print working directoryQuestion 4. What command-line option is required to list "dot"files using "ls"?
cd - change directory
more (or less) - page-at-a-time display of files
cat - prints a file to the screen
ls - list 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 iddid 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" UNIXuser.
Question 18. Create a UNIX command line which answers the questionof how many users are listed in the file /etc/passwd.
The last field in thepassword table is the shell that the user uses.
Question 19. Create a UNIX command line that answersthe question, how many users use the plain shell (sh).
a. a*.cQuestion 2. Examine the filegrepme.txt (save it from http://webhost.lclark.edu/jmache/sec07/grepme.txt, one way is typing "curl http://webhost.lclark.edu/jmache/sec/grepme.txt > 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 #).How many lines of lines of output did you get?b. a[bcd]*([ef]*|[gh]+)ij
c. a?b*c+$
d. [ab]*[^cd]+ef?.*
Question 3. Create a grep command that prints out all lineswhose first entry is "nisplus", i.e., "nisplus" appears after the colon.How many lines of lines of output did you get?
Question 4. Create a "find" command that starts your homedirectory and prints out the names of all the files that have been changedin less than 3 days.
Question 5. Type "chmod 444 my.info". Create a "find"command that starts at the current directory and prints out all files thatthe owner (i.e. you) doesn't have write access to.
Question 6. Create a "find" command that starts in yourhome directory and finds all "regular" files and counts the number of linesin each of them. Hint: Use the "-exec" option.
Question 7. You suspect someone tried to break into thesystem in September. You want to find all the users thatloggedin that month. The last(1) command prints out a list of theall the users that have logged-in in the last few months. Create acommand that prints out a sorted list of users that logged-in inSeptember. You may want to use the commands sort(1), cut(1) and uniq(1).
X-tra Credit Question. Write a command sequence that prints all theusernames whose first part of GCOS/ real name (field 5) contains no lower-case letters (i.e. is all upper case). Use cat /etc/passwd to get access to user information.