Conquering the Command Line
A brief guide to getting started on UNIX/Mac OS terminal
When I was first introduced to the command line I really had to adjust to navigating my computer in a black box with just text. So I avoided the command line as much as possible. I was accustomed to the visual cues and feedback that a computer usually provides. In many ways it felt like I was re-learning how to use a computer via the command line.
Yet, since first learning how to navigate my computer using UNIX commands I’ve learned that the command line doesn’t have to be a scary thing just because there’s no visual feedback when typing a password in on the command line. As security, nothing shows up as you type in your password to indicate that any characters have been entered.
What is the command line?
The command line is a software that executes commands or instructions for a computer to manipulate or interact with its file system.
What is UNIX?
Why Use the Command Line?
- Faster to modify, navigate between files
- Able to install software as a superuser
- Can see hidden dotfiles
dotfiles are UNIX configuration files, they tend to be files that are proceeded with a
.and are hidden to normal users.
You can learn more about getting started with dotfiles in this article).
In order to get started on the command line you should navigate to your applications and open the Terminal application.
Create a Basic Website Folder on the Command Line
A folder with the above structure can be create on the command line by typing the commands inside of an empty directory:
- Make a directory (also known as a folder) called personal-website
- Navigate to inside of the directory called personal-website
- create a directory, inside of the personal-website folder called assets
- Navigate inside of the assets folder which is inside of the personal-website folder
- create a directory, inside of the assets folder named images
- create a directory, inside of the assets folder named js
- create a directory, inside of the assets folder named css
Woops! We forgot to create an index.html file :(
We are in the assets folder and want an index.html file in our main personal-website folder. Typing
cd .. will move us out of the assets folder and into the directory above which is personal-website. Now that we are in the personal-website folder if we type
touch index.html a blank index.html file will be created.
Some frequently used terminal commands are:
commands to navigate/manipulate the filesystem
**list** the contents of a directory
print working directory for the terminal to display the directory you are currently working on
**create or open a file without making any changes
very handy when wanting to create empty files without leaving the command line
**this allows you to run commands as a **super user
move a file or directorythis can be used to move or rename a file by updating the file path
change the current directory you are working on so that you can access files on a different part of the system
cd moves you to the root directory (top level folder on computer — usually the current User)
cd . current directory
cd .. navigates to directory two levels up
make a new directory (or a folder)
Commands to Install Software
You can install some software from the command line using the following commands:
- in Python
pip install <package name>.
Pip is a software package manager for Python.
npm install <package name>
Commands to Run Software
In order to run a script on the command line you need to provide a command prompt and file name. Some examples are:
- in Java
javac filename.javaand then
java filenamecompiles java projects and then runs them.
- in Python
python filenameruns python scripts.
If you find you are repeating a lot of commands you can scroll through your recent commands using the up/down arrows and edit them and re-run by navigating to them and then pressing enter.
Additional Resources to Get Started with Command Line Prompts
- MIT Terminus (interactive game to learn command line)
- Codecademy Learn the Command Line
- Learn Python the Hard Way’s Command Line Crash Course
Decorating the Command Line
You can completely customize the colors and outputs on the command line to better suit your visual and aesthetic needs.
Here’s how I’ve made my command line prettier :
How to install Tomorrow Night
If you enjoyed reading this article consider tapping the clap button 👏. Wanna see more of my work? Check out my GitHub to view my code and learn more about my development experience at http://aboutmonica.com.
Monica Powell is a Full Stack Engineer, building tech to bring people together IRL at Meetup. She's interested in chatting about React, open-source, tech inclusion, automation and more. 🍿