User Tools

Site Tools


CHRIS' spring2018 Journal



My name is Christopher, but you probably already know that. I really like to make things and learn new things but that means that my interests range very widely. It seems like there is never enough time in the day. Some of my more specific hobbies include 3D Printing, Building and Flying Racing Drones, Biohacking, and a variety of outdoors-y stuff (balance is important).

I think the coolest thing that I have done is my biohacking. I am a cyborg. At most I had 4 implants in my left hand. 3 RFID chips and 1 magnets. All of which had a variety of purposes. Ask me about it at your own risk :)

Other than that I am pretty run of the mill.

unix break2


Filler text- your entry goes here; remove this line to receive full credit.

unix week12

I am not even sure any more

I have to say that I have pretty much hit my breaking point with this stuff. I am trying very hard to contuine to learn but at this point it is just starting to feel tedious. Its not that things have gotten too hard or are boring. There is still so much cool stuff to explore but at the same time I do not have the enegery to do so

When I took up this class at the beginning of the semester I was really exicted to learn about something that I used everyday. However it is constantly an uphil battle. All of the subjects that I desperately want to avoid learning (Calc II, Chem, Physics) are all just kicking my butt. It has gotten to the point where I am just too burnt out to try to comprehend the material and I resort to just looking for patterns online. Anyways, it's just the same old story.

I guess we should get to some actual unix stuff now.

This week we are scraping some data from a webpage, formatting it, and then sticking it in a table. This will all be processed into a nice little graph. Let's get to it.

First things first we need to wget the webapge. That does not seem adaquate. There is just whole mess of code for us to try to filter out. So I wonder if there is a way to tell wget or curl to only download a specific selectin. Sure enough, sed to the rescue.

I am just going to pipe the status file into a newfile that only contains the data that I need. I can trip out the sections between the two different code tags with

 ... | sed '/<pre class="code">/,/pre>/p' 

I think that is a really nice way to do it, and no regex!

Further more, the process can be stream lined with “curl” instead of wget. I know realize the differnce between the two. wget will actually download the page while curl will simply output the raw file to stdout. Both handy in their own cases

Another trick that I am trying to use again is just putting the output from my grep into an arrya directly. Hower ever this is not working the way that I am thinking. Instead of putting each matchinto it's own seperate array, it just puts a whole string into the first index. More tinkering is required.

So it turns out that all I needed to do was just wrap in some (). Was not thrilled.

I have made some more steady progress on the gtfo project and I haven't really learned anything new on the bash side of things. At this point in the semsester it really is all about using what we know which is pretty cool. I did become a little more familiar with regex which is good

On a brief side note, I also tried to keep all of my major variables the same character length, just for fun. Funnily enough, I was actaully able diagnose a spelling error which caused my program to fail. So this might be a best practice sort of thing if I can manage to adhere to it.

April 5 - 11

Alright so I think that I am allowed to be editing this journal. I am not entirly sure though.

No wait I think that I am supposed to be good. That's good.

So this week we are messing with some X window stuff that I still have yet tofully understand but that is okay. I know that we were given an extension on gfto0 but I honeslty I have no interest in touching that again. I would perfer to just take the bonus points and move on.

Besides, I really want to make some pretty art. So far so good. I am taking a bit of a reverse approach to gtf0 simply because I want to.

Instead of making the mouse move I am first instead starting with maximzing the window. I feel that will just help things move along, plus it will help reduce learning overlap

I have found that while I am fine working in a group, I learned best when I am working individually. As long as I can still get all my work done I see nothing wrong with that.

On a minor side note. I just killed my X server. So that was cool. It happened when I tried to resize a window. I am thinking that happend because I tried to resize something too small I honestly have no idea.

Another clever hack that i am coming up with is how to maximize the window. I found out that you can specify negative values for the warping. All I need to do is have the mouse move and click the maximize button. That will work everytime without any need to get the display width or display height that will make things a little bit easier. However that is a little bit hacky

I don't really mind though. It works so I am happy. It will just have to rely on some dead reckoning. Thankfully, these are computers, not the real world, so dead rekoning will work almost everytime.

So now with the hard thing out of the way all I need to do is make my mouse move around a little bit.

unix week10

March 22 - 29

Alright here we go. Week 10 home stretch baby.

This weeks project looks a bit easier than last weeks which is welcome. The first thing that we are going to do if figure out how to properly cache a file using the 'tmp' directory.

I beleive in the 'pigen' script from the spf0 project there was some usage of the tmp directory.

It looks like we can use the 'mktemp' command to do this which is very convient. According to the man page for mktemp the command “create[s] a temporary file or directory”

you can run it from the command line just like this. See what happens.


Mktemp also gives you the option to create a temporary directory. In this caase we just need a single file though.

Another really really nice thing that I have figured out is how to conditionally set the “-x” option for bash. If you don't know this basically gives you really nice debugging out put from the script that you are running.

I learned this little trick from an mailing list. You know who you are.

The code looks a little something like this.

 set -o xtrace 

This of course would have to be wrapped in an if statement so you could do something like this:

	if [ ${1} == "-v" ]; then 
		set -o xtrace 

I have noticed one issue with this though. The further down you put some logic like this the more debugging out put you may miss. I have also noticed that even that might not be consistent. I need to do some research to see how setting such a variable effects the output of the script.

However due to the time constraints that I am facing this week I might just have to write it off as a half baked feature.

Update: I was actaully just beinga dummy and wasn't reading my code correctly.I stuck the logic into a nice little function which as long as I put it at the top of my script I can now add some more verbosity to any of my projects!!o

Want a super easy way to create a help dialog?

egrep '^###( |$)' ${0}  

Check this out. This nice little bite will search for all the lines that beging with “###” and end with a space. I need to use this this is super helpful.

Somthing else that is pretty helpful. Is io redirction to itself. You can do soemthing like this.

 echo "This is an error" 1>&2 

This basically redirects standard output to standard error

Protip: !! is the previous command that you have typed.

Does anyone know who to make printf just be able to print a certain number of the same character? I found that it would be very useful when having to work with making tables and such. I couldn't find any functionality that I like so I decided that I would just write a function. It looks like this

	function repeatChar () {
		for count in `seq 0 ${2};
			printf "%s" "${1}"

I know that it probably isn't the best way to do it, but it works and it isn't too messy.

Another issue that I was running into is using my arrays. I really like the ideas of having all of my data placed in array because it makes manipulating it a little bit easier. However my issue is that that command I was using was not behaving the way I thought it should be.

my command looks like this now:

  scoreAr=($(sed -n "${topLine},/^$/p" ${statusFile} | cut -d ":" -f1 )) 

Of course there are always going to be those very choice situations where you think, man I really wish that I could do “insert thing here”

In this case I really wanted to be able to convert all letters in my string to uppercase. Thankfully the man page of bash told me how to do exactly that!

 ${stringHere^^} #for upper case
${stringHere,,} #for lower case

unix week9

March 14 - 21

Alright so the biggest project that is going on right now is the dreaded pwn0. I however am not too worried because I am learning lots of things

First of all I learned a neat little hack to find out if a variable is an integer or not:

 if [[ ${1} -eq ${1} 2> /dev/null) ]]; then fi 

Basically what happens here is that bash compares the two numbers and if they are integers then that statment will evaluate to true. However, if they are not ints then you can't use the “-eq” option so instead it will just give you an error. That is the reason we are redirecting to /dev/null

Another useful trick that I learned is for making help statments. If you use “sed” then you can make bash only look at only a fixed number of lines. In this case we can print out only the the lines that the help section is on. I prefixed my help section with “##” to make it clear that is was different from just a normal comment. I then used “tr” to remove them like so:

 sed -n "9,33p' ${0} | tr -d "##" 

In this case, the “-n” option is telling sed to supress the printing of the pattern space. “9,33p” is the range of lines that we need. Finally “${0}” is the name of the script so that sed knows what file to work on.

Another fun thing that I get to play with in this script is arrays We talked about arrays a little bit last week but this is one of the first projects where I can them being actaully helpful.

In this script I had originally created two different arrays but then I realized that we could just make one. Then add and remove the arrays as needed. The only thing is that we will need to do some sorting which won't be too fun. However it does look like there is a built in sorting array function

Now the issue that I have run into is that I cannot reassign my variables. I have 2 predefined variables that I would like to change based on the two inputs that I get from the command line. However, when I try to set my predfined values they simple do not change. I am not sure if it is a matter of casting or if I am not getting the syntax right or what. This is my code:

So in turns out the issue that I was having was this:

Lets says you have a nice little variable here


Then let's say that you want to change the variable based on the condition of an if loop.

if (( 1 > 0 )); then 

This won't work as I found out. That is because when you put that dollar sign infront of the variable that is essentially a command expansion. It is essenitally subing in whatever number happens to be in the variable “val.” So while the code above may make sense to you, this is what bash sees:

if (( 1 > 0)); then

We can all agree that doesn't make any flipping sense and bash will jsut yell at you.

So the correct answer is:

if (( 1 > 0 )); then
	val=2 #NO DOLLAR SIGN!!!

While this seems obvious in retrospect (most things do), I am glad that I took the time to figure it out.

Now pretty much the onyl thing that I have left to do is sort the array. Of course I need to put in some fucntions in there and we should be good to go.

However the issue now is that I need to figure out how to actaully sort the array. I know that I could probably figure out a sorting algorithm pretty easily but I think that there is probably an easier way to do it with 'sort' but I am not sure. :

So fun thing. I found a really nice and elegant way to sort my array. It looks something like this.

 arraySorted+=(`echo ${ogArray[@]} | tr " " "\n" | sort -n`) 

What the above code is is taking the original array and printint out each of the numbers within it. Then 'tr' will replace all of the automatically inserted spaces with new lines. This is what the 'sort' option is looking for. So then when we pipe in all of our numbers to sort, because we specified the “-n” option, it will spit out all of our numbers in the correct order from least to greatest.

With these nyumbers we then put them into our new array with is caleld “arraySorted.” This is done with the “+=” operator dilo. This can be very helpful for a variety of things.

It should also be noted that this is not really a correct sorting algorithm and it kind of a hacky way to do things. It would be helpful to be able to just stick the values back into their orignial array but that would require more work that I do not have the time or energy to do

Another cool tip, if you run your script with “bash -x” then that will provide some more helpful output for your pleasure..

I found another cool command as well and that is called 'fold.' I needed a way to put in a new line after every character. That way I could have grep be able to only print out the lines that I need. I did this with fold and the below coded:

 echo "${input}" | fold -w1 | grep -o -m4 "${patternToMatch}" | tr '\n' ' ' 

The above does this. It pipes in the input into fold. In this case 'input' is just a string. 'Fold' sets the line width to 1. That means that it essentailly puts a new line after every character. Grep is looking for these new lines.

However, there is a downside. It will only work with a pattern of 1 character long

Oh well. I will call that a week

unix week8

March 8-15

This week's project is called upf1 and boy is it fun. I have to say that thesere require a little more lateral thinking than most of the projects but that is under standable. I was actuaully able to resue most of the code from last time in terms of the house keeping and setting up of the files.

However, I did make a nice little addition. I created a function called “makeCli”

It was a nice little single line function:

 makeCli() { echo 'echo' ${1} > task${2}.cli;}

This usage goes something like this:

 makeCli '1920 yd | yd2mi -d "" | mi2km -I " " -d " -> " "' 0 

The purpose of this function is basically to replace the constant tedious echo within an echo and then the outputting of that to the file. The two variables (${1} and ${2}) represent the string that we want to put into the cli file that we are making and the number of the task file that we are creating. In the example above we would be making a file called “task0.cli”.

This isn't super neccecasry but it does speed things up and make the script look a little cleaner. However to the untrained eye it might make the purpose and the function of the script a little more cryptic

I also jsut realized that I didn't ever do the usr0 project. Whoops.

Something new that I am going to start doing is making a reflection file. This can be submited with just the submit tool because it allows you to give the system non-required files.

Another great tool that we will be using a lot of is:


This is like the big boy version of echo. Some simple examples:

<code bash> printf "Hello" </code>
<code bash> printf "Hello\n" </code>
<code bash> printf "Hello\t" </code>

There is also something called a format specifier. It looks something like this:(order matters!!)

<code bash> printf "hello %d" 10 </code>
This would print out "hello 10"
In this case "%d" is an unsigned integer
(fun fact, we can do a hack and get it to truncate our floats)
(printf "The number: %d\n" "3.14141" 2> /dev/null)
(This basically redirects the error into the null

<code bash> %s </code> - this is for a string
<code bash> %d </code> - (again) unsigned integer
<code bash> %x </code> - this will represent the value in hex
<code bash> %c </code> - sub in a character

Another useful thing that printf can do is generate and justify spaces and stuff: (Check the project page because this is too funky to explain well“:

<code bash> printf "Testing: >>%4d<<\n" 47 </code>
This will output "Testing: sting: >>  47<< "
<code bash> printf "Testing: >>%.8d<<\n" 47 </code>
<code bash> printf "Testing: >>%*d<<\n" 6 47 </code>
>>    47<< 

unix break1

Febuary 15-22

Alright so first break week. I am currently having a great time in a Boulder Colorado.

I am going to try to do some LINUX/UNIX while I am here.

I have a few projects that will help keep me busy. One of which the pbx3. It looks like this is going to be another pbx that requires lots of zipping and unzipping which is cool I guess.

Another on going battle that I have had wit hthese puzzle boxes is with gunzip. The darn thing always wants totos to have a a “.gz” suffix on the end of it and I don't want to give in. IThere has to bee some way to have make it ignore the stffix that is on the back ofth e file name but I have no I dead how to make that work.

I hvaea looked through all o the man page and there is no mentions of ignoreing the suffix. I have also looked on stack over flow and there is nothing abouut it there either. At least not the solution that I am looking for. I wonder why this is the case . Why would you make a porgram that only works tih “.gz” suffixes.

TI read that suffixes most of the time arejust used so that the human users of the computer can no what type of file they are looking at. The computer doesn't need to know the uffix. So once again, whymake a program thato nly works with .gz.

So I guess for now I am just stuck renaming the files.

But no wait. There is still some hope. I found this code: for file in datapart?; do mv “$file” “$file.gz”; done

This basically makes a for loop for each of the file that start with “datapart” and then performes the required action on them. It's super slick and I think that this can probably work with many other commands other than just “mv”.

Turns out you can use this for other commands. This was also used in my pbx3 file to untar the files as well as rename them.

I still feel like with a lot of these things that there is a better way to do them.

unix week7

March 1-7R

In other news, I am trying to create a bot army in the irc chat. If anyone reads this journal then they will know that it is me.

Today we are goni to be talking about some awesomet things caleld functions

They are pretty standard things really;

function testingFunction(){
	echo "this is my function."


Remeber, programmers are lazy. They don't want to have to write something more than once.

Oh snap I only have like 75 words.

I guess we can use this journal as more of a vent session.

For the first half of the semester I have been rank 1 but I just checked today and I noticed that I am now number 7. That is a bit more fair and I think that it is too bad. I just don't have the time to dedicate to this class.

Lately I have been doing nothing but homework all the time and I am so sick of it. I don't know how long I can keep going like this. I just want to be able to read and write and presue my own techy passions. Yet here I am. I come home from class just to do more homework for classes that don't even interest me. This is the only class that I really enjoy and even then Ican't deidcate that much time to it.

How long can someone like me go on doing something that hate and ignore their true passions. It sounds dramatic and it is. But I am just so damn sick of this.

unix week6

Feb 22nd - Mar 2R

Alright kids back on the horse once again.

Useful thing #29

mkdir -p

This will prevent mkdir from yelling at you if you already have that directory created.

Usefult thing #30

[ and ]

First of all check the man page for this. Just do “man [” without the quotes. These are basically how you evaluate conditions. You can do number comparisions and string comparisions. You can also see if files are newer or older, check to see if things exist, see if there are certain permissions, if something is a directory.

For Example: See if spring2018 exists as a directory

[ -d “spring2018” ] && echo “exists” || echo “Does not”

See if the directory exsists and print if it does.

[ -d “spring2018”] && cd spring2018 || (mkdir spring2018; cd spring2018)

This will make the direcotory if it does not exsist and if it does then it will cd into it.

Another example.

[ -d “spring2018” ] && [ -x “spring2018” ] && cd spring2018

If the file is a directory then check if the -x bit is set and then change into it

NOTE: That whitespace matters. If you have something touching your stuff then that is not good.

Useful thing #31

if then fi

This command lets you do what is basically the job of the “&&” an the “||”. However, this will let you do some more complex things. Most of the time it looks like this

if [ $var1 -lt $var2 ]; then

  echo "That is a true statement""


  echo "That is a false statement"

fi (remember whitespace matter!)

Useful thing #32


This is bascially like any other progamming lanauge else if. The only execption is that you must follow the elif and the condition with a “; then” look up the syntax if you don't get it. Sorry bro. Don't feel like typing any more

So then this all begs the question. How do we determine if the variable that we assigned is a number or not a number. There is something that is called a Regular Expression.



This stands for regular expression. This is a way to match patterns within some text or string.

They are a set of synmbols that can be used

List of Regs:

. ---Any signal symbol (just like the ?)
* ---Match 0 or more of the previous
? ---Match 0 or 1 ofthe previous
^ ---Will match the start of a line
$ ---Will match the end of the line
\< --Will match end of the word
\> --Will match start of the word
[] -- Character classe (e*)
[^ ]- Inverted character class do not match any of 
-----Below are not super standard-----
+ ---Match one or more of the previous 
| --- logical OR
( ) - Group regex

Some examples:

How many words are there that are only 4 characters long
WRONG: cat words | grep '....' | wc -l
This will match anyline that has at least 4 letters so taht won't work
CORRECT: cat words | grep '^....$' | wc -l
Those two symbols are reference to the end and the beginning of the line
CORRECT: cat words | grep '^[stST]..*..e$' | wc -l
This will return all the word that are at least 5 characters, starts with 	  and S or T and ends with an e
CORRECT: '^[0-9][0-9]*' This will check to see if there is only numbers fr	  in the whole line

CORRECT: '[0-9][0-9]*$' This will pull out the numbers within a string.

Alright lets talk about some loops

Using loops we can repeat blocks of commands.

We are going to be talking about 3 loops in particular.

But first some basic loop theory:

  1. —Basic Loop Therory—
  2. top driven
  3. bottom driven

Top driven loops have the ability to run the loop 0 or more times Bottom driven loops have the ability to run the loop 1 or more times

—- Numeric Loops —- The first thing that we are going to talk about is the “while” loop. It does something while the given condition is true.

while [ condition ] 

Another type of loop is the for loop

for ((start; loopcondition; step))

The reason that we ahve the “1)” is that in bash the double “()” will make a “pocket of arithematic.” So basically allows us to use the symbols that would otherwise be interperted as a string.

Side Noted: if you see something in a sqaure bracket, that denotes the default value;

The “let” command is the way to reassign variables.

Additioanlly, you should always put an “exit 0” at the end of your script.

—- List Based Loop —- We also have something called a foreach loop

for var in list; do

This will run through the list of values and it will do something for each number of those things in said list.

Useful Thing #34

Comand Line Arguments

There is something called teh ${0} variable. This is the name of the script. that is pretty useful. There is also the ${#} which is the number of argumements There is also the ${*} which is all the arugments There is also the ${@} which is just like the same thing as ${*}

if we want to access the arguments of the script then each ${num} is the next argument

There is something cool that you can. If you make the script aware of what it name is when it is called, you can modify the behavior which is pretty powerful.

unix week5

Feb 08 - 15

Okay so this is the week 5 journal and there isn't really going to be anything technical. This is mostly beacause while I do enjoy and love this class, it is not one of my priorities. This is more of a hobby if anything. I find it fun and it is a really natural way of thinking. I do not consider this work.

This week in class we did a project called “uka0.” This was basically another puzzle box but with a different graphic. I have a feelig that there are more effieent ways of doing the puzzle boxes but my method works and that is what is importnat.

Right now my current method behind the puzzleboxes is to split it into the 4 pieces, rotate, reverse them, and then stick them back together.

I have a feeling that there is probably a way to do this dynamically. By dynamically I mean that instead of spliting the file 4 differnt times and then having like 12 different files (the process of splitting and rejoining them is quite intense), there is probably a way to just extract the parts you need and then inerset into a new file. That way all you have to do is run the script and then you would have the completed file.

Right now when you run my script, you will be left over with a bunch of different junk files. I am sure that if I wanted to I could find a way to delete all of the files execpt for the most important ones.

Either way that is all the I got for this week. I am exhausted.

unix week4

Feb 01 - Feb 08

Okay so week 4 here we go. Not going to lie I'm getting real burned out here. There is too much crap to do.

I am all about that customization so I wanted to make a script on my laptop tht will open up 4 terminals in the 4 corners of the screen. After that I want them to automatically be able to login to lab46. That way all i have to do is run a scipt and then I will be read to roll.

The bread and butter of this script is the “gnome-terminal” command. It has lots of options that you can pass to it. In this case I am using the “geometery” option. This allows you to create a terminal a specific number of characters high and wide. Then it allows you to set the position.

After that option you can just give it another command, in this case the “ssh” command to get into lab46 (for which I have another script).

The next step is a way to generate the ssh keys. That way I don't have to put my password in the file to keep everything secure.

Basically wish ssh key's you don't have to enter your password into the prompt every time you try to log in to lab46 from and outside place.I will be using the “ssh-keygen” command. This will generate a public and private key.

Once that is generated then we have to copy the public key on the server we want to use. FOr that there i the “ssh-copy-id” command. which is then follwed by your “”.

At this point everything should be all set. Now to login to lab46 all i have to do it type in “ssh” No password required.

This also works with the “scp” command so that means that it is almost trivia to transfer files from my laptop to lab46

Helpful Thing #20

scp /local/file/tobetransfered

I already knew about the scp command from a while back but having the ssh keys be paired along with it makes it really nice to use. The syntax can be a bit tricky though because of the “:”.


- Special symboles that we can use on the command line. they are basically used to descibrie patterns. They are:

  1. * = match 0 or more things
  2. ? = match exactly 1 of anything
  3. [ ] = (character class) match any 1 of enclosed.
  4. [^ ] = (inverted char. class) Do not match any 1 of enclosed

(dont use commas)

Some examples:
ranges: [abcde] , [a-d], [a-zA-Z], [0-9]
Some more examples:
ls -1 /bin/???? | wc -l -> will tell you how many 4 character files in are bin
ls -1 /bin/c??? | wc -l -> will tell you how many 4 character files there are that start with "c" in the /bin dir.
ls -1 /bin/?[aeiou]?[aeiou]? | wc -l -> will print the number of files in the bin directory that 2nd and 4th character is a lowercase vowel and is 5 characters long.
ls -1 /bin/????* | wc -l -> files that are 4 characters or longer

ls -1 /bin/*p | wc -l -> files that end with "p"

Useful Thing #21

od file

Will covnert a file to hex so that you can check it out. This is helpful for checking out the binary hex code.

Useful thing #22

grep (dear god grep)

Everything is string data to 'grep'. So it willl search for patter that is given to it by standard input and then out the line that it on. It will return that linet hat contains that substring.

it has some options:

  1. o will return just the substrings taht matches
  2. v will ommit all the lines that dont contain that substring
  3. i will do a case insenstitive sub string search
  4. q makes it quiete

Useful Thing #22

&& and ||

These are the 'and' and 'or'. If you want to run two commands together then these are the good things to use. && Will only run the next command following the previous one if the fist command was successful. The || will run the next command for 'true' || 'false'. This will allow you to run something based on the conditions of whether or not the previous command was successful.

Examples: - echo “hello” | grep -q 'the' && echo “true” || echo “false”

This would do somethingthat I can't really remeber

This is other wise known as an “and/or” conditionial change.

Also we are learning about VIM. I have been writing all these jouranals already inVIM because I am a nerd. So if you are reading this journal because you are trying to find somethign about VIM then you probably won't find the basics.

cool thing though: if you prefix a command with a number then VIM will run that command that many times.


using “w” in command word will jump through incrementally a line. using “b” will take you back a word. uuing “G” will take you to the end of a file. using “g” will take you to the beginning of a file. using “{” and “}” goes back and forth by stanza/paragraph


  1. dw delete word. (You can still put the number in front of the thing)

also yank and paste and cut and all that good stuff


Shift ZZ will help you get out of VIM. This has been a brief and unorganized into to VIM.

Useful Thing #23

Want a multiline command? type " \ "

Useful Things #24

screen -x

This will allow you to attach over a screen session. For example if weat at home and there is a screen session that is running on a pod, then you can over attch that screen session on the pad so what ever you type on the pod you will also see at home. It's like a screen mirroring. Wemux and tmux works on a simliar prinicple which is pretty cool.

Usefult things #25

PS1='$ '

This will make it so your current working direcotry does not show up. This is basicawlly the variable that control how your prompt looks. In the case of the example it will be setting to just be a dollar sign. There a bunch ofother speical sysmbles that can be found in the bash manuel page.

Another useful tip is that generally system variables are place in ALL CAPS. There is nothing that is presenting you from making variables in all caps but generally it is best practice to avoid them. Most of these enviornmental variables are stored in a place called the “.bashrc” Beacuse there is a dot infront of the file name that means it is hidden. There is another file that is called the “.bash_profile”.

There is a file that is called the “inputrc”. This is a config file that will allow you to set key bindings to various commands.

Useful thing #26


These are almost like shortcuts kinda. You can reassign your own “commands” to specific commanands that already exit. On lab46 a good example of an alias would be the “rm” command. When you type in “rm” it is really running “rm” with an argument to prompt the user if they really want to do it.

So basically if you want to creat your own quick command that consists of my different ones or if you want to reassign an existing command a new name you can do it with aliases. There are stored in the basrc I am pretty sure but i am very tired so. If you want to make an alias with more than one command then you can sperate them by semi-colons.

Just keep in mind thought that they are not relly meant to do complex things. Mostof the complicated stuff should be handled by shell scripts. You should limit your use of aliases to just commands that you want to shorten or commands that you always want to run with specific options. They arent very good at doing complex things.

"Useful thing #27

set nocobbler

Using the “set” command you area able to enable different features that come built into bash. On of these examples is nocobbler. So if you turn it on, it will prevent you from over writing the contents of a file by accident.

Usefult thing #28


Did you know that there is an interperter for the C lanauge?? Well there is. If at the tope of a file you type “ #!/usr/bin/tcc -run ” that will tell bash what to run an interpreted file with. So you can do that same sort of thing with python too. There is however a performance hit. Tcc is also a complier, it just happens that tcc includes that interperter. Tcc has smaller executable files but at the same time it inlucdes less of the C-library and is less optomized than gcc.

But wait, there's more. Another complier is called 'clang' which is comparabled tothat of gcc.

unix week3

Jan 25 - Feb 1

Okay so I definitely tried to edit the week 2 journal because I am a mess and have no idea what day it is becuse of all of the homework that I have needed to do oh my gosh please send help.

Anyways. This week I am working on pbx1.

So far the first thing that I had to do was figure what to do with the .html file that was give. It was obviously a xz archive but it had the wrong suffix so xz didn't like that at all. I probably should have checked the man page to see if there was an option to make xz ignore the suffix but oh well. I just renamed it and that worked too. I am very tired.

The first part of the puzzle box was easy enough, just use your “head” and your “tail.” The tricky part though is figuring out how to split a file down the middle. I think that I will need reguar expressions for that

There is one command that looks promising though and that is the “cut” command. I am struggling to find out what it means by “field and Delimiter.”

However I did a quick Google and found some examples. It was exactly what I was looking for!

Useful thing #11

cut -d ' ' -f ' ' --complement

The cut command allows you to basically write certain sections of a file to standard output. The nice thing is that you can choose where it the command will “cut up to.” The character that determines where the command will cut to is called the “delimiter” and is denoted by the “-d” option. Another argument that is required for performing such a command is the “-f” option. This denotes “field” and in my case I set it to “1.” I don't really know what this means but it warrants further research. Additionally the “–complement” argument will make the “cut” command return the inverse of what it would otherwise normally do, pretty handy.

Useful Thing #12

paste -d ''

This is basically the opposite of of “cut” which means it is pretty self explanatory. It will merge the same lines of a file together i.e. it will take line 1 of both file1 and file2 two, smoosh them together, and then repeat. However, there was also a bit a of a hickup. I noticed that while doing pbx1 and using this command that it was leaving a “tab” character inbetween where it merged the two lines. Once again we have delimiters to the rescue! I had a feeling that if something lke that existed for the “cut” command then it would also exist for the “paste” command. Once again it was the “-d” arguement, then specify and empty string and the rest was history.

On another note, because computers are fun there is also more than one way to do this. Originally after I had the fils “pasted” together I had used the “tr” command to delete all the tab characters which is denoted by the “\t” escape sequence. Either way works but it is the best idea to use the “paste” command to it's full potential.

Useful Thing #13

md5sum FILE

can be used to manually check the check sum of your work! This can be compared with the checksum found in the MANIFEST file that is in the project directory.

Class time 01/29

File System stuff!!

There is lots of good stuff in the root directory. One of the first things is the *bin* directory. This contains all of the basic commands that you need to make a

These are stored in the *dev* block device - the Raw hardrive data device Chracter device - formatted device

A few other notable devices: Zero - just returns a bunch of 0s when you do something with it Null - just gobbles up data that you send it Random - returns some sudo random stuff

Another fun thing is that the that terminal is also a file/device. So if you type ing “tty” it will returnt the device of your terminal. So that means that you can actualually redirect stuff to our own terminal. You can do something like echo “hello” > pts/64, or some such.

Next we have the *etc* which is short for what you think. It has become mostly for config files and imporant start up screips and stuff. Lots of stuff with the “.conf” suffix.

A notable file within within etc is “shadow” which holds all of the encyrpted passwords. Nobody has access to this except for the OS. The passwords in this file are all stored in an encrypted manner which is the product of their salts and hashes.

There are lots of other directories that have lots to do with some system config stuff. A really important one is the *lib* directories which contain many of the libraries that the system needs to function. This includes the “C” library which again is super important.

Next up is “media” and “mnt” which is where external media is mounted. This is different from windows because UNIX wants everything to be accessible from the / dir where as windows makes it a seperate thing. You can mount and unmount things using the same commands.

“Opt” is another place where add on files could be put. Don't worry about it.

“Proc” is short for processes and wasn't originally there. They came up with a way to map system processes to files which goes well with the “everything is a file.” All of them have some sort of number and owners and you can look at them, but that doesn't really do anything. Still neato to poke around though.

“/root” is where the home directory for the root user is. You can't go in there, the door is locked.

sbin contains commands that are mostly used by the admins and the system. Not super helpful but good to know.

“usr” has some of duplicates of the root directory. One of them is another “bin” dir. It isn't system critical stuff but this usr/bin contains a lot of nice stuff to make the system more readable. There is also a dir that includes the standard files you need for programming.

If something has a 'd' at the end of the file name it normally denotes a 'daemon' or a server.

The stuff that is found in usr/local is often the stuff that has been modified locally by the user. This includes commands like ptt and wcp.

/var is short for variety and is a nice collection of random things. var/log is a really important place because it holds all of the logs for the system.

Useful Thing #15

apg for passwords

will generate you a random passwrord

Useful Thing #16

cat cpuinfo

Will tell you some stuff about your specs.

Usefult Thing #17


This lists the mount points of all the different files. If you notice the home directory is mounted in a different place than the /root dir. This is by design so that way if you mess up your home file you can login as root and fix your mess.

System Variables

In order to declare a variable name you must do something like “myvariable=” stuff and things“ It is important to note that there is no space between the ”=“ and the ” “ ”. You can then access whatever is in the variable by using the '$' infront of the variable names. This is a local variable and will exsist until the session ends. There are also environment variables which will still go away at the end of the session, but they will be in the config file so they are just created again. They can also permeate all shells and subshells. In order to make something an environment variable you must export it with “export myvariable”. This will add it to the config file so taht it won't go away. There are some built in env variables whichcan be listed with 'printenv'. The built in ones are noramlly in CAPITALS.


- * “ * double, half quote - * ' * single, full/literal quote - * ` * backquote, backtick

Half/double quotes allow for expansions. There are two types of expansions, variable and command. This basically allows you to concatinate strings and variables. It is best practice to use these quotes. You should also use curly braces ”{}“ so that the systems knows what the variable is.

Single/full quotes just returns you what is “literally” inbetween the quotes. example: '${PATH}things' will literally print out '${PATH}things'. You can also use character escapes with the backslash.

Backquotes allow you to do the command expansion. This bascially means that you can run the command within the double quotes. That is a really big things. For instance if you do ” echo “There are ` who | wc -l ` users on the system” “. It will return the number of users within the string that it prints. You can also assign variables from the output of commands. For instance *usercount=`who | wc -l`. Sdie note: you can also do $( ) in bash which is basically the same thing.

Control Characters

(ctrl + a) - the cursor goes back to the beginning. (ctrl + e) - the cursor goes tot he end of the line. (ctrl + b) - goes back one space (ctrl + c) - SIGINT (interupt signal) (ctrl + d) - generates and end of file character. (Better than ^C) (ctrl + f) - right arrow (ctrl + g) - bell (ctrl + h) - backspace (ctrl + i) - tab (ctrl + j) - new line (ctrl + k) - cut from cursor to end (ctrl + l) - form feed (ctrl + m) - carriage return (ctrl + q) - XON (ctrl + s) - XOFF (ctrl + n) - next command (ctrl + p) - previous command (ctrl + o) - enter + up command (ctrl + r) - reverse history search (ctrl + t) - swap characters (ctrl + v) - cut from cursor to the start of the line (ctrl + w) - cut word backward (ctrl + v) - escape (ctrl + x) - hop positions (ctrl + y) - paste from buffer (ctrl + z) - suspend/stop


The terminal has some sort of multitaskign system involved in it. You can the most common commands that you use for this is “fg” “bg” and “jobs.”

Useful Thing #18

fg, bg, jobs

Use these to manage the multitasking features of the terminal

Useful Thing #19

bc - the calculator

this is the built in calculator program for unix. It has many different functions and is super useful for base conversion. This can be used with “ibase=#” and “obase=#.” It also loads in the math library so you can use things like sqrt and trig functions.

You can also pipe things into the bc command which is very useful. Something like ” echo “2+2” | bc “ and then you could wrap that whole thing in a ” $( ) “ to make that number a variable! So that is pretty cool. It also very useful for doing math in Bash scripting.

Usefult Thing #19

$(( Math pocket))

if you just want to do some basic math in a command line or bash then you can put something in double paraenthiese. It is mostly used for very very basic arithmatic

As some unoffical useful things that i am sure will come later in later there is “cal” which will actaully print out a calendar in various forms. It's pretty funny because it will show where humans transistioned from the Julian to Gregorian or something like that. It shows just a little skip which I think was very thoughtful that the people who made cal put that in there.

Another one that is pretty helpful is “pom” which will tell you the moon phase. In this case today has a super moon type dilo going on so it just prints out full mmon. Another one was date which I is cool. These are my last few words to make 2048.

unix week2

January 18-24, 2018

Just started working on one of the first reall assignments. So far so good.

I have learned somethings about he IRC chat from a guy called Nathan.

Useful Thing #1

In irssi use "alt+#" to switch windows. "#" being a number.

You can do /window to make a new window. This will allow you to have multiple channels open! I am interested to see if you could set up some sort of notification system to check if there are new chats.

I also leared another useful thing with the “mkdir” command. In the adm0 project, it is recommended that you create a “projects” directory. However there are some more directories inbetween that you first need to created. Instead of creating them one by one, you can use the “-p” arugment.

Useful Thing #2

mkdir -p

Another strange thing. By using the “ls -sh” and “du -h” you should be able to find the file size. However all of the files for this week's assignments just return 4.0K. I did find something that workedthough

Useful Thing #3

du --bytes

Which just returns the number of bytes a file is. Very handy

Useful Thing #4

tar -c -f file_name.watevr

Makes a new archive. You can also use the -a command to pick specific files

I also figured out how to generate new files from the output created by “tac” and “rev” by uppending a “>” to the command and then the name of the new file thatyou want to create. Similarly, if you use “»” then it will append to the ouput to the given file

Useful Thing #5

“sort” is a very useful command for organizing text files! If you use the -h option then it will sort it very nicely.

Usefule Thing #6

sed 's/find/replace' file

This is the command that you can use to find and replace characters within text.There seems to be a lot of really poweful syntax that you can use for options. This seems like a pretty niche command but is probably very useful in some situations.

I have also noticed that the “-h” option for a number of commands often stand from something along the lines of “human readable.” So when doubt it might be a good idea to try it. After reading the man page obviously :).

Useful Thing #7

The command “fms” lists all of the people that have more than one screen session.

Usefule thing #8

There are three types of files - regular/ordinary files - directories - special files

Useful thing #8

the "wc" command can be used for counting things in a file

The -l returns the number of lines, among other things. It is very powerful when combined with a pipe. For instance “ls -l /dev | wc -l” will return the number of files in that particular directory. In this case 159. Another example would be “who | wc -l”. This would return the numbero of terminal sessions logged in.

Usefult thing #10

Pipelines!!! "|"

Basically a pipe line allows you to “pipe” the output of command into another command. The example that we were given in class worked like this. We need to outputthe MOTD with line numbers. That was pretty easy. Just looked at the CAT man page. The next part was a bit more tricky. You then had to pipe the output of the cat file into “head” with the -n which allows you to define the number of lines that it returns. So if I said -n 10, it would return the first 10 lines. In this case though we wanted to get the first 12 lines. So if we head with -n 12 that is what it will give us. But we just wanted to get the lines 9 through 12 and right now we have the first 12. So in other words we wanted to get the last 4 lines of thefile which we can do the tail -n command.

unix week 1

January 16, 2018

Hooray I get full credit! I am really digging lab46. I messaged someone randomly just to see what would happen and ended up talking with the CS tutor for quite sometime. There are just so many goodies to play with I am so excited! I am really excited for class tomorrow and hope that I can keep up with all my classes.

” and the “
journal/spring2018/cherrma1/start.txt · Last modified: 2018/01/15 11:37 (external edit)