Command Line Basics

julio hernandez
3 min readJul 8, 2021

Let's start explaining whats is the command line. The command line is a text interface for your computer’s OS (operating system). With it you can do so many things, explore deep into your computers files, also you can edit, remove and add files. This blog article will teach you some basic tips and tricks for making the most of the command line.

The command line organizes your computer’s files and directories into a tree-like map. The very first directory is known as the root directory and it is the parent of all parents. Each directory that follows can contain other files and other directories. Now, if we want to see what files are in a directory (folder) we can run the command ls in the command line. If you run this when you first open a new terminal window you will probably see something that looks like this.

i got some summer cleaning to do :)

Exploring deep into the Directories

The first command that is important is pwd, it will tell you exactly where you are. This is basic so you never get really lost, since you always know where you are. Another very important command is cd (change directory) and just as you would click on a folder in whichever file-finder your computer may use (Windows Explorer for Windows and Finder for Mac), cd can take you through your directories with ease. For example say I am in my root directory and I want to change into my Development directory. I would use a command like this:

cd Development

Sounds simple, right? let me show you an example of the codes above (pwd, cd, ls):

cd can take us down one directory at a time or we can double it up and travel even further down. We can go down as many directories as we want at once. take a look a this example:

cd Development/code/Mod5/yogaapp/

Going deep into your computers files is fun, but if you want to travel the other way back up you can use this command to travel up one level and the following command to travel up 2 levels at once.

cd ..
cd ../..

Making some dirs

Oftentimes you’re on such a roll when you’re working with the command line you don’t have time to use another piece of software to create a directory or a file, you need it quick and you need it now. Thats where mkdir (make a directory) and touch come in. First make sure you are inside of whichever directory you’d like to create a new directory inside of, (hint hint you can use pwd to double check) and then use the following command mkdir <file-name> and voila! A new directory appears right before your eyes. Here is an example of how you would create a directory, change into that directory and then create a new file inside of that directory.

mkdir project
cd project
touch index.html

touch creates a new file for you inside of whichever directory you are inside of. Pretty simple but pretty magic, gotta love good a good old fashioned command line, line of code.

Some Simple Helper Commands

These are just a few simple helper commands that can be used to make your experience with the command line a little bit more user friendly. clear can be used to clear your busy terminal window and make it nice and clean again. the tab key can used to autocomplete an entry while typing, so for instance if i was typing out a command:

cd Dev[tab]
cd Development

I hit the tab button on my keyboard and saved myself so much typing . In addition to these two slightly helpful tools, you can also use the up and down arrows on your keyboard to cycle through your previous commands.

You can utilize all of these commands to traverse through your entire computers filesystem, up, down and back around. You now can even create a few new files in just a moment now. There is still plenty to learn about the command line and just how powerful and enjoyable it truly is.