Unit Three
Unit Three
1
Page 249 exercise 1, 3, 4, and 6: 1. What does the shell ordinarily do while a command is executing? What should you do if you do not want for a command to finish before running another command? While the command is executing, the shell waits for the process to finish. Or sleeps
3. What is a PID number? Why are these numbers useful when you run processes in the background? Which utility displays the PID numbers of the commands you are running?
PID process identification numbers. Each of these numbers identifies the command running in the background. You can use the PS (process status) utility to display the PID numbers of running commands. 4- Assume that the following files are in the working directory: $ 1s intro notesb ref2 notesa refl ref3 sectionl section2 section3 section4a section4b sentrev.
Give commands for each of the following, using wildcards to express filenames with as few characters as possible. a. List all files that begin with section. $ ls section* b. List the section1, section2, and section3 files only. $ ls section[1-3] c. List the intro file only. $ ls i* d. List the section1, section3, ref1, and ref3 files. $ ls *[13]
6. Give a command to: A. redirect the standard output from a sort command into a file named phone_list. Assume that the input file is named numbers. $ sort numbers > phone_list
IT250 UNIT#4.1
B. Translate all occurrences of the characters [ and { to the character (, and all occurrences of the characters ] and } to the character ) in the file permdemos.c. (Hint: Refer to the tr man page.) $ cat permdemos.c | tr '[{}]' '(())' or $ tr '[{}]' '(())' < permdemos.c
C. Create a file named book that contains the contents of two other files: part1 and part2. $ cat part[12] > book *Advanced Exercise: 11. In experimenting with shell variable, Alex accidentally deletes his PATH variable. He decides that he does not need the path variable. Discuss some of the problems he may soon encounter and explain the reasons for these problems. How could he easily return PATH to its original value? a. Give a command to empty the file without invoking an editor. b. Explain how you might have permission to modify a file that you cannot delete
Page 353 exercise 1, 3, 6, and 7: 1. Explain the following unexpected results: $ whereis date date: /bin/date $ echo $PATH .:/usr/local/bin: /usr/bin:/bin $ Cat > date echo This is my own versions of date. $ date Sat May 24 11;45:49 PDT 2008 $ . scriptfile nder tcsh you can use $ source scriptfile
3. What is the purpose of the PATH variable? A. set the PATH variable so that is causes the shell to search the following: 1- /usr/local/bin = export PATH=/usr/local/bin;/usr/bin/:/bin;/usr/ 2- /usr/bin = t is determined by the order in the path statement. the command will execute the /usr/bin file 3- /bin = if you need to run a file that is not in your path, you would use the full command directory structure like: /usr/bin/doit or cd to the /usr/bin directory and type ./doit 4- /usr/Kerberos/bin = export PATH=$PATH:/usr/games 6. assume that the /home/jenny/grants/biblios and /home/jenny/biblios directories exist. Give jenny working directory after she executes each sequence of commands given. Explain what happen in each case. A. $ pwd /home/jenny/grants $ CDPATH=$(pwd) $ cd, $cd biblios After executing the preceding commands, Jenny s working directory is/home/jenny/grants/biblios.
IT250 UNIT#4.1
When CDPATH is set, cd searches only the directories specified by CDPATH, cd does not search the working directory unless the working directory is specified in CDPATH (by using a period). B. $ pwd /home/jenny/grants CDPATH=$(pwd) $ cd $HOME/biblios After executing the preceding commands, Jenny s working directory is /home/jenny/biblios because, when you give cd an absolute pathname as an argument, cd does not use CDPATH. 7. Name two ways you can identify the PID of your login shell. echo $$ and ps