Terminal Commands: A Reference


listicle of commands to run in a terminal and navigate directories and logs like a pro! Mostly for Linux but some of them work in Windows also.

Photo by Francesco Ungaro

cd

  • cd — brings you to your home directory
  • cd .. — goes up one directory
  • cd ../../ — up two directories and so on…
  • cd / — goes to your root directory
  • cd - — brings you back to the directory you were last in

quick keys

hit these while in a terminal

  • ctrl + l — clears the terminal
  • ctrl + shift + plus or just ctrl + plus— zoom in
  • ctrl + shift + minus or just ctrl + minus — zoom out
  • ctrl + a — brings cursor to beginning of the line
  • ctrl + e — brings cursor to end of the line
  • ctrl + u — deletes everything before the cursor
  • ctrl + y — pastes deleted contents where the cursor is at
  • ctrl + k — deletes everything after the cursor
  • alt + backspace — deletes word the cursor is on
  • ctrl + r — search for commands you’ve already ran

ls

  • ls — lists contents within the working directory
  • ls -l — lists contents within the working directory in a top-down format
  • ll — linux alias command which can be used instead of ls -l ; might not work on all OSs
  • ls -al — lists contents within the working directory in a top-down format and includes secret files also!… ooh neat
  • la — linux alias command which can be used instead of ls -al ; might not work on all OSs

Checking log files

less path/of/the/log/file.log — better than using cat for looking at log files, but you’ll probably have to use sudo

pro tip: if you forgot to type sudo before a command you just ran, then just type:

sudo !! — the double exclamation marks are a shortcut to call the last command you just ran without needing to type it all over again

tail path/of/the/log/file.log — like the less command but it will just print the last 10 lines of a log file, you might need to use sudo with this one also

press q to exit the log page

tail -f path/of/the/log/file.log —this command will specify to print out the log file in real time for live monitoring, you might need to use sudo with this one also; test it out with the log file path/var/log/auth.log found in linux OS


Thanks for reading!

If you enjoyed reading this article, support my writing by signing up for a Medium subscription.

Medium is a writing platform where writers from all over the world showcase their writing, covering any topic you can think of.

With a subscription you'll have unlimited access to all these writers and email notifications for my newly posted articles.

...but never fear, if you really enjoy my cybersecurity articles, then they will always be available here to read for free, for you!