1 OVERVIEW SOLUTIONS 1 Overview Solutions 2. Changing password (a) Responses will vary from system to system, depending on whether or not good password practice is enforced. 3. Navigating Man Pages (b) It is possible that some Linux distributions won’t use less to display man pages. If that is the case, try to find out how you navigate under that setup and answer the same questions about it. (d) Keystrokes for basic man page navigation: Instruction Top of man page Bottom of man page Forward one screen Backward one screen Up one line Down one line pattern Search forward pattern Search backward Repeat pattern Search forward Repeat pattern Search backward Move to nth line Keystroke(s) g < ESC-< G > ESC-> f ^F ^V SPACE b ^B ESC-v y ^Y k ^K ^P e ^E j ^N RETURN /pattern ?pattern n N ng Table 1: Keystrokes for basic man page navigation N.B. Several different keystrokes can be used for the same movement. This is common in UNIX tools designed to operate from any keyboard. less always has a single key method. Multi-key methods are shown without spaces between them. 4. Invoking the Right Man Pages (a) i. $ man -k whatis or, slightly differently: $ man -f whatis ii. $ man -K cdrom iii. There is no easy way to do this yet. Later on you will learn about grep which will allow you to filter the output of man -k print to see only the information you require. (b) Practice using these flags to find and view man pages which deal with computer keywords your partner sets for you (and vice versa), e.g. i. e.g. $ man -K jpg ii. e.g. $ man -K modem iii. e.g. $ man -K NFS 1 1 OVERVIEW SOLUTIONS 5. Finding Out About Your System and Users (a) The listed command strings tell you about: Command string $ whoami $ who am i $ users $ who $w $ date $ cal 8 1999 $ cal 9 1752 Output Your username Your username plus machine(s) and terminal you are on Usernames of currently logged on users Who is logged on, when and where Who’s logged on, when, where, what process and what system resources they are using Current date and time, can set date/time Calendar for August 1999 Calendar for September 1752. Strange because 12 days were ‘lost’ in the transition from Gregorian to Julian calendars Disk free, i.e. summarises disk usage Full file and path name for the man executable file Much the same as which man Locates the less executable and its man page Very brief help notes on the cd command. N.B. help only works on very few built-in commands The sleep command puts itself to sleep for 2 seconds. The time command then times the whole process and provides other data on the operation of the sleep command $ df $ which man $ type man $ whereis less $ help cd $ time sleep 2 Table 2: Output from basic system information commands (b) See Table 2 6. Creating new files (a) Your output should be something like: $ touch filename.txt (b) Your output should be something like: $ ls -l filename.txt -rw-rw-r-1 davef davef 0 Jul 21 17:59 filename.txt (c) Your output should now be something like: $ touch filename.txt $ ls -l filename.txt -rw-rw-r-1 davef davef 0 Jul 21 17:59 filename.txt 2 1 OVERVIEW SOLUTIONS $ touch filename.txt $ ls -l filename.txt -rw-rw-r-1 davef davef 0 Jul 21 18:01 filename.txt i. The time stamp has changed ii. The real purpose of touch is to change time stamps, but it is handy for creating new empty files (d) i. Reading diskspace.txt should produce something like this: $ cat test.txt Filesystem Used Available Capacity Mounted on /dev/hda1 65571 406394 14% / /dev/hdc1 5030416 650563 89% /backup /dev/hda5 2000097 857401 70% /home /dev/hda7 14289 457676 3% /tmp /dev/hda6 1136861 741727 61% /usr /dev/hdb 653004 0 100% /mnt/cdrom 7. Appending information to files (b) Your screen should look something like this: $ w > test.txt $ date >> test.txt $ cat test.txt 6:36pm up 16 days, 23:07, 4 users, load average: 1.03, 1.08, 1.02 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT davef ttyp7 oakleigh:0.0 9:39am 0.00s 2.58s 0.02s w mikeb ttyp4 kebab Tue 3pm 23:07 0.20s 0.13s -bash davef ttyp2 oakleigh 9:04am 15:34 7:24 0.07s -bash davef ttypb oakleigh 3:02pm 3:15m 3:00m 0.08s -bash Wed Jul 21 18:36:39 BST 1999 8. Using Simple Pipes (a) $ who | sort -r (b) sort /etc/passwd > passwd or $ cat /etc/passwd | sort > passwd.sorted (c) wc prints the number of lines, words, and bytes in files. To get these details for your /etc/mime.types file, you could do the following: $ cat /etc/mime.types | wc 291 524 7751 i.e. 275 lines, 488 words, and 7373 bytes 1 Another way of doing the same thing without a pipe is $ wc /etc/mime.types 291 524 7751 /etc/mime.types 1 N.B. wc only counts whitespace-separated words 3 1 OVERVIEW SOLUTIONS (d) E.g. $ cat /etc/mime.types | wc -w 524 We can get a similar result by typing: $ wc -w /etc/mime.types 4