Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 8 pot

68 306 0
Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 8 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

14 14-30 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D The sort Command Using sort on Different Fields Within a File The first example represents beginning a sort on some field other than the first, and shows a numeric, reverse-order example. The sort command line would read as, “Do a reverse order, numeric sort on the fifth field of the data in the file list, and place the output into a file called num.list.” The second example represents a multilevel sort showing how the M option would work. This command would read as “Do a Month order sort beginning with the sixth field. Do a second-level sort in numeric order and begin on the seventh field (this will sort the numeric day of the month correctly), name the output file update.list.” $ ls -ld f* > list $ cat list -rw 1 melissao staff 218 Jul 15 16:47 feathers -rw 1 melissao staff 218 Jul 15 16:48 feathers_6 -rw 1 melissao staff 1696 Oct 19 1998 file1 -rw 1 melissao staff 105 Oct 19 1998 file2 -rw 1 melissao staff 218 Oct 19 1998 file3 -rw 1 melissao staff 56 Mar 7 09:52 fruit -rw 1 melissao staff 57 Mar 7 09:53 fruit2 $ sort -rn +4 list -o num.list $ cat num.list -rw 1 melissao staff 1696 Oct 19 1998 file1 -rw 1 melissao staff 218 Oct 19 1998 file3 -rw 1 melissao staff 218 Jul 15 16:48 feathers_6 -rw 1 melissao staff 218 Jul 15 16:47 feathers -rw 1 melissao staff 105 Oct 19 1998 file2 -rw 1 melissao staff 57 Mar 7 09:53 fruit2 -rw 1 melissao staff 56 Mar 7 09:52 fruit $ sort +5M +6n list -o update.list $ cat update.list -rw 1 melissao staff 56 Mar 7 09:52 fruit -rw 1 melissao staff 57 Mar 7 09:53 fruit2 -rw 1 melissao staff 218 Jul 15 16:47 feathers -rw 1 melissao staff 218 Jul 15 16:48 feathers_6 -rw 1 melissao staff 105 Oct 19 1998 file2 -rw 1 melissao staff 218 Oct 19 1998 file3 -rw 1 melissao staff 1696 Oct 19 1998 file1 14 File and User Information Utilities 14-31 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Exercise objective – In this exercise you will practice using commands to find files and text. Tasks Complete the following steps and write the commands used to perform each task in the space provided. 1. Use the find command to search the /usr directory and display the file names of any length that end with ln. 2. Use the ls -li command to answer the following questions: ▼ How many links are there to the file /etc/init.d/lp? _______________________________________________________ ▼ Are these hard or symbolic links? _______________________________________________________ ▼ What is the inode number of the /etc/init.d/lp file? _______________________________________________________ 3. Create a file in /var/tmp that is linked to /etc/init.d/lp. Make sure it works. ✓ If /var is a separate file system, this will have to be a symbolic link. 4. Using the find command and starting at the /etc directory, find the other files that are linked to /etc/init.d/lp. What are they? ___________________________________________________________ 5. To what directory is /bin linked? ___________________________________________________________ 6. Search for the text string other in the /etc/group file. 7. Using ls and grep, display all the files created today. 14 14-32 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Tasks 8. Using the grep command, look for all lines in the file4 file located in your home directory that do not contain the letter "M". 9. Identify who is logged on to the system. 10. Switch to the guest account or another user’s account as specified by your instructor in such a way that you are in that user’s environment. 11. Type the who am i command. What happened? ___________________________________________________________ 12. Type the id command. What happened? ___________________________________________________________ 13. What command do you type to display the user ID and all groups that you belong to? __________________________________________________________ To create a file for use in the next step, type: $ ls -la > ls.output 14. Sort the ls.output file. Produce a numerical listing by size of the files, in reverse order. What command did you use? ___________________________________________________________ 15. Perform a multilevel sort of the ls.output file that places the data in chronological order, then alphabetically by name. What command did you use? ___________________________________________________________ 14 File and User Information Utilities 14-33 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Workshop Labs Use what you have learned so far in this course to work through the following: 1. On Monday you are told that all members of your department are to be dismissed because they consistently arrive at work late. In order to prove to your supervisor that this is not the case, you ask to have a week to gather data to prove your group’s timeliness. At the end of the week, you need to provide a printed copy of a file that lists what time everyone in your group logged in each day for a week. You have to create this file using commands that you have learned. For easier readability, the printout should be sorted by employee before being printed. You would also like to have a copy in your home directory of the sorted file to refer to at a later date. Using the least number of commands, how can you achieve this goal and save the group’s job? 2. You would like to have a list of all of the names of the subdirectories under /etc. Because you want to keep this list for future reference in a file, you would like any error messages that might appear while you are doing your search to be removed from the final output. Create a file that contains the list of these subdirectories and place it in your personal binary directory. 3. Using the caret (^) character with the regular expression in the grep command indicates the first character in a line. (For example, $ grep ^c file will look for lines that start with a “c” in the named file.) Using the file created in the workshop lab for Module 6, generate a file that contains the shell commands that start with the letters “a” though “f”, regardless of case (upper or lower). Sort this file alphabetically using the second field of the output of the grep command, and save the sorted text. Important – You will need to have the sort command ignore blank spaces when performing the sort. 4. To which commands is the cp command linked? What similarities are there between these commands? 14 14-34 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Exercise Summary Discussion – Take a few minutes to discuss what experiences, issues, or discoveries you had during the lab exercises. ✓ Manage the discussion here based on the time allowed for this module, which was given in the “About This Course” module. If you find you do not have time to spend on discussion, then just highlight the key concepts students should have learned from the lab exercise. ● Experiences ✓ Ask students what their overall experiences with this exercise have been. You might want to go over any trouble spots or especially confusing areas at this time. ● Interpretations ✓ Ask students to interpret what they observed during any aspects of this exercise. ● Conclusions ✓ Have students articulate any conclusions they reached as a result of this exercise experience. ● Applications ✓ Explore with students how they might apply what they learned in this exercise to situations at their workplace. 14 File and User Information Utilities 14-35 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Exercise Solutions Complete the following steps and write the commands used to perform each task in the space provided. 1. Use the find command to search the /usr directory and display the file names of any length that end with ln. $ find /usr -name ’*ln’ 2. Use the ls -li command to answer the following questions: ▼ How many links are there to the file /etc/init.d/lp? Four or five, depending upon the system. ▼ Are these hard or symbolic links? Hard ▼ What is the inode number of the /etc/init.d/lp file? It is different for every system. It is the number on the far left of the permissions. 3. Create a file in /var/tmp that is linked to /etc/init.d/lp. Make sure it works. $ ln /etc/init.d/lp /var/tmp/printer $ ls -li /var/tmp/printer 4. Using the find command and starting at the /etc directory, find the other files that are linked to /etc/init.d/lp. What are they? $ find /etc -inum inode number 5. To what directory is /bin linked? $ ls -ld /bin It is linked to /usr/bin. 6. Search for the text string other in the /etc/group file. $ grep other /etc/group 14 14-36 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Exercise Solutions 7. Using ls and grep, display all the files created today. $ ls -l | grep 'May 9' (This date is for example only.) 8. Using the ln command, create a symbolic link in your home directory to the command /usr/bin/clear. (You can name the link in your home directory whatever you want.) Check to see if the new link works to clear your screen. $ ln -s /usr/bin/clear cl 9. Using the grep command, look for all lines in the file4 file located in your home directory that do not contain the letter "M". $ grep -v 'M' file4 10. Identify who is logged on to the system. $ who 11. Switch to the guest account in such a way that you are in that user’s environment. $ su - guest 12. Type the who am i command. What happened? Your real UID (RUID) is displayed. 13. Type the id command. What happened? Your effective UID (EUID) is displayed. 14. What command do you type to display the user ID and all groups that you belong to? $ id -a 14 File and User Information Utilities 14-37 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using File and User Information Utilities Exercise Solutions To create a file for use in the next step, type: $ ls -la > ls.output 15. Sort the ls.output file. Produce a numerical listing by size of the files, in reverse order. What command did you use? $ sort -rn +4 ls.output 16. Perform a multilevel sort of the ls.output file that places the data in chronological order, then alphabetically by name. What command did you use? $ sort +5M +6n +8d ls.output If time of day created is an issue, the answer would be: $ sort +5M +6n +7n +8d ls.output 14 14-38 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Check Your Progress Before continuing on to the next module, check that you are able to accomplish or answer the following: ❑ Describe some advantages of using file systems ❑ List the inode number of a file ❑ Link files using hard and symbolic links ❑ Employ the find command to locate files by specific criteria ❑ Search for text within a document using the grep command ❑ Identify which users are logged on to your system ❑ Switch to a new user ID and identify the user ID you are currently using ❑ Identify your effective and real UID when switching users ❑ Use the sort command to sort ASCII files in alphabetical and numerical order ❑ Use the sort command to perform multilevel sorts on ASCII data 14 File and User Information Utilities 14-39 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Think Beyond For what kinds of situations might you use the utilities presented in this module in your work environment? [...]... example on the next page 16-6 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 16 Processes and PIDs Displaying a Full Listing of All Processes $ ps -ef | more UID PID PPID root 0 0 root 1 0 root 2 0 root 3 0 root 236 1 root 84 4 1 aster 1292 1 root 241 236 rose 1400 321 More C 80 80 27 80 80 54 80 69 80 STIME 16:46:41 16:46:44... additional details on the topics discussed in this module: q 16-2 Solaris User’s Guide, Part Number 80 2-6499 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 16 System Process Overview Each task you perform in the Solaris 7 environment starts a process An example of a process is using vi to edit a letter, or sending a file to... files with one request, rather than having to issue a download request for each separate file jar is standard with the Solaris 7 operating system, but is available on any system that has Java virtual machine (JVM) installed Command Format The syntax for the jar tool is almost identical to the syntax for the tar command jar options [ output file ] filename(s)/directory(s) 15 -8 Fundamentals of Solaris 7 Copyright... following example uses the -v (verbose) option to compress a file called bin.file: $ compress -v bin.file bin.file: Compression: 70 .84 % replaced with bin.file.Z The file is compressed and a Z suffix is appended to the file name 15-6 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 15 The compress Command Files are uncompressed... using the mt utility Backing Up and Restoring 15- 17 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 15 Think Beyond What tasks do you currently complete that you can apply the tar or jar commands to, besides saving and restoring files and directories? 15- 18 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise... highlight the key concepts students should have learned from the lab exercise q  Ask students what their overall experiences with this exercise have been You might want to go over any trouble spots or especially confusing areas at this time q  Conclusions Have students articulate any conclusions they reached as a result of this exercise experience q  Interpretations Ask students to interpret what... question to stimulate the students and get them thinking about the issues and topics presented in this module While they are not expected to know the answer to the question, the answer should be of interest to them and inspire them to learn the content presented in this module Discussion – How frequently do you back up or restore files? 15-2 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc... the tape forward to the end of the tape, then rewinds back to the beginning of the tape to smooth out the tape tension erase Erases the entire tape fsf Forward skips count tape files bsf Backward skips count tape files eom Skips to the end of the recorded media off Ejects 4- or 8- mm tapes Note – Only the unique prefix of a command is required For example, use ret in place of retension Use the following... daemon provides the CDE login screen at the beginning of a user’s session and again after the user exits CDE 16-4 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 16 Process Hierarchy Following system boot-up, a process called init is invoked This process is at the top of the process hierarchy and is responsible for spawning... jar file backups of ~/practice for size 6 Retension the tape Workshop Labs Use what you have learned so far in this course to work through the following: 1 Another user in your group needs a copy of the files in your personal binary directory Create a compressed tar file, place it in that directory, and make it available to the other user 15-14 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, . use? $ sort +5M +6n +8d ls.output If time of day created is an issue, the answer would be: $ sort +5M +6n +7n +8d ls.output 14 14- 38 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc 2 18 Oct 19 19 98 file3 -rw 1 melissao staff 2 18 Jul 15 16: 48 feathers_6 -rw 1 melissao staff 2 18 Jul 15 16: 47 feathers -rw 1 melissao staff 105 Oct 19 19 98 file2 -rw 1 melissao staff 57 Mar 7. staff 2 18 Jul 15 16: 47 feathers -rw 1 melissao staff 2 18 Jul 15 16: 48 feathers_6 -rw 1 melissao staff 1696 Oct 19 19 98 file1 -rw 1 melissao staff 105 Oct 19 19 98 file2 -rw 1 melissao staff 2 18 Oct

Ngày đăng: 13/08/2014, 02:23

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan