======UNIX Journals====== ==6. May 2013== ==Lab 0x7 - Job Control and Multitasking [pushing it, aren't I?]== 1a/b. lab46:~$ ps USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND dblanch1 25797 2.3 0.1 13636 1976 pts/22 SNs 10:14 0:00 -bash dblanch1 25839 0.0 0.0 8588 980 pts/22 RN+ 10:15 0:00 ps u 1c. Use the t option to specify which tty to consider in it's output. 2a. lab46:~$ ps axu USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 8356 796 ? Ss Apr29 0:10 init [2] root 2 0.0 0.0 0 0 ? S Apr29 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Apr29 1:55 [migration/0] root 4 0.0 0.0 0 0 ? S Apr29 0:02 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S Apr29 0:00 [watchdog/0] root 6 0.0 0.0 0 0 ? S Apr29 3:00 [migration/1] root 7 0.0 0.0 0 0 ? S Apr29 0:04 [ksoftirqd/1] root 8 0.0 0.0 0 0 ? S Apr29 0:00 [watchdog/1] root 9 0.0 0.0 0 0 ? S Apr29 3:31 [events/0] root 10 0.0 0.0 0 0 ? S Apr29 3:28 [events/1] root 11 0.0 0.0 0 0 ? S Apr29 0:00 [cpuset] root 12 0.0 0.0 0 0 ? S Apr29 0:00 [khelper] root 13 0.0 0.0 0 0 ? S Apr29 0:00 [netns] root 14 0.0 0.0 0 0 ? S Apr29 0:00 [async/mgr] root 15 0.0 0.0 0 0 ? S Apr29 0:00 [pm] root 16 0.0 0.0 0 0 ? S Apr29 0:00 [xenwatch] root 17 0.0 0.0 0 0 ? S Apr29 0:00 [xenbus] root 18 0.0 0.0 0 0 ? S Apr29 0:02 [sync_supers] root 19 0.0 0.0 0 0 ? S Apr29 0:01 [bdi-default] root 20 0.0 0.0 0 0 ? S Apr29 0:00 [kintegrityd/0] root 21 0.0 0.0 0 0 ? S Apr29 0:00 [kintegrityd/1] root 22 0.0 0.0 0 0 ? S Apr29 0:07 [kblockd/0] root 23 0.0 0.0 0 0 ? S Apr29 0:00 [kblockd/1] root 24 0.0 0.0 0 0 ? S Apr29 0:00 [kseriod] root 27 0.0 0.0 0 0 ? S Apr29 0:00 [kondemand/0] root 28 0.0 0.0 0 0 ? S Apr29 0:00 [kondemand/1] root 29 0.0 0.0 0 0 ? S Apr29 0:00 [khungtaskd] root 30 0.0 0.0 0 0 ? S Apr29 0:06 [kswapd0] root 31 0.0 0.0 0 0 ? SN Apr29 0:00 [ksmd] root 32 0.0 0.0 0 0 ? S Apr29 0:00 [aio/0] root 33 0.0 0.0 0 0 ? S Apr29 0:00 [aio/1] root 34 0.0 0.0 0 0 ? S Apr29 0:00 [crypto/0] root 35 0.0 0.0 0 0 ? S Apr29 0:00 [crypto/1] root 38 0.0 0.0 0 0 ? S Apr29 0:00 [khvcd] root 113 0.0 0.0 0 0 ? S Apr29 0:59 [kjournald] root 164 0.0 0.0 10416 696 ? S lab46:~$ ps -u statd USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND statd 1046 0.0 0.0 14596 840 ? Ss Apr29 0:00 /sbin/rpc.statd 11b. init's PID is 1, as it is the first process of executed by the system. lab46:~$ ps ax | grep init root 1 0.0 0.0 8356 788 ? Ss Apr29 0:10 init [2] dblanch1 29888 0.0 0.0 10092 868 pts/35 RN+ 13:56 0:00 grep init 11c. cron's PID is 971 and is owned by root. cron is a task scheduler in the sense that you can schedule a command to be executed at a specific time, or have it reoccur every so often. lab46:~$ ps ax | grep cron root 971 0.0 0.0 14676 776 ? Ss Apr29 0:06 /usr/sbin/cron dblanch1 29894 0.0 0.0 10092 868 pts/35 RN+ 13:57 0:00 grep cron ===Varying Dates (Actual Edit: 5. May 2013)=== ==Case Study 0x9 - Fun with grep== 1a. grep "coast" -c < pelopwar.txt b. 9 c. grep '\' -c < pelopwar.txt d. 8 e. grep '\$' < pelopwar.txt f. grep '^\' < pelopwar.txt 2a/b. egrep '^(\|\)' < pelopwar.txt 2c/d. egrep '(\|\)$' < pelopwar.txt 3. This produces no results as there is no line or string the file matching this. ==Lab 0x8 - UNIX Programming Environment== Compiling Things: as -o helloASM helloASM.s; ld -o helloASM helloASM.o gcc -o helloC helloC.c g++ -o helloCPP helloCPP.cc All three compiling methods worked fine for me. The current directory is not in $PATH, so just typing the name of the binary in question is insufficient; it must be prefixed with a path. file: helloC.c: ASCII C program text helloCPP.cc: ASCI C++ program text helloASM.S: ASCII assembler program text gcc -s yields an assembler source file conversion of helloC.c hello.o is a 64-bit relocatable ELF file, a UNIX executable format. It is an object file, so it is machine code nearly ready for execution, it just needs to be placed in another executable (which is why it is relocatable; either a finished form consisting of it's own code linked with necessary support libraries, or turned into a shared object and linked into another process; which is not the current case). The output matches as we just did what gcc would automatically do for us. helloC could be compiled this way: make helloC Code Efficiency: helloC is 6546 bytes helloCPP is 8369 bytes helloASM is 935 bytes helloJAVA is 426 bytes The resulting Java file is smaller than the other files because it does not link any support code into the bytecode file, instead linking it at run time. ==Case Study 0xA== dd: What is different? uptime is executable, and howlong is not. The permissions are different, because a regular user used dd to make the copy. howlong is not executable because UNIX does not by default create executable files. The differences exist because the actual file data is copied but not associated filesystem metadata, such as permissions, time and date, and the file name. file's output for both files is the same because it analyses the files' contents to determine it's type. In order to execute, howlong needs to be made executable. The only difference between the two programmes' output is the amount of time displayed as they were executed at separate times. Comparisons: Using diff -s (which reports when both files are the same) causes it to report their file data is, in fact, the same. MD5 hashes are useful in data integrity because they provide an easy, compact way to check the contents of a file for any difference using an algorithm. diff can be used for checking changes between two different versions of a document (say you deleted a line from a document that you now decide that you needed, and you want to retrieve it). The Exercises: 3a/b/c: To create the zero filled file: dd bs=8kB count=1 if=/dev/zero of=test.file I verified this with bvi. 3d. This would append the string to test.file 3e/f. The string start at byte 8001, so we can skip the first 8000 bytes: dd bs=1 skip=8000 if=test.file of=string 4a. According to bvi, the file is 8186 bytes long. 4b. zeros. 4c. Not constant. Byte Ranges (hexadecimal) - Size (decimal) 1000 -> 13A5 - (933 bytes) 19A7 -> 19BE - (23 bytes) 1BBF->1BF6 - (55 bytes) 4d/e: There are three such ranges. Segment 1: ELF 64-bit executable dd bs=1 count=933 skip 4096 if=data.file of=segment1 Segment 2: ASCII text dd bs=1 count=23 skip=6567 if=data.file of=segment2 Segment 4: gzip compressed data dd bs=1 count=55 skip=7103 if=data.file of=segment3 In accordance with "The magic number is 42" [I hope the Earth doesn't get blown away soon for an interstellar highway], count is changed to 97 for segment3 such that the secret word can be extracted: "The secret word is: Monkeysnake." Whatever that means. ==Lab 0x9 - Pattern Matching Regular Expressions (joys to be had ahead)== 1a/b. lab46: ~$ grep 'System' gnats:x:41:41:Gnats Bug-Reporting System(admin):/var/lib/gnats:/bin/sh 2. lab46: ~$ grep '^[b-d][aeiou]' /etc/passwd daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh This search looks for lines starting b, c, or d and is immediately followed by a vowel. Pattern searching is more powerful than looking for just a string literal because you can search unknown strings so long as you have some idea of their structure. 3a. lab46: ~$ grep '^[dwb]' /etc/passwd daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh 3b. lab46: ~$ grep '^[aeiou]h$' root:x:0:0:root:/root:/bin/bash 4a. %s//
/g 4b. %s/<\/CENTRE>/<\/center>/g 4c. %s///g 4d. %s<\/b>/<\/strong>/g 5a. lab46: ~$ ls -l /usr/share/dict | grep words This points to /etc/dictionaries-common/words 5b. This file contains words the are on individual lines. 5c. lab46: ~$ cat words | wc -l 98569 words in this file For this next set of exercises, I copied the words file to my cwd, /home/dblacnh1 in this case. 6a. cat words | egrep '^.{5}$' | wc -l; 6685 matches 6b. cat words | grep '^[dwbDWB]' | wc -l; 14617 6c. cat words | egrep '^[dD].*[wW].*[bB]$' | wc -l; 1 match: dweeb 6d. cat words | egrep '&[aeiou].*[aeiou]$' | wc -l; 1731 matches 6e. cat words | grep '^[dD][aeiou][est]$' | wc -l; 10 matches 6f. cat words | grep '^[^dwbDWB]' | wc -l; 83951 matches 6g. cat words | egrep '^[^t][^h].+' | wc -l; 90669 matches 6h. cat words | grep '^..e$' | wc -l ; 72 matches 6i. cat words | grep '.*bob.*[^b]$' | wc -l ; 41 matches 6j. cat words | grep 'blue.*' | wc -l ; 37 matches 6k. cat words | grep '[^aeiouyAEIOUY]*' | wc -l ; 204 matches This should be 203 as 'Ångström' contains two vowels. 6l. cat words | grep '[^aeiou].[abcd][aeiou]$' | wc -l; 762 matches ===29. April 2013=== ==Lab 0x6 - Shell Scripting Concepts== *To make script1.sh run, we need to make it executable: chmod +x script1.sh Code for age.sh: #!/bin/bash echo "In what year were you born? (YYYY) " read birth_year current_year=`/bin/date +%Y` let current_age=$current_year-$birth_year echo "Your current age is: "$current_age Code for guess1.sh: #!/bin/bash pick=$(($RANDOM % 20)) echo "Please pick a number [1,20]: " read guess if [ "$guess" -eq "$pick" ]; then echo "Congrats! You guessed correctly." else echo "You have three guesses left. Guess again: " read guess if [ "$guess" -eq "$pick" ]; then echo "Congrats! You guessed correctly." else echo "You have two guess left. Guess again: " read guess if [ "$guess" -eq "$pick" ]; then echo "Congrats! You guessed correctly." else echo "You have one guess left. Guess again: " read guess if [ "$guess" -eq "$pick" ]; then echo "It's about bloody time you guessed right..." else echo "You have failed. The correct answer is "$pick fi fi fi fi 4a. To make the loop put the count all on one line, each separated by a space, change: echo "$i" to echo -n "$i" 4b. To change the stepping and direction, change: for ((i=1;i<=10;i++)); do to for ((i=20;i>=2;i-=2)); do Code for modified color.sh (now colour.sh): #!/bin/bash echo -n "First colour is: " for colour in red orange yellow green blue indigo violet; do if [ "$colour" = "violet" ]; then echo -n "The final colour is: " echo $colour elif [ "$colour" != "violet" ]; then echo "$colour" if [ "$colour" != "indigo" ]; then echo -n "The next colour is: " fi fi done Code for script6.sh: #!/bin/bash for((i=1; i<=8; i++)); do echo "$i" >> "file"$i done echo "Pick a number [1,8]: " read number for ((i=8; i>0; i--)); do let j=$i+1 if [ "$i" -gt "$number" ]; then mv "file"$i "file"$j elif [ "$i" -eq "$number" ]; then mv "file"$i "file"$j echo "$number" >> "file"$number fi done echo "$number" >> "file"$number Code for script7.sh: #~/bin/bash ag=0 hm=0 ns=0 tz=0 q_files=0 echo -n "Directory to process: " read curr_dir cd $curr_dir echo "Processing: $curr_dir ..." a="`find ./ -name "a*" -maxdepth 1 | wc -l`" b="`find ./ -name "b*" -maxdepth 1 | wc -l`" c="`find ./ -name "c*" -maxdepth 1 | wc -l`" d="`find ./ -name "d*" -maxdepth 1 | wc -l`" e="`find ./ -name "e*" -maxdepth 1 | wc -l`" f="`find ./ -name "f*" -maxdepth 1 | wc -l`" g="`find ./ -name "g*" -maxdepth 1 | wc -l`" let ag=$a+$b+$c+$d+$e+$f+$g let q_files+=$ag if [ "$ag" -gt 60 ]; then let ag=60 fi h="`find ./ -name "h*" -maxdepth 1 | wc -l`" i="`find ./ -name "i*" -maxdepth 1 | wc -l`" j="`find ./ -name "j*" -maxdepth 1 | wc -l`" k="`find ./ -name "k*" -maxdepth 1 | wc -l`" l="`find ./ -name "l*" -maxdepth 1 | wc -l`" m="`find ./ -name "m*" -maxdepth 1 | wc -l`" let hm=$h+$i+$j+$k+$l+$m let q_files+=$hm if [ "$hm" -gt 60 ]; then let hm=60 fi n="`find ./ -name "n*" -maxdepth 1 | wc -l`" o="`find ./ -name "o*" -maxdepth 1 | wc -l`" p="`find ./ -name "p*" -maxdepth 1 | wc -l`" q="`find ./ -name "q*" -maxdepth 1 | wc -l`" r="`find ./ -name "r*" -maxdepth 1 | wc -l`" s="`find ./ -name "s*" -maxdepth 1 | wc -l`" let ns=$n+$o+$p+$q+$r+$s let q_files+=$ns if [ "$ns" -gt 60 ]; then let ns=60 fi t="`find ./ -name "t*" -maxdepth 1 | wc -l`" u="`find ./ -name "u*" -maxdepth 1 | wc -l`" v="`find ./ -name "v*" -maxdepth 1 | wc -l`" w="`find ./ -name "w*" -maxdepth 1 | wc -l`" x="`find ./ -name "x*" -maxdepth 1 | wc -l`" y="`find ./ -name "y*" -maxdepth 1 | wc -l`" z="`find ./ -name "z*" -maxdepth 1 | wc -l`" let tz=$t+$u+$v+$w+$x+$y+$z let q_files+=tz if [ "$tz" -gt 60 ]; then let tz=60 fi echo "Total files: $q_files" echo -n "(a->g): " for ((c=0;cm): " for ((c=0;cs): " for ((c=0;cz): " for ((c=0;c 111 111 111 077 -> 000 111 111 AND -> 000 111 111 3b. Assuming a directory 777 -> 111 111 111 777 -> 111 111 111 AND -> 111 111 111 3c. Assuming a directory 777 -226 551 Assuming a file 666 -226 441 3d. 777 074 703 4a & 4b. Using the id command, I belong to: lab46 (GID 5000) unix (GID 1730) dblanch1 (5813) 5a & 5b. Directories fall2010 permissions are 730 and unix is the group root permissions are 750 and the group is root unix permissions are 750 and the group is unix users permissions are 750 and the group is lab46. 5c. I cannot view unix/ME.TOO . unix/README: The mountain ate the dog. users/groups.cs: Up Up Down Down Left Right Left Right B A 5d. I cannot get into root because I am not a member of group root, and I cannot view the contents of fall2010 because I do not have read permissions to this file. ===14. April 2013=== ==Case Study 0x8 - Data Types in C== My inclination is to find files with whereis, but it's limited to searching along $PATH, so we'll go with find this time. Among the directories listed with find that a limits.h file is, I shall use /usr/include/limits.h. I called it: lab46:~$ find / -name limits.h 2>/dev/null On Lab46, the following is true: char is a four bit type. Has 2^4 (256) possible values. Signed Range: [-128,127] Unsigned Range: [0,255] short int is a sixteen bit type. Has 2^16 (65536) possible values. Signed Range: [-32768,32767] Unsigned Range: [0,65535]. int is a thirty-two bit type. Has 2^32 possible values. Signed Range: [ (-(2^32)/2), ((2^32)/2 - 1)] Unsigned Range: [0, ((2^32) - 1). long long int is a sixty-four bit type. Has 2^64 possible values. Signed Range: [ (-(2^64)/2), ((2^64)/2 -1)] Unsigned Range: [0, ((2^64) - 1). "Testing the Limits" To compile: lab46:~/devel$ gcc dtypes.c -o dtypes Value of unsigned int, after: 429467295 This value is seen in limits.h, defined as the UINT_MAX macro. Value of signed int, after: -1 This is expected. The value is within signed int's range. The result of the modified code makes sense because the value will "roll over" (sort of like the digit wheel on old alarm clocks that had a wheel of digits for the tens of hours, ones of hours, tens of minutes, and ones of minutes). Modified code: #include #include int main() { unsigned int a, x; signed short int b, y; a = 0; // zero not letter "O" b = SHRT_MAX; x = a - 1; y = b + 1; printf("signed short int before: %hd \t after: %hd\n", b, y); return(0); } "Playing with long long int" The minimum value of signed long long int: -9223372036854775808 One use of this data type could be to display the size of the American deficit to the dollar, truncated, of course. Code (C++): #include #include using namespace std; int main(){ cout << "***Playing with long long int***" << endl; cout << "Unsigned:" << endl; cout << "Min: " << 0 << " Max: " << ULLONG_MAX << endl; cout << "Signed: " << endl; cout << "Min: " << LLONG_MIN << " Max: " << LLONG_MAX << endl; return 0; } ===19. March 2013=== Case Study 0x6 - Device Files Looking at /dev: Some files null (character) random (character) zero (character) loop0 (block) xvda1 (block) xvda2 (block) Filesystems: /dev/xvda1 is mounted at / /dev/xvda2 is mounted at /tmp /dev/xvda3 is mounted as swap (determined by runnning the following: cat /etc/fstab | grep swap nfs:/home is mounted at /home nfs:/lib/mail is mounted at /var/mail udev is mounted at /dev There are two temporary file systems, one resides in memory (/dev/shm), and the other is mounted at /lib/init/rw Software Devices: The two terminals I was using were /dev/pts/28 and /dev/pts/74. Permissions on for both terminals are crw--w----. Write permissions for group are enabled for the UNIX messaging facilities to function (ie, mesg returns y). Terminal Pointer: Both methods are the same because /dev/tty points to the current terminal. Also: cat'ing to /dev/null dumps the output of cat. /dev/null is useful for ignoring command output and making technical jokes. ===12. March 2013=== I did Case Study 5 - Web Pages today. My web page is all set up, including a quote from Camus and Hesse. It's just basic HTML, covering some primitive tags such as
to break off into a new line,

&

to demarcate paragraphs, and creating lists with
    &
(ordered list) and
    &
(unordered list) tags. The URL of my web page is http://lab46.corning-cc.edu/~dblanch1/index.html . ===7. March 2013 (Actual Edit: 11. March 2013)=== Case Study 4 - Messaging Utilities I performed this on my local system using two accounts, user doug on tty2 and user root on tty3. I first ensured messaging was enabled on each account by calling: doug@slackware: ~$ mesg y root@slackware: ~# mesg y I then had doug write root "Hello" doug@slackware: ~$ write root Hello // pressed CTRL+D here to exit. Here is what root would see: root@slackware: ~# Message from doug@slackware on tty2 at 20:42 ... Hello EOF // root pressed return here to get his shell back root@slackware: ~# write doug; mesg n I am busy. Do not interrupt. mesg is n now. doug@slackware: ~$ Message from root@slackware on tty3 at 20:43 I am busy. Do not interrupt. mesg is n now. EOF doug@slackware: ~$ write root write: root has messages disabled doug@slackware: ~$ mesg n root@slackware: ~# mesg y; write doug; mesg n I can still message you. I am the sysadmin. You cannot ignore me. // doug sees this, attempts to start a talk session, then realises his system has no talk daemon configured. Some points about ytalk from the man pages, as I did not have time to actually configure a daemon and play with it: To bring up a shell while in a talk session, press ESC then S To invite another user to a session, press ESC then A To kick another user from a session, press ESC then D Lab 4 - Basic Unix Shell Stuff Personalised my .signature file. printenv brings this valuable information: Shell: bash Term: xterm Path: /bin /usr/bin /usr/local/bin /usr/bin/X11 /usr/games /usr/local/java/bin In order to display what is in the PATH shell variable: doug@slackware: ~$ echo $PATH Current alias for ls: alias ls='ls --color-auto' Which, according to the man page, this colourises the ouptput of ls (shocking, I know) based on the file type. Some examples of these colours: plain text is white, directories are blue, archives are red, symlinks are cyan, and executable files are green. Important to note is the colourisation of the file types can be customised with another shell variable, LS_COLORS Removing the alias for ls removes colourised output for ls when ls is called with no parameters because the shell no long supplies the colour paramter. Recreating and customising the ls alias alias ls='ls --colour=auto -k -s --block-size=K' Changes made here: Calling ls in the shell now displays the total file size of the directory now, and the size of each individual file in front of the filename now, in KiB, and the output is colourised again. History: doug@slackware: ~$ history -c //clears history doug@slackware: ~$ echo "###" ### dou@slackware: ~$ echo "You got it" You got it doug@slackware: ~$ echo "---" --- doug@slackware: ~$ history 31 echo "###" 32 echo "You got it" 33 echo "---" 34 history // 32 is the line number for "You got it" doug@slackware !32 echo "You got it" You got it History cycling is useful if you mistype a command and need to correct (or at least this is my own personal, very common use for it). Tab Completions: This is all fairly self explanatory. Skipping the first few parts of this to filling in vimtutor; to get a unique hit for tab completion to complete, at least vimt needs to be provided. ===4. March 2013=== Not entirely sure when I originally posted this Lab 2 stuff, but I just noticed it was in the wrong section. So I am moving it. Lab 2 Results: 10d. chmod 705 lab2 //Needs executable permission because it is a directory 11c. / | bin/ etc/ home/ lib/ sbin/ tmp/ usr/ var/ | dblanch1/ | making.waves unix.text some_assembly/ | a b c d e f g h u j k l m n o p q quest2 quest2.dblanch1.gz r s t u v w x y z 12. ls / | grep bin // Of note, I guess, neither /bin or /sbin are revealed to be symlinked to anything ls /usr | grep bin // Again, neither /usr/bin or /usr/sbin are symlinked to anything ls /usr/local/ | grep bin // Again, neither bin nor sbin here are symlinked to anything. // /bin and /sbin store binaries for the local system necessary for startup and single user mode // /usr/bin and /usr/sbin store binaries that are not necessary for startup or single user mode, and as such, can be shared on a server amongst many clients // /usr/local/bin and /usr/local/sbin store binaries that are specific to the local system, but do not need to be on other computers in the network // Obviously, the difference between bin and sbin is that bin holds user binaries, while sbin holds binaries useful to system administration Worksheet for Week 6 File Permissions 755 321 421 663 File Types Normal Directory Special file, character. Used for raw input/output to devices Special file, block. Used for block input/output to devices. Often used with disk drives. Modifying File Permissions Based on File Type Do not modify. Normal file. chmod 725 chmod 625 chmod 627 Absolute vs Relative Absolute. The root directory is explicitly mentioned. Relative. Up one directory level from the current working directory (.. is explicitly mentioned). Relative. No root directory is specified, so the current working directory's path is used. Absolute. Root directory is explicitly mentioned. ===25. February 2013=== It might help if I posted how I overcame the challenge round... rm ./?\ challenge\ round\ ? rm: remove regular file `./- challenge round -'? y ===23. February 2013=== The results of the exercise for Case Study 2 1a. Choosing files: "'ls' * HI! *" "??? can you delete me ???.abc" "compres "this" file.data" 1b. cat ?ls* Will the weird filenames ever end? rm *can\ you* rm: remove regular file `??? can you delete me ???.abc'? y //verify ls | grep can //amazing... nothing appeared... gzip compress* //Compresses fine. ls | grep compress compress "this" file.data.gz 2a. Choosing files: "*** watch out! ***" "change my\ name.file" "just a simple file.txt" 2b. cat \*\*\*\ watch\ out\!\ \*\*\* Care must be taken when using the '!' symbol, as it deals with history. mv change\ my\\\ name.file "change my name.file" && cat change* This file has spaces and a backslash in its name. cat just\ a\ simple\ file.txt Simple, but simpler without the spaces! 3a. Choosing files: "#pico28903#" "( paranthesis & other odd things)" "one, 'two', three, "four"" 3b. cat "#pico28903#" laLAA... pretend this is a pico temp file. cat "( paranthesis & other odd things)" Are we having fun yet? cat "one, 'two', three, "four"" cat: one, 'two', three, four: No such file or directory //This is because the double quotes around 'four' need to be escaped cat "one, 'two', three, \"four\"" spaces, commas, two types of quotes... oh my! ===19. February 2013=== Completed the puzzle case study. Not really what I was expecting based on the name. Kind of disappointing, actually. ===18. February 2013=== I have not had much time to work on my e-mail server project as of yet, so progress on that is where it was last week, unfortunately. This should change this week, though. But anyway, I am starting to do the text processing lab. Here are my thoughts on it so far: ===wc(1) on /etc/passwd=== To get wc(1) to display just the line count of /etc/passwd, we would call: lab46:~$ wc -l /etc/passwd and this tells us there are twenty-seven lines in the file. Alternatively, we can use the long parameter format, according to its man page, and use --lines instead of -l ===head(1) on /etc/passwd=== To display just the first sixteen lines of /etc/passwd, we would call: lab46:~$ head -n 16 /etc/passwd Alternatively, we can use the long parameter format and use --lines instead of -n. ===tail(1) on /etc/passwd=== To display just the last eight lines of /etc/passwd, we would call: lab46:$ tail -n 8 /etc/passwd Alternatively, we can use the long parameter format and use --lines instead of -n. The -f (--follow) parameter is used to follow changes to a file. This would be especially useful for following changes to, say, a log file. ===11. February 2013=== I started work on my first project yesterday, setting up an e-mail server. I ran into an issue yesterday that seems to be resolved now, however; my noip DUC was unable to associate itself with my noip account. To clarify, noip provides free dynamic DNS for users without a static IP address (most residential users, myself included). The Dynamic Update Client would not during configuration associate itself with the domain I chose in my noip account. More to come later. ===5. February 2013=== Well, even though I've concluded I probably shouldn't be doing the problems that appear to be randomly placed in /var/public/unix , I'm still going ahead and doing them as I wait on confirmation for setting up an e-mail server (on my home computer) as a project for this class. "puzzle" is puzzling indeed... so far it appears to be just a collection of oddly named empty files. A few things that strike me about it at the moment is a file called "eieio.c", and a few files seem to have the same group of letters in them, with one adding to the set... I also wonder if all the ??.c files are at all related... ===2. February 2013=== Actually finished "Quest 2". For some reason it didn't dawn on me that .gz without tar.gz needed to be extracted with gunzip... I suppose I'm a little too used to tar. I did notice that there is no submit directory under /var/public/unix though, so I could not submit my completed quest. That does have me thinking that perhaps I was not supposed to start doing the quests. ===1. February 2013=== I was doing "Quest 2", redirecting a programme's stdout (to produce file z) was fairly simple (admittedly after a search with Google), a la sys:~$ FUNC 1>DEST 1 is stdout, 2 is stderr. It is important to note that this is a bash feature and will not work with zsh, csh, tcsh, et cetera. ===30. January 2013=== I was perusing the public directory yesterday and found a directory called quests. I am not entirely certain what these are exactly, but I noticed the one entitled "some_assembly" seems to be a good exercise for using tar and basic file management (save for symlinking, ln -s src dest). I'll start doing these little "quests" though, particularly since they likely will go along well with the labs for this course. Oh, and when I was setting up screen, I used man screen to help me set it up. You tend to develop those habits when (basically) building your own Linux installation (I used Arch Linux before moving to Slackware; I switched away from it because it was too much work to maintain). Morse code eh? C'est trés interessant... and I'll be perfectly honest, I did not know there was a reverse line command in UNIX. ===25. January 2013=== I was just reading through the page for Lab 0. Nothing exciting going on there. Decided to leave some evidence that I did it by playing around with alpine a little bit, talking to myself mainly (or exclusively). I know root is watching. ===22. January 2013 (actual edit: 25. Jan 13)=== I setup Mercurial, irssi, and screen as per the UNIX task page. Following the instructions it was pretty simple. Logging in via ssh was also a breeze (I've setup it up before to access my home computer remotely, and an FTP server (pure-ftp) to access the files easily and not pay money).