The Shell

When I say ‘computer’, most people think of this:

However, when I say ‘computer’ to a computer expert, they think about this:

Vastly different right? Every computer expert a least has the basic knowledge of command line usage. The reason for this is that the command line is the most basic, raw, and primal way of interfacing with a computer, that allows for more complete control and higher productivity. To run firefox in a command line, you type:

onionchesse@hunger:$ firefox

As opposed for looking for an icon or searching a large list of programs (i’m looking at you windows 8!). This simplicity and powerful nature of the command line leads to huge increases in productivity. By the way, these blocks indicate snippets of command line ‘code’, which do not include the stuff before the ‘$’. So in this case, you would type ‘firefox’ into your shell.

Because of the major inconsistencies between the original (unix) and the skewed (windows) command lines, I will be talking the unix shell, which is ‘bash’ by default on most Linux, and osX machines. (Once using both enough, you will see why). Bash is a free and opensource derivative of the original command line interface, the shell (or sh). Bash stands for ‘bourne-again shell’, which is extremely appropriate, given its history. This article will cover most of the basics of using a shell.

To start your shell, just open up a ‘terminal’ program on your computer. If you are running windows, you need to install cygwin to get this functionality.

When you start a shell, you are ‘placed’ in a directory on your computer. Think about opening a file explorer in windows, or finder on a mac, you are pointed at a location on your computer, like my documents or my programs (in windows). To find out where you are on your computer, type ‘pwd’:

onionchesse@hunger:~$ pwd
/home/onionchesse

That output, the ‘/home/onionchesse’ is the current directory, or where I currently ‘am’. I can find out what files are in this location by using the ‘ls’ command:

onionchesse@hunger:~$ ls
bin Copy Desktop Documents Downloads Dropbox Minecraft Music Pictures Public Templates Videos

Hey, there are all my folders which are inside that ‘current directory’. Lets now try moving around! To move around, we use the ‘cd’ or change directory command:

onionchesse@hunger:~$ cd Minecraft
onionchesse@hunger:~/Minecraft$ ls
MagicLauncher_1.2.5.jar Minecraft.jar Mods TechnicLauncher.jar

The cd command moved us into the Minecraft folder, and ls listed the contents of the Minecraft folder, which has some cool jar files! (Pro Tip: You can press tab when typing out a directory name to autocomplete it if the name is unabiguous! Ex: ‘cd Mine<tab>’ completes to ‘cd Minecraft/’). Typing out ‘cd ..’ will take you back ‘up’ a directory, and typing ‘cd ~’ will take you to where you started! (This is called the ‘home directory’ on unix machines, and it is represented by the ‘~’). These little shortcuts add up until you can save yourself a ton of keystrokes.

Lets now create a text file! The ‘touch’ command creates a text file:

onionchesse@hunger:~$ touch MinecraftIsAwsome.txt
onionchesse@hunger:~$ ls
MagicLauncher_1.2.5.jar MinecraftIsAwsome.txt Minecraft.jar Mods TechnicLauncher.jar

Hey! MinecraftIsAwsome.txt showed up! Lets see what inside it! The ‘cat’ or concatenate command will print out files (as text) to the command line:

onionchesse@hunger:~$ cat MinecraftIsAwsome.txt
onionchesse@hunger:~$

Oh no! Nothing got printed out! This is because there was nothing in the text file to begin with… We need to fill that text file with information to print out. Next week, i’ll talk about i/o redirection, which will allow us to easily write to files from the command line! In the meantime, open up Notepad, Word, or Microsoft Paint and edit that file the way you’re used to. Just make sure to save as a text file!

-[onion] chesse

7 comments

  1. As a novice computer user like most, I feel that understanding the basic using’s of a computer’s command line is important to understanding how a computer works on a more basic and more fundamental way. Perhaps telling viewer’s how to access the command line and giving them a basic idea of why they might ever need to know about the command considering the commercialization of software.

    Like

    1. In windows, you can get a shell by installing cygwin from here:https://www.cygwin.com/
      In other os’s, you can simply open up a ‘terminal’, it should be preinstalled.

      As for why you need to know about the shell, that question’s answer cannot be fully understood without actually using the shell. Go out there and try it out, and don’t give up at the first sign of hardship, its definitely worth it!

      Like

  2. coming from a person that knows nothing about the inter-working of a computer, this is amazing. I’ve always been mesmerized by the people who know why a computer works, as opposed to me who just uses the computer. Nice introduction to computers!

    Liked by 1 person

  3. You are amazing! Clearly, you are extremely knowledgable and passionate about computers and I love how you took that and transferred it into your blog. It is rife with credibility! I love how the format is structured as a how-to, complete with pictures for each step. I had no trouble with losing interest or getting bored or anything like that! I really enjoyed reading your blog because like most, I’m not a computer expert by any means. I can use one to get by, but I would love to learn more about the why’s and the how’s behind them. This blog is an incredible start for me. Great job!

    Liked by 1 person

  4. I know nothing about computers except that when I click on things, stuff happens. I really enjoyed this post as I don’t usually stop to think how my computer does what it does. This post was very informative and easy to understand. I was able to follow along with your tutorial step by step on my computer and I liked that you included screen shots of your terminal so I could make sure what I was doing was correct. I definitely feel smarter and more computer savvy after reading your post! Keep up the good work!

    Liked by 1 person

    1. Thanks for the feedback! I will continue to use things like this as much as possible, so readers can follow along ‘at home’ and keep up with the examples! And if anyone has trouble, they can reach out to me in comments and on my ‘contact me’ page!

      Liked by 1 person

Leave a comment