Whether you are a casual computer user who uses Office for part of their work, a budding young design student who spends many hours at the computer, or just the average Joe who emails and uses Facebook or other social media, you ought to know what the command line is. If you’re just learning about the command line terminal for the first time, I urge you to roll up your sleeves and try some of the examples I’m about to provide. If you already know what it is and have tried it, but failed miserably, I encourage you to read on – I have a feeling it might just click this time (more advanced users can skip to the next post in this series). Trust me, the reward will be great.
It is no surprise that to the average Windows or Mac user, the command line terminal is like an unforgiving desert shrouded in darkness. Where is my start menu? Where are my icons? Where are my files? Where are the colors and pictures? Using the command line for the first time is like being lost in an abyss. The command line assumes extended knowledge of your directories, knowledge of commands, what they’re used for, and how to invoke them (syntax). It assumes you will enter in your commands perfectly without any typos and that you’ll be immediately able to spot your own errors and typos. Basically, it makes a lot of people want to cry out “HELP!”. . .
For Windows users:
Which is actually a good place to start – asking for help:
This is what displays after entering “help” into the Windows command line. Pretty good, but it will flood you with a list of commands and move whatever you had displayed before upwards. Let’s see PowerShell’s help call:
Hey, it kept the screen in one place and didn’t force us to scroll back up to see what we had before we entered a command, great! You can hold enter to scroll down as you read the remainder of the text, where it says “– More –“.
Note: to learn more about these listed commands you can type “help ___” where the blank is any command on the list. It will give you more detailed information on syntax and arguments. The example I have later uses one of these commands. For example, entering “help find”:
Don’t worry about using the “find” command right now, this is just a picture to show you the format of a help screen from the Windows command line. So entering “FIND /V old C:\Users\John” will search John’s user folder for files that don’t have the word “old” in them.
For Linux users:
I’m now noticing this command line help menu makes use of two columns, not just one. That way the visual space is optimized for the user. Nice! Anyhow, if you don’t have any experience with Linux this will look like a bunch of gibberish. That’s fine, everybody has to start somewhere. I just want to make sure your start was better than mine (lots of trial and error, hasty Google searches, little guided assistance). For a person to be able to navigate in an unfamiliar terrain, they must have some sense of orientation. Let’s start by finding out where we are by typing three simple characters:
Short for “print working directory” this is where we are. When issuing commands from the terminal interface, commands take additional parameters, or arguments, to tell it what to do and in what way. Many times, commands will need to specify a certain file or folder. This can be done two different ways: commands entered that don’t specify a full directory path (C:\folders\in\my\computer) will, by default, target files in this sub folder that we are operating from – our “working directory”. This is what is called a “relative” reference, contrasted with specifying the full path which starts at the root directory (C:\folders\in\my\computer).
Here is an animated gif that shows me displaying my current working directory (pwd), the contents of this location (ls), asking for help (help), asking for more information via the manual page (man pwd), asking for more help (h), and finally using “/stringIwantToSearchFor” (a string is a word or collection of characters) to help me navigate lengthy manual pages and help screens. The important parts of the screen are underlined in green, and I will transcribe the commands and button presses below:
- man pwd
- /files (note: you can press ‘z’ to scroll down and ‘w’ to scroll back up on help and man pages, but not the main terminal itself – it will just type out the letters instead.)
The purpose of showing you this sequence of commands was to illustrate how one can find out where they are, get a list of commands, find out more about those commands, and quickly search through the documentation provided by utilizing manual page or help page shortcuts, like “/searchforXstring”. There is a lot of technical writing in these pages, replete with jargon and abbreviated words, so don’t worry about not understanding all the text on the screen. Just focus on how you’re navigating through the command line windows or “screens”.
For Windows users:
Short for “current directory”, this will do the exact same thing that “pwd” will do in Linux: tell you where you are. Strangely, if you enter just “cd” in a Linux terminal, it means a different thing: “change directory”, and entered by itself, it will return you to your home directory. However, for both Windows and Linux, if you enter:
If entered correctly, you will be brought to that point in the directory, or folder. The term folder just has a more visual connotation that we don’t see anymore in the command line view of things:
For Windows and Linux users:
Entering the following command:
Will take you “up one level” so to speak. For example, if you’re currently in “C:\Users\You\Documents” and you issue the above command, you will be brought to “C:\Users\You”.
Entering “ls” will list the contents of your current working directory. It’s always nice to have operating system “cognates” that do the same thing on both systems. This is on my Windows 10 installation though. On Windows 8.1, “ls” won’t do anything. Instead, try typing “dir”.
That will conclude this post, check back soon for part 2 where I’ll show how to do things like create and delete files and folders. If you’re still sitting there with questions floating around in your mind, please comment or write me an email! I tried my best to explain things in a way that would have helped myself as a beginner, but maybe we all think different!