Home Engineering Computer Science Linux/UNIX Operating System Linux/UNIX Operating System Homework





Below you will find homework examples pertaining to UNIX/Linux. These homework examples include topics such as operating environments, root, utilities, commands, permissions, vi, and more. All of these homework examples are consistent with what you might find in any UNIX/Linux college course.

Note: If you are having trouble viewing this page or would prefer to view this information in a document viewer Click Here!


NOTE: All Question/Answer Sets That Include Page Numbers Can Be Referenced In The Book: Introduction to Unix and Linux Author: John Muster Publisher: McGraw/Hill ISBN:978-0-07-222796-3

1. Describe the kinds of environments that use UNIX/Linux extensively and environments that use it much less.

The kinds of environments that use UNIX/Linux are extensive:

Internet – Internet servers and fundamental computing structures.

Modern Films – Generated special effects

Stock and Bond Markets – Sales transactions.

ATMs and Banking – Communication networks.

Electronic Games – Development.

Military – Communications, programs, smart devices, and critical data infrastructures.

Governments – Tax liens, records, and communications storage.

Universities – Records, research, communication, development, and publications.

Corporations – Data, research, file serving for desktops, e-mail, and publishing.

Utilities – Electricity production and delivery grid.

The kinds of environments that use UNIX/Linux are much less extensive:

Desktop Computer Systems – Word processing, etc.

2. Why should users log on as a regular user and not as the user root?

The user named root is granted extensive powers need to administer the system. Because this account carries substantial authority over system events and operations, you can hurt or destroy a system by issuing the wrong commands. It is dangerous to log on using the root account.

3. Try to log in but provide a space in the middle of your login name. What error message results and when is it displayed?

The error message that results is “Login Failed.” This error message appears immediately after pressing the enter key.

4. Try to log in putting a space in the password. What error message results?

Again, the “Login Failed” error message results when a space is placed in the password. The error message also occurs after pressing the enter key.

5. How do you exit from a terminal window or character based terminal?

In a terminal window or character based terminal you can exit in a number of ways. For example, you can choose the Session Menu in the terminal window and choose Quit or you can type exit at the command prompt and press enter. However, to exit a session in a graphical environment select Log Out/Leave from the Applications Menu.

Self Test 1 – pg.27

  1. the who utility
  2. You are asking the shell to execute the cal utility with an argument of 2004. The result is a display of the 2004 calendar.
  3. The ps command list the processes you are currently running.
  4. utility argument argument
  5. No, this will not work because a space is required between the utility and the option.
  6. The shell waits for the child process to complete its execution.

Self Test 2 – pg. 43

  1. The !!, r, or up arrow will tell the shell to repeat the last command.
  2. A command of ls > myfile will create a new file named myfile that contains a list of the contents of the current directory.
  3. ls | wc will list the number of file in a current directory.
  4. cal (month) (year) > friend-bday will create a file named friend-bday containing the month and year of their birth.
  5. date >> friend-bday will add today's date to the end of the friend-bday file.
  6. In tcsh or csh shells alias cl clear will allow cl to run the clear command.
  7. In the bash or ksh shell the command alias cl=clear will allow the clear command to run when cl is entered.
  8. utility argument argument | utility > file is how the shell would interpret the tokens of this command line.
  9. A. Alias - creates alternate names for commands. B. more file1 file2 – Shows the contents of file1 then file2. C. wc -l file1 file2 – Shows the number of lines in file1 and file 2. D. !w – Issues the last command beginning with the letter w. E. r 12 – reissues the twelfth command in the history list.
  10. The shell will look for all words in the dictionary that begin with psy and will pass the output to the wc utility which will count all of the words and pass the output to the file psy-words which is created in interpreting the look psy | wc -w > psy-words command.. The result is the number of words that begin with psy in the dictionary (327).

Self Test 3 – pg. 64

  1. The command head -5 /etc/passwd > password_info will enter the first five lines of the /etc/passwd file in the new file password_info.
  2. The pwd command will output your current location in the system.
  3. The name of the directory at the top of the file system is called root or /.
  4. To make a new directory named New_dir in the subdirectory of your home directory issue the command md New_dir. To verify the success of this task issue the ls command.
  5. To copy the file old_file into the directory New_dir issue the command cp old_file New_dir.
  6. The result of the command more /etc/passwd is a list of the contents of the passwd file.
  7. The q command will end the more command and return you to your shell.
  8. The command mv junk treasure will change the name of the file junk to treasure.
  9. To copy file fA and fB from the current directory to a subdirectory named DirAA issue the comand cp fA fB DirAA.
  10. The command man man will display the manual entry for man.
  11. To search the man table of contents for all references to the word file issue the command man -k file | more.

Assignment – pg. 66

  1. C. Utility
  2. E. All of the above
  3. D. date >> junk
  4. ls /tmp > tmpfiles will create a file named tmpfile containing the contents of the /tmp directory.
  5. wc -l | ps will count the number of currently running system processes.
  6. In the bash shell, the command alias see=more will allow the more utility to be executed when see is typed.
  7. mkdir Ballroom will create a new directory named Ballroom.
  8. To list the contents of the Ballroom directory type ls Ballroom.

Project – pg. 67

  1. The commands issued to accomplish the three previous steps are:
  2. ls > ch2
  3. !!
  4. !258
  5. !m
  6. !! > ch2-hist
  7. !258 >> ch2-hist
  8. !m >> ch2-hist
  9. mkdir Backups
  10. cp users_on lost-days ch2 ch2-hist Backups
  11. There are 104 files in the /bin directory and the command ls -f /bin | wc will produce that result.

Self-Test 1 - pg. 90

1.

A.The contents of both files are read and sorted together.

B. Outputs the stats for each file then produces a total.

C. It returns to the shell prompt because no search string is indicated.

D. The output of the who utility is connected to the input of the sort utility and the resulting output is stored in the created file (abc).

E. The cat utility interprets each argument as a file to open, read, and write output. The cat utility reads all of the lines from the first file and writes to output then moves on to the next file and repeats the process. This process continues until the end of the last file is reached. The result is all three files spliced together.

2. sort -r | grep 0 /etc/passwd

3.

A. The string 'file1.'

B. Whatever the user has input prior to entering CTRL-D.

4. CTRL + ALT + F3

5. cat

Self-Test 2 - pg. 105

1.

A. All lines from the files in the current directory containing the string 'file1.'

B. The file would contain the user name and and home directory.

2.

A. The spell utility would examine file1 for misspelled words and list any misspelled words that are found.

B. The shell would open file1 and connect it to the input of the spell utility.

C. This would make the output of the cat utility the input of the the spell utility.

D. This command would look for and find the string 'Joan Heller' in a file named faculty.

E. The command would look for all instances of the string $USER in file1.

3. who | awk '{print $4}'

4. This command outputs the contents of the $PATH variable. The $PATH variable list all of the places where the shell looks to find Unix utilities.

Self-Test 3 - pg. 119

1. This command will advance the cursor to the next line and wait for user input. This happens because there is no argument for the cat utility to read.

2.

A. An output listing of the current users.

B. This command will output all instances of the home directory located in file1.

C. This command will create a list of all file beginning with the letter 'u' and place that list in file1.

D. This command will create a line with the characters 'u*' and place it in file1.

E. This command will output a listing of running processes.

F. The shell will read fileA and execute each line in fileA.

G. In the C shells this command will turn the noclobber variable on which will instruct the shell not to overwrite files.

H. In the Korn shells this command will output a list of currently set variables.

I. This command will make file2 an executable file.

3. To change the prompt in the C shells enter the command set prompt='Next' and in the Korn shells enter the command PS1='Next'.

4. Login : Password : UserID : GroupID : Information on the user : Home directory : Start-up program.

5. To instruct the shell not to accept CTRL-D as a signal to log off in the C shells enter the command set ignoreeof and in the Korn shells enter the command set -o ignoreeof.

Assignment - pg. 122

1.

A. -a

B. -l

C. -F

2. ls -a | wc -l

3. which ps

4. ls | grep f*

5.

A. As text.

4

B. As a file name.

C. As a search string.

6. cat file1 file2 file3 >> all

7.

A. A listing of all of the instances of the string 'Linux is fun' in the directory.

B. A sorted listing of user input placed in file4.

C. A listing of all of the instances of the login name in the password file.

D. The string '$PATH' preceding the contents of the $PATH variable.

E. A listing of all of the instances of the string '1 2 3' located in all file beginning with the letter 'f'.

F. This command will turn the EOF variable on.

8. CTRL-D completes the running process and then terminates while CTRL-C just terminates.

9.

A. Read (+r)

B. Execute (+x)

C. The shell process.

D. A child process.

Self Test 1 - pg. 147

1. left arrow or h

2. up arrow or k

3. Command mode

4. Command mode

5. /Admin

6. n

7. dd

8. x

9. I must place the cursor somewhere on the line that is to be deleted.

10. u

11. a

12. o

13. Append mode

14. ESC

15. :q!

16. :wq

17. Command mode

Self Test 2 - pg. 177

1. 3j

2. 7l

3. /wonderful heroes

4. ?time

5. w

6. 0 (zero)

7. $

8. ft

9. 8|

10. :set number

11. :15

12. G

13. :q

14. L

15. ''

16. CTRL-F

17. 7dd

18. The cursor will move down two characters and deletes three words to the right of the cursor.

19. D

20. dfH

21. I

22. a

23. O (capital letter 'O')

24. If the word open is typed while in command mode a line will be opened below the cursor and the characters 'p,' 'e,' and 'n' will be added.

25. A

Self Test 3 - pg. 200

1. The character under the cursor will be replaced with the character 'o' and the cursor will move back one character. Replaces the word Hat with the word Hot.

2. J

3. The editor goes into type-over mode and the letters 'qu' are typed over and replaced with the letters 'ed.' This replaces the word quit with the word edit.

4. R

5. cw

6. cc

7. C

8. dfH

9. :s/bill/tom/

10. 7yy

11. The p or P command paste whatever was yanked.

12. yfH

13. :w practice1

14. :5,30 w practice2

15. :5,30 w! drill

16.

line dd yy cc

word dw yw cw

To the end of line d$ y$ C$

To the 12th character df12 yf12 cf12

on the line

Line number d8G Y8G c8G

17. : set number

18. :set nonumber

Assignment - pg. 203

1. When just entering vi old-filename the editor is started in command mode and the following can be accomplished without leaving the current mode:

A. Delete lines

B. Go to line 32

C. Yank line 3 through 8 into memory

D. Put the lines from memory at a location in the file

F. Remove a word

2. Answers below are in order as questions appeared in the text:

G

3dd

y$

23x

cfH

:wq

$

fH

dfH

L

H

Homework Chapter 5

Self Test 1 - pg. 236

1. b

2. v

3. cut -c1-5 practice

4. grep 'z....' filename

5. grep -l Pat Lloyd *

6.

set=4

((424+79)/161)^15

7. grep Catherine Thamzin *

8. wc -wl practice users_on

9. cat -n section1 section2 section3 section4 > chapter

10. column empnames

Self Test 2 - pg. 268

1. sort junk1 -o junk1

2. sort +1 -2 +3 -4 employees

3.

A. -c

B. -l

C. -c

4. tr -d '!,.?"&$;*.()' < practice

5. who | sort | tr 'a-z' 'A-Z'

6. cat -n awards

7. sort -df people

8. sort +3 -4 +2 -3 /etc/passwd

9. diff students paid

10. who | tr 'a-z' 'A-Z'

Self Test 3 - pg. 286

1. awk -F: '{print $1, $2}' /etc/passwd

2. This chapter focused on replacing and deleting strings using sed. I have no idea how to use sed to output all lines of a file up to a particular string.

3.sed '^UCB/s/UCB/University of California/g alma_mater

4.head -20 passwd | awk '/$USER/ {print $1, $3, $6}' passwd

5. Wow! I have no clue what this command might be.

6. file README

Assignment - pg.289

1. All three command will have the same output. The output is a count of all characters, line, and words in fileAA.

2. SPACE

3. What is the result of each command?

cut -d: f1,4,6 /etc/password - The first, fourth, and sixth fields from the /etc/passwd file is displayed.

paste -d'\\' names.tmp numbers.tmp - This command will result in a backslash as the field separator in the two files.

grep -i bill * - This command will output all lines from all files in the home directory containing the string bill regardless of case.

grep '^j...k$' datafile - This command will output all of the instances of a pattern that begins with the letter j, has three characters, and ends with the letter K in datafile.

sort -f +2 -3 datafile - This command will sort the field after the second field separator and before the third field separator regardless of case.

man man - This command will display the manual page for the man command.

uniq -c datafile - This command will output all unique lines in the datafile with a number next to each unique line indicating how many time that line is in the sorted file.

ls -Fal -This command will produce a listing from the current directory of all files including dot or hidden files, all directories with a forward slash a the end of the name of each directory, and in long listing format.

sed '/operations/s/UNIX/Linux/g' history-file - This command will output only lines with the string operations and within those lines substitute the string UNIX with the string Linux globally from the history-file.

Self Test 1 - pg. 319

1. The output of this script will be the number of users logged on.

2. The output will be sent to the display.

3.

A. Identifies the users logged on.

B. Do not interpret as a new line.

C. Print the first field.

D. Input the output of the previous command to the uniq utility which outputs all unique lines.

E. Runs the wc utility.

F. Instructs the wc utility to count and display only the number of lines.

4. 3

Assignment - pg. 320

1. -F

2. chmod +x p.scri

3.

A. The result of this command is an output of nothing. ls -F / list all of the directories from the root directory with a slash. grep -v / rejects all of the lines with a slash. column outputs the previously piped commands in column form.

B. This command outputs the contents of textfile as one word to a line because each space is translated into a new line. tr ' ' '\n' runs the tr utility where the first argument consisting of a space is replaced by the second new line argument. < textfile redirects the output of textfile to the input of the tr utility which as previously explained replaces all spaces with new lines.

4. So the next line is not interpreted as a new line.

Self Test 1 – pg. 347

  1. mkdir Proposals
  2. cd Proposals
  3. cd
  4. pwd
  5. -F
  6. The Projects directory.
  7. Have the two files in different directories.
  8. Mv florence ~/Proposals
  9. The file named ideas name has changed to the name work.
  10. Ls -F cows

Self Test 2 – pg. 379

  1. In bash or ksh: cd $OLDPWD ; In tcsh: popd
  2. A. Any because it is an absolute path. B. Any because it is an absolute path. C. The Desk directory. D. The home directory.
  3. A. Not a directory error. B. Change to home directory. C. Not a directory error. D. The home directory of bill. E. The file bill in the home directory of bill. F. Not a directory error. G. Not a directory error.
  4. cd ~/Proposals/Education
  5. vi Proposals/mikekirby
  6. mkdir ~/Proposals/Rejected
  7. cp ~/selquist ~/Proposals/Education/selquist
  8. cd ..
  9. cd Marilyn
  10. cd ../Letters
  11. mv report7 ../report7
  12. cp * ..
  13. A. mkdir ~/Location/Junkyard B. mkdir ../Location/Junkyard C. mkdir /Home/$USER/Location/Junkyard
  14. The Contacts directory.
  15. Vi ~/Chris/Cats
  16. cp /Africa/rhino /Africa/elephant
  17. mv ~pjaddessi/Transportation/vans /tmp/cars

Self Test 3 – pg. 400

  1. mv eakins ~
  2. rmdir removes empty directories and rm -r removes all files and directories starting with the target.
  3. Mv ~/Projects/New-Projects/Bookproject ~/Projects/Old-Projects/Bookproject
  4. ln users_on ~/Projects/users_on

Assignment – pg. 402

  1. D
  2. rm -r
  3. E
  4. A. Change to Work directory. B. Copies 'manywords' to the current directory. C. Change to the parent directory. D. Search for 'bash' in /etc/passwd and place the output in a file names bash.pw E. Changes the directory name to Old. F. Copies all to Dir-B.
  5. Argument, Argument, Argument, Directory

Self Test 1 - pg. 447

1. Tokens are words on the command line which are often utilities, arguments, and files. One token ends and another begins through the use of special characters such as && , ; | and the like.

2. An error message stating 'cat no such file or directory.'

3. The junk1 is created as an empty file and an error (no datexxx command) is produced.

4. C shells - ! after redirection ; Korn - |

5. utility argument utility utility argument utility utility

6.

A. Places the job in the background.

B. Defines the path variable.

C. Tells exit error code of previous command.

D. Overwrites contents of filexx.

E. Asks if your sure you want to overwrite because of the -i option.

7. A 'can't overwrite file' error is produced.

8. 3

Self Test 2 - pg. 476

1. Counts the lines of files named 'file' ending with any characters including 237ACks.

2. C - set tuesday=8-5 ; Korn - tuesday=8-5

3. C - setenv OCT NOT PAID ; Korn - first, set OCT = NOT PAID then, export OCT

4. one

5. First, set -o vi then, set -o vi-tabcomplete.

6. grep friend monica*

7. Changes the prompt to included the current variable number, current location, and a %.

8. PS1=

9.

A. Unsets the AA variable.

B. Lists the set variables.

C. Creates an environmental variable in the Korn shell.

D. Shows the shells search path.

Assignment - pg. 478

1. lpr assign*

2. Utility Argument Utility Utility Utility Argument Utility Utility

3. Because there is no such utility.

4. -x

5. No, because it is protected by the noclobber variable which does not allow overwriting when set on.

6.

A. Suspends the currently running foreground job.

B. Brings the last suspended job to the foreground.

C. Runs the wc utility on all files in the current directory ending with a single character 0 through 9.

D. Searches for all instances of the string in the staff file.

E. Makes AAA an environmental variable.

F. Sends grep output to glmatch file and errors produced from that to glerr.

7. The result is 1 which is the exit error code from the previous command.

8. The contents are directory path names that the shell uses as search paths to find utilities.

9. Modify the file for the shell you are using. The file that the shell reads when starting.

Self Test 1 – pg. 510

  1. ls -l
  2. The owner has read and execute permissions and group/other do not have any permissions.
  3. +rw
  4. A. yes yes yes B. yes yes no C. Yes no no
  5. rwxrw-r--
  6. Write/execute
  7. source
  8. At the beginning of the permissions line a 'd' is noted.
  9. Everyone in your group except you.
  10. Read/execute
  11. chmod -r+x infrom
  12. A. everyone B. User/Others C. User/Others D. User/Group
  13. r-x—x---
  14. chmod a=rx
  15. A. 400 B. -w------- C. 600 D. 100 E. --------- F. r-x------

Self Test 2 – pg. 530

  1. Read/execute
  2. 500
  3. A. rwx, r-x, r-- B. User C. User
  4. Read/execute
  5. Permissions, date created, date modified, and links
  6. read/execute
  7. read
  8. Execute/write
  9. A. read, read/execute B. write C. write, execute, write D. write E. write, execute/write F. read G. read
  10. A. rwxrwxrwx B. 554 C. rw-r----- D. r-------- E. 754

Self Test 3 – pg. 547

  1. umask 533
  2. umask 066
  3. A. rwxr-xr-x B. rwxr-xr-x C. rwxr-xr-x D. rwxr-x--- E. rwxr-x---
  4. A. rw-, rw-, rw- B. rw-, rw-, rw-
  5. rw-------
  6. rwx------, rwx------
  7. No, because the utility will copy the old permissions

Assignment – pg. 549

  1. A. rw-rw-rw- B. rwxr-x--- C. rw-r—r-- D. 554 E. rw-rw----
  2. Others cannot have write permissions.
  3. R-x------
  4. rw-r-----
  5. rw-rw-rw-
  6. chmod 750, chmod u=rwx,g=rx,o=
  7. E, F, and H because execute permission are granted as part of the users permissions as well as read permissions which will allow us to source while group and others have no permissions.
  8. Chmod 640 Mybin
  9. Number 9 is a Project and Projects are not required to be completed in this class.

Self Test – pg. 576

  1. The shell
  2. A. 3 B. 1
  3. CTRL-C
  4. Start a new shell by opening a new terminal and enter the command ps -a.
  5. kill -2 PID
  6. The output is all suspended jobs with vi as the lead (+) and sleep second in line (-) because vi was the most recent to be sent to the background with the command CTRL-Z and sleep was sent to the background before vi with the & character at the end of the command line.

Assignment – pg. 578

  1. csh ; tty ; ps -t port
  2. A. CTRL-\ B. CTRL-C C. Interrupt exits the process while quit destroys the process. D. If nothing else works.
  3. fg %-
  4. kill -4 PID
  5. ps -l
  6. A. 1080 B. 1056 C. yes (tty24)

Self Test – pg. 598

  1. lp nlongfile
  2. find ~/ core rm*
  3. ps -aux | split -10 ps-
  4. The tar archive is in compressed format and includes file information while mcopy does not.

Assignment – pg. 600

  1. split -13 july_birthday na+
  2. man wc | col -bx | lp -n2
  3. ls $USER > wade-blank
  4. mcopy a:/july_birthday .
  5. Use the cancel or lprm command.
  6. Print jobs are held in a queue until the print spooler program processes them.

Self Test 1 – Pg. 620

  1. startx
  2. Click the help icon on the taskbar.
  3. Click the minimize button on the open window. Click the minimized window on the taskbar.
  4. These allow alternate desktops to be run.

Assignment – pg. 621

  1. Clicking the terminal icon on the taskbar.
  2. From the taskbar icon, start menu listing, or desktop icon.
  3. The menubar or taskbar.
  4. Locate the calculator function in the start menu then drag and drop the icon to the desktop.
  5. Choose environment as the default in the startup splash screen

Self Test 1 – Pg. 650

  1. ps -aux
  2. A. Modifies the password of the user. B. Logon as the super user in its own environment. C. Creates a new user account. D. Sends warnings and disables logins now. E. Creates a tarball of the /etc directory. F. Starts the printer configuration tool.
  3. A list of all currently defined default files are contained.
  4. 0. Halt 3. Multi-user 5. Multi-user with graphical login 6. Reboot

Assignment – pg. 651

  1. Three important responsibilities are in the areas of users, data, and security. When administering a root system users can be created, deleted, and disabled as necessary, data is protected and backed up, and security is implemented to preserve access, integrity, and availability.
  2. Because a root user has unrestricted access to the system and the ability to do great harm whether intentional or not.
  3. cd /, tar cvf root.tar.image, tar czvf root.tar.image.small, cp root.tar.image.small a:/
  4. Two options of legitimately shuting down a system are -h and -r. The -h option immediately shuts down the system which would be used by a user who has completed all of his/her task. The -r option allows for a delayed shutdown which can be useful to a user who has pending task he/she wantes to be completed prior to shutting down the system.
  5. linux single
  6. B and D results in the same super user powers.
  7. Encrypted versions of the password are located in etc/skel. To regain access of the account for the user you would logon as root and create a new password for the user.
Share
 



Login Form
Who's Online
We have 23 guests and 6 members online
Follow Us
  • Facebook Page: 120863957978522
  • Stumble Upon: studentsagain
  • Twitter: studentsagain