Terminal Commands: A reference
A 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.
cd
cd
— brings you to your home directorycd ..
— goes up one directorycd ../../
— up two directories and so on…cd /
— goes to your root directorycd -
— brings you back to the directory you were last in
quick keys
hit these while in a terminal
ctrl + l
— clears the terminalctrl + shift + plus
or justctrl + plus
— zoom inctrl + shift + minus
or justctrl + minus
— zoom outctrl + a
— brings cursor to beginning of the linectrl + e
— brings cursor to end of the linectrl + u
— deletes everything before the cursorctrl + y
— pastes deleted contents where the cursor is atctrl + k
— deletes everything after the cursoralt + backspace
— deletes word the cursor is onctrl + r
— search for commands you’ve already ran
ls
ls
— lists contents within the working directoryls -l
— lists contents within the working directory in a top-down formatll
— linux alias command which can be used instead ofls -l
; might not work on all OSsls -al
— lists contents within the working directory in a top-down format and includes secret files also!… ooh neatla
— linux alias command which can be used instead ofls -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