User Tools

Site Tools


opus:fall2012:dsherbur:part1

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

Keyword 1 Phase 1

Identification of chosen keyword: Current working directory

Definition

Definition (in your own words) of the chosen keyword:

THE WORD(S) OF THE DAY IS(ARE): CURRENT WORKING DIRECTORY. *Note: If you haven't read Unix for the Beginning Mage yet, some of the terminology might seem odd.

COMMENCE

The current working directory refers to the absolute path of where you are “standing”. To find out where, exactly, you are standing, type “pwd” into the terminal. You should get an output; if you don't, I'm sorry. This output will change as you change your position in the file system. The prompt will also change as you move around. To illustrate a few concepts, I have made a directory in my home directory called “cwd” (current working directory) and a few directories therein.

lab46:~$ mkdir cwd
lab46:~$ cd cwd
lab46:~/cwd$ mkdir file
lab46:~/cwd$ cd file
lab46:~/cwd/file$ mkdir music
lab46:~/cwd/file$ cd music
lab46:~/cwd/file/music$ pwd
/home/dsherbur/cwd/file/music

In the prompt, lab46 refers to the system's name (as far as this entry is concerned). Then there is a colon (:), and, if you are standing in or past your home, there is a tilde (~). The prompt can help you identify your current working directory without having to type pwd. The tilde refers to the path of your home directory, which is usually /home/username. Everything after the tilde and between the dollar sign is your current directory. If you are not in the home directory, or you are in a directory contained within the home directory, the prompt will not have a tilde in it.

lab46:~$ cd /
lab46:/$ pwd
/

I changed directories from my home directory to the root directory. The prompt no longer uses a tilde because root is not part of home, but rather home is a part of root.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1: Play

Keyword 1 Phase 2

Remote Host

Definition

A remote host is a computer typically refereed to as a server in a private or a public network. The computer or server will be located in a distant location. This server or computer can retrieve and store data and users can even access data off of them. A good example would be the servers located here at the business center when we log on and access files from home.

References

Demonstration

Demonstration of REMOTE HOST:

Our remote host is lab46. There is one centralized computer or server from which, via terminals, data is/are accessed. To demonstrate this, we will be examining the PS1 line. This line is a variable (notice the caps) that determines what the prompt looks like.

lab46:~$ echo $PS1
\h:\w\$

The “\h” (whack h) prints the hostname in the prompt. Furthermore, when I ssh into lab46 from my home computer, I use the following incantation:

dustin@balagog:~$ ssh dsherbur@lab46.corning-cc.edu

Lab46, or more specifically, lab46.corning-cc.edu is our remote host.

See: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

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.

opus/fall2012/dsherbur/part1.txt · Last modified: 2012/10/01 04:03 by dsherbur