Helpful Terminal Commands

Using the Terminal or Command Line will prove to be a super handy and important aspect of your software development process. Here are a few commands that will most definitely be useful for you when using the Terminal. I’m using a Mac.

Make a new folder

mkdir folder-name

Go into folder (only up 1 level)

cd folder-name

To cd into a folder with a space in the name, use the backslash character between the words

cd Software\ Development

Go backwards by one level in the folder system

cd ..

Go to your computer’s root directory

cd ~

Clear the Terminal window (just for declutter)

clear

See the contents of a folder

ls

See the hidden files in a folder

ls -a

Copy file to a different directory. This line copies the file file-name.txt to the directory/file one above the current directory/file.

cp file-name.txt ../

Rename a file

mv file-name.txt NEW-FILE-NAME.txt

Remove file from current directory

rm file-name.txt

Shows where an application lies in your file system. In this example, we are seeing the location of the Git application. This command will either return the file system location if the application exists on your machine or no output if there is no application with that name on your machine

which application-name
which git

Shows where you are currently in your file system

pwd

Basically a print statement but in the Terminal

echo hello

Make a new file and put the defined text inside of it. In this case, we put the text hello in a file called hello.txt

echo hello > hello.txt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s