======Part 1====== =====Entries===== ====Entry 1: September 17th, 2012==== __cd's lost sibling__ So, I was thinking last night if there was another way to navigate the file system besides using cd. Most unix utilities have specialized functions, but sometimes they overlap a little bit. For example, you can use cat to view a text file. You can also use more and/or less to view a file. Cat, more, and less each have their own niche that they fill; some features present in less are not present in cat. What features could this other navigation utility (lets call it go for now) have to make it different from cd? Could there be a need for another navigation utility? Cd does a pretty good job alredy, so I can't really fathom a need for another separate utility, but then again I'm not a wizard yet. I suppose there could possibly be some situation in which cd was not sufficient, though such a situation has not yet presented itself to me. *Brief intermission* After consulting with the Oracle, I can find no leads to another navigation utility. Indeed, cd leaves little to be desired and fulfills its duty with aplomb. I was wrong for ever doubting. ====Entry 2: September 17th, 2012==== Just a moment ago, I wished I was in vim. See, I was writing an entry and I forgot to capitalize the beginning of the sentence. As I noticed the leading letter was not with the stature leading letters typically have, I watched in slow motion horror as my right hand, my very own right hand, moved FROM the keyboard and TO the mouse. And the nightmare didn't stop there. Paralyzed by fear, I could to naught but look on as my possessed appendage wrought havoc upon my poor wretched soul. Then I saw movement on the screen; it was the cursor! It was moving to the beginning of the sentence! O, woe! O, ye gods, offer thy solace! I heard a click, and the offending letter was dispatched by a swift back-space. What had driven my hand to become such a devilish creature? Was it neglect? Had I done some great unforgivable wrong? I was so fixed on the affairs unfolding before me, that I had paid little attention to my left hand. Ever the opportunist, the hand, once stoic and obedient, began to stir; joining forces with the right hand, and, thereby, relinquishing myself of all control. I was at the mercy of two rogue hands, well-trained in the martial art of Type Kwon Do. There was a shift, and a character strike (a very effective two-hit combo) and on the grave of the former character, there the hands summoned a capitalized version (I believe it was an 'a', but I am very shaken from the experience and certain details may be lost on me). The right hand returned the cursor, via mouse, to the unfinished end of the line, and, as soon as it had begun, the calamity had ended. I wept for the moments lost. Moments that seemed like hours, hours lost forever. Had I been in vim, I may have avoided much of this great catastrophe. ====Entry 3: September 24th, 2012==== I just learned the importance of saving. Part way through lab 0x0, I noticed my trackpad was on (theres a little light right above it). I use a mouse since this computer is largely immobile, and, not wanting to brush it with my palm and interrupt the flow of typing, I decided to turn it off (theres a little button, too). So I push the button, and, lo and behold, the computer no longer responds to any input from the keyboard or mouse. I was unable to save the text file I was working in, unable to copy/paste into a new document, unable to even click the shutdown button. An hour's worth of work unsaved and gone like my ex-wife. fml ====Entry 4: September 26th, 2012==== Today I learned that echo doesn't really like newline characters. Whilst doing project 0x01, there is a point where you have to print the output of an incantation into a file in order to run it correctly. On my first few attempts, I was using echo in a manner such that the output was not the way I wanted it to be. The script wouldn't run, even though it was the same code. After cat'ing the file, I noticed that the text was absent of newlines and tabs. Let's have a look-ey, shall we? lab46:~/the answer.txt$ echo `rev sales | tr ^ ' '` #!/bin/bash # # Puzzle Box Script - This is an actual script that you need to run # in order to finish this project. # echo -n "What is black and white and read all over? " read response if [ "${response}" = "newspaper" ]; then echo "You are correct! Finish this project by providing GIMMEH with that answer" exit 0 else echo "That is not correct. You'll have to try again." exit 1 fi exit 0 # # wonk ot sdnammoc lufesu era )1(rt dna )1(ver # Siehst? Das ist nicht gut. Let's take out the echo bit and see what we get. lab46:~/nix/0x01/the answer.txt$ rev sales | tr ^ ' ' #!/bin/bash # # Puzzle Box Script - This is an actual script that you need to run # in order to finish this project. # echo -n "What is black and white and read all over? " read response if [ "${response}" = "newspaper" ]; then echo "You are correct! Finish this project by providing GIMMEH with that answer" exit 0 else echo "That is not correct. You'll have to try again." exit 1 fi exit 0 # # wonk ot sdnammoc lufesu era )1(rt dna )1(ver # Now THAT looks like a script. And, when outed to a .sh file and executed, runs. Also, when we went into /usr/bin and ran echo *, it returned text in a very hard-to-digest manner. When trying to use wc, the -l option might not have worked, but -w probably would have. =====Keywords===== {{page>unixpart1&nofooter}} =====Experiment 1===== ====Question==== We learned how to make a ghetto ls; can we make a ghetto find? Moreover, can we make an incantation that can find all instances of the search parameter in the entire filesystem? I'm sure there's an option for find that facilitates this function, but I want to brute force it. ====Resources==== man pages, growing incantations ====Hypothesis==== I believe, with the use of pipes and such, that this task can be accomplished. ====Experiment==== How are you going to test your hypothesis? What is the structure of your experiment? I shall forge an incantation to accomplish this task and compare my findings to the results of a function meant to do this. ====Data==== Perform your experiment, and collect/document the results here. Through the man pages, I have discovered an option to ls that lists all directories recursively (-R). Since we are searching the entire filesystem, this incantation should be performed in root. Putting the output from ls -R into this wiki would be stupid. We can, however, pipe that output into grep, argument grep with our search parameter, and viola (hopefully). dustin@balagog:/$ ls -RA | grep grep ls: cannot open directory ./proc/96/task/96/fdinfo: Permission denied ls: cannot open directory ./proc/961/fd: Permission denied ls: cannot open directory ./proc/961/fdinfo: Permission denied ls: cannot open directory ./proc/961/task/961/fd: Permission denied ls: cannot open directory ./proc/961/task/961/fdinfo: Permission denied ls: cannot open directory ./proc/961/task/968/fd: Permission denied ls: cannot open directory ./proc/961/task/968/fdinfo: Permission denied ls: cannot open directory ./proc/961/task/969/fd: Permission denied ls: cannot open directory ./proc/961/task/969/fdinfo: Permission denied ls: cannot open directory ./proc/97/fd: Permission denied ls: cannot open directory ./proc/97/fdinfo: Permission denied ls: cannot open directory ./proc/97/task/97/fd: Permission denied ls: cannot open directory ./proc/97/task/97/fdinfo: Permission denied ls: cannot open directory ./proc/972/fd: Permission denied ls: cannot open directory ./proc/972/fdinfo: Permission denied ls: cannot open directory ./proc/972/task/972/fd: Permission denied ls: cannot open directory ./proc/972/task/972/fdinfo: Permission denied ls: cannot open directory ./proc/987/fd: Permission denied ls: cannot open directory ./proc/987/fdinfo: Permission denied ls: cannot open directory ./proc/987/task/1103/fd: Permission denied ls: cannot open directory ./proc/987/task/1103/fdinfo: Permission denied ls: cannot open directory ./proc/987/task/987/fd: Permission denied ls: cannot open directory ./proc/987/task/987/fdinfo: Permission denied ls: cannot open directory ./proc/tty/driver: Permission denied ls: cannot open directory ./root: Permission denied ls: cannot open directory ./tmp/.esd-114: Permission denied ls: cannot open directory ./tmp/orbit-gdm: Permission denied ls: cannot open directory ./tmp/pulse-PKdhtXMmr18n: Permission denied oil-bugreport pgrep rgrep zipgrep greprev_.gif greprev.gif greplus.gif totem-bugreport.py greprefs ./usr/lib/xulrunner-1.9.2.28/greprefs: system-greprefs.js grep bogogrep.c egrep.awk ./usr/share/doc/grep: grep-maintainer grep_native_packages.py gedit-bugreport gnome-power-bugreport grep.info.gz grep.mo grep.mo bzegrep.1.gz bzfgrep.1.gz bzgrep.1.gz egrep.1.gz fgrep.1.gz grep.1.gz pgrep.1.gz rgrep.1.gz zegrep.1.gz zfgrep.1.gz zgrep.1.gz zipgrep.1.gz bugreport.vim ls: cannot open directory ./var/cache/ldconfig: Permission denied grep.list grep.md5sums ls: cannot open directory ./var/lib/gdm: Permission denied ls: cannot open directory ./var/lib/polkit-1: Permission denied ls: cannot open directory ./var/log/gdm: Permission denied ls: cannot open directory ./var/run/cups/certs: Permission denied ls: cannot open directory ./var/run/gdm: Permission denied ls: cannot open directory ./var/spool/cron/atjobs: Permission denied ls: cannot open directory ./var/spool/cron/atspool: Permission denied ls: cannot open directory ./var/spool/cron/crontabs: Permission denied ls: cannot open directory ./var/spool/cups: Permission denied While the incantation worked, it did report a lot of permission denied error messages (from ls). With more polish, these error messages could be trimmed out, but excluding terms is a more difficult task than I had initially planned for. Furthermore, I can not use find as a control, as it only searches the current working directory, and not the entire filesystem. ====Analysis==== Based on the data collected: * Was your hypothesis correct? * yep * Was your hypothesis not applicable? * I'm not sure * Is there more going on than you originally thought? (shortcomings in hypothesis) * Yes, there are directories that cannot be read by ls because of permissions. Each one spits out an error, and at the end, there are too many errors. * What shortcomings might there be in your experiment? * The experiment was flawless and a golden model of the scientific method. Although I totally shafted myself on the control, as my control method was not applicable. * What shortcomings might there be in your data? * There was too much data and no control. ====Conclusions==== What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made. It is my thought that many utilities that exist in linux today began as simple incantations. These incantations were imperfect and left much to be desired, and so, ambitious folk went to work modifying, tweaking, polishing, and adding functionality to these once one-line incantations.