DEV Community

Sal Hernandez
Sal Hernandez

Posted on

These are a few of my favorite: Terminal Shortcuts

Terminal: an interface where the user types and executes text based commands.

ISSA Terminal

I’ll admit that when I first opened the terminal in 2014, I disliked it. At the time, I strongly believed that using a Graphical User Interface, such as Finder on Mac, was much faster for things like deleting, copying, and creating files and folders. The tutorials and articles I would read kept insisting that the terminal was 🔑, though, so I kept going.
I’m glad I pushed through and kept learning to use the terminal! Eventually, with practice and consistency, the understanding and speed came. Now I barely use the GUI for managing my file system.
That said, the road wasn’t all smooth. There were a lot of terminal commands thrown at me during my journey. How was I supposed to memorize all of them??!!? At once?!?!

To prevent you from going through the same anxieties. I compiled a list of my Top Fave ❤️ Terminal shortcuts. 😁

ls List files and directories (Folders)


cd Change directory
pwd Print Working Directory (Shows the full pathname of the current working directory)


touch Create a new file


mkdir Create a new directory


cp Copy files or directories


mv Move (rename) files or directories


rm Remove files
rm -r Remove Directories & files in
Note: Therm command is really powerful. It deletes files/directories without recovery. (It doesn’t go to the trash bin)


Ctrl + A Gets the cursor at the beginning of the line
Ctrl + E Gets the cursor to the end.


Cmd + k (Mac) `Ctrl + L (Linux/Mac) Clears the Terminal Screen


And now for my absolute favorite ❤️: Tab auto-completion!

If you’re trying to remember a command, type at least one letter and hit tab twice and it will show you all the commands available based on the typed characters. If you type enough characters and only one match is left then it’ll auto-complete it for you. This works with all UNIX commands and even your file system.

Now go on and jump into your terminal, start playing with it & work your way towards becoming the terminal-ator. 😎


If you liked this post, make sure to hit the hit the green heart! 💚
For more puns and code tips follow my journey on twitter @clickclickonsal
Join the Color Coded slack community by visiting our site and stay in the loop.

This article originally published on the Color Coded Medium publication

Latest comments (54)

Collapse
 
der_gopher profile image
Alex Pliutau

telnet pliutau.com 8080 - snake game :)

Collapse
 
clickclickonsal profile image
Sal Hernandez

That's so cool!!!

Collapse
 
rusbra profile image
Rus

move cursor one word left
alt/option + ←

move cursor one word right
alt/option + →

Collapse
 
clickclickonsal profile image
Sal Hernandez

This is a good one, unfortunately, it doesn't work out of the box if you're using iterm.
For those using iterm & are looking to be able to do what Rus pointed out, check out this link coderwall.com/p/h6yfda/use-and-to-... !

Collapse
 
colorfultones profile image
Damon Cook

I believe tab auto-completion is something that is not out-of-box terminal command but a Zsh/Oh-My-Zsh package one must install?

Collapse
 
colorfultones profile image
Damon Cook

Oh my go(z)sh it is out-of-the-box functionality! Would ya look at that. 👀

Collapse
 
clickclickonsal profile image
Sal Hernandez

😉

Collapse
 
denvercoder profile image
Tim Myers

I am the only dev at my job that uses command line Git...I am the only dev at my job that doesn’t think that Git sucks. I think people confuse the GUI with the underlying tech, ie, “I can’t find my stash in SourceTree, I really hate Git”.

I come from a strange time. Started on a PC using DOS a bunch to add Extended Memory and Shadow Memory to play games.

I “locked” down my windows install by renaming win.exe to tim.exe. I did a lot in the command prompt.

Then I became a .NET developer. Visual Sudio has always been either a click-me interface or use keyboard shortcuts interface. It rarely required command line. Even now I use it more with the Nugget Package Manager Console but still, for the last 10 years or so I haven’t used the command line much.

Then I got a Mac and I’m back to mostly terminal, (iTerm). So in my career I have gone from command line to GUI and back to command line.

Collapse
 
denvercoder profile image
Tim Myers

I am one of the only people at my job that uses command line Git...I am also one of the only people at my job that doesn’t think that Git sucks.

I think people blame GUI errors on the platform, ie, “I cant find my stash in SourceTree, Git really sucks”.

Collapse
 
clickclickonsal profile image
Sal Hernandez

Aw, that sucks to hear :-/ Git is awesome & I couldn't imagine developing without it!
I think you should try & give a tech talk at your job and show them the tips and tricks to using git on the command line. :-)

Collapse
 
ahmadawais profile image
Ahmad Awais ⚡️

Using rm cannot be your favorite shortcut. I would suggest using trash-cli.

Collapse
 
clickclickonsal profile image
Sal Hernandez

Whoa! It Cannot be my favorite shortcut? That's a very aggressive statement.
Everyone is entitled to their own opinions and they will determine what they consider their favorites.

Granted, rm is a very powerful command & I recommend everyone who's using it to fully understand what it does which I mention in my blog post.
It's one of my favorite shortcuts because when I delete stuff with it I know that it has been completely removed from my computer.

Collapse
 
ahmadawais profile image
Ahmad Awais ⚡️

It's a bad practice to use rm — you're def entitled to your own opinion but be open to suggestions as well. You cannot always be right. Using rm is a bad practice. Things can go wrong and you can end up deleting your OS.

Thread Thread
 
clickclickonsal profile image
Sal Hernandez

It is not bad practice to use rm. It is bad practice to use rm if you don't know what it does, but the same goes for running any command in the terminal.
The terminal is a very powerful tool & anything you run in it should be ran with a good understanding of what it is doing.

Thread Thread
 
ahmadawais profile image
Ahmad Awais ⚡️

Let's agree to disagree here.

Collapse
 
psnebc profile image
Patrick Schanen • Edited

I use zsh and ohmyz.sh on Linux Mint 17.3 psnc.github.io/linuxme/

Collapse
 
itscoderslife profile image
Coder

==>(Cmd + k (Mac) `Ctrl + L (Linux/Mac) Clears the Terminal Screen)

In macOS Sierra, its Ctrl + L. Ctrl + k does not work.

Collapse
 
clickclickonsal profile image
Sal Hernandez • Edited

That's because It's not Ctrl + K, it's Cmd + K :-)

Collapse
 
itscoderslife profile image
Coder

Yup, works fine! Both are working Cmd + K and Ctrl + L

Collapse
 
kalinchernev profile image
Kalin Chernev • Edited

Ctrl + u is the first nature of Ctrl + l :)
I personally do both mechanically.
echo 'something' somewhere and echo 'something' >> somewhere is also a beginner one that helps quite often, say adding items in a .gitignore file.

Collapse
 
clickclickonsal profile image
Sal Hernandez

Whoa! I love everyone who's been sharing their tips as well! I've always used Ctrl + C to jump to a fresh new line. Now I know that I can do Ctrl + u to clear out my terminal! :-)

The echo command is awesome as well! I forgot to mention a lot of good ones. 😅

Collapse
 
the_scott_davis profile image
Scott Davis ⭐
  • "open ." to open your current directory path in a Finder window in Mac

  • drag drop a file or directory into terminal from any application to automatically copy the text into the terminal window (handy for changing into directories within terminal)

Collapse
 
clickclickonsal profile image
Sal Hernandez

Thanks for sharing your tips! These are awesome!
I use the first one all the time! I forgot to mention that one! :-)
The second one I didn't know about! That could come in handy in the future!
I learned something new! :-) Thank you, Scott!

Collapse
 
the_scott_davis profile image
Scott Davis ⭐

My pleasure! Enjoy!