DEV Community

Taylor Overturf
Taylor Overturf

Posted on

10 Terminal Commandments for Coding Newbies

The terminal can be an intimidating place for anyone, like me, who has spent most of their life living in a ✨Graphical User Interface✨ paradise.

In the GUI, it seems like nothing can really go that wrong. However, on the command line, it feels like a single cat-on-keyboard moment can bring everything crashing down. 🐱🔥

It is my belief that the terminal itself is not what frightens us, but the unfamiliarity of it all. Once you build up your confidence, the terminal can, and will, be your new best friend. 👯 I promise!

The first time I entered the terminal, I had no idea where I was. You don't believe me? Look at the first 15 commands I ever ran:
Image description Unfortunately, hello and where am i, yielded no results. You know what did? Making a ton of mistakes, which I like to call, "practice." (I really got my ls practice in here, see lines 6 to 9).

So, here are my Top 10 Terminal Commandments. These helped me become more comfortable working on the command line, and I hope they help you, too! 💛

1. history

If you're anything like me, you routinely forget the command you ran 5 seconds ago. Run history to get a friendly reminder. You will see all the commands you have previously run. And, if you don't mind scrolling for several minutes, try to find your first 15 commands by going all the way up. Perhaps you, too, wondered: where am i? 🌍

2. exit

Image description This is a best practice that I turned into a habit very early on in my coding journey and I'm grateful I did. By using exit at the end of every session, you are setting yourself up for success later on when it will be important to exit out of multiple servers and live ports. Use exit whenever you're done in the terminal, instead of just quitting or x-ing out. Your future coder-self will thank you! 🙏

3. mv old-file-name-you-dont-want new-file-name-you-do-want

I can't tell you how many times I've misspelled something and thought, "Oh well, I guess it will just be called main-directury for the rest of my life." 🤷‍♀️ For some reason, as a coding newbie, I find it scarier to delete and edit than it is to create. However, don't be fearful of the mv command. You can easily rename your files for times when you have a typo or simply realized there's a better name out there for your project or file.

4. touch new-file-name

🏆 This one gets the award for Cutest Command, touch whenever you want to create a new file. Not to be confused with the less cute, mkdir which will just create a folder (directory).

5. pwd

Print Working Directory or pwd is the command I was looking for when I ran where am i. It will tell you exactly where you are within your file structure! This is helpful for when you want to confirm your location before running another command.

6. ls

List all the contents of a folder. This is extremely helpful as there is no graphical interface showing you all your files, you either need to remember (not going to happen!) or see what your options are. 🧐

7. cd

Move into a folder. ⬇️ Think of it as moving level down within your file structure.

8. ..

Move out of a folder. ⬆️ Think of it as moving one level up within your file structure.

9. CMD + t

Did you know, just like your browser, you can also open a new tab in your terminal? Maybe you cd-ed into the depths of one folder and now you want to move back out .. without losing your spot. The CMD + t action will open a new tab where you currently are (which is different than opening up the terminal application on your computer). Use it when you want to be in two places at the same time! 🪄

10. CTRL + c

Did you just start running something that you instantly regret? 😱 Try the action CTRL + c to clear. This will become handy later with Git and installations and servers and other levels of chaos, but it is helpful to hardwire into your brain now so that you always have an escape plan!

Yes, the terminal can be a scary place for us beginners. But, every time you run ls a coding fairy gets its wings. So ls all day long, my friends! I guarantee you will start to feel more comfortable as you practice these 10 Terminal Commandments. Finally, love thy coding newbie as thyself–comment, re-post, print, bookmark, subscribe or share this post!

Latest comments (29)

Collapse
 
astorrer profile image
Aaron Storrer

How about "Commands newbies should never type." Or, most dangerous powerful commands.

rm (or anything with -r or -R)
chmod
chown
mv (You did mention it's use but not why to fear it.)

Collapse
 
moscow0201 profile image
UCan

thank you so much

Collapse
 
drvy profile image
Dragomir Yordanov

Note: CTRL + C does not "clear" the terminal. It sends an "Interrupt" (SIGINT) signal to the current program. Also, the program can chose to ignore it.

Collapse
 
thiagomg profile image
Thiago Massari Guedes

A nice shortcut for exit is Ctrl+D - It is also satisfying for lazy people such as myself

Collapse
 
whobeu profile image
Robert G. Schaffrath

I usually set IGNOREEOF=4 (or higher) due to having gotten logged out too many times accidentally. Type CTRL+D to exit an application and it seems unresponsive so I hit it again. Then it actually wakes up and I have entered two CTRL+D's with the net result being the shell getting the second CTRL+D LOL.

Collapse
 
dozykeys profile image
Duru Chidozie

Nice read...it was worth it

Collapse
 
napcoder profile image
Marco Travaglini

You know the sensation when you need to re-execute that very complicated command you run few days or week ago and you cannot remember anything but a word? history | grep that-word saved my life a lot of time

Collapse
 
rbgrouleff profile image
Rasmus Bang Grouleff

In Bash you are also able to search in your history with CTRL+r :)

Collapse
 
napcoder profile image
Marco Travaglini

I have to remember this one, thanks

Collapse
 
nueeardente profile image
Edgar Carlos

Thank you for this article.
For me, the most indispensible commands (besides some of the ones in this article) are:

  1. cat combined with grep -i (when you are quickly looking for something or some pattern in a file)
  2. grep (many regex options)
  3. tail (when going through logs in linux)
  4. more
  5. which and last but not least
  6. man (for looking up how to use the commands mentioned here)
Collapse
 
dozykeys profile image
Duru Chidozie

it's worth it...thumbs up

Collapse
 
sturlabragason profile image
sturlabragason

Nice post! My favorite is CTRL+R 🔥

Collapse
 
goodevilgenius profile image
Dan Jones

This is very unclear on how to use ... It's not a command itself. If you try it, you'll just get a "command not found" error.

You need cd ..

Also, cd by itself will send you back to your home folder. Normally, you need to put the directory name in there: cd subfolder

Collapse
 
goodevilgenius profile image
Dan Jones

I think you've confused iTerm or Terminal.app with "terminal". Cmd-t is an iTerm (and other terminal emulator) shortcut for opening a new tab. It's not universal, and has nothing to do with the terminal itself, but rather, with the terminal emulator you're using.