pwd # print current directory
ls -la # list all files, including hidden, with details
cd /var/log # change directory
find . -name "*.log" # search for files by name, recursively
These four cover the overwhelming majority of everyday navigation — everything else is a variation with extra flags.
cat file.txt # print entire file
less file.txt # page through a large file
grep "ERROR" app.log # find lines matching a pattern
grep -r "TODO" src/ # search recursively through a directory
grep is one of the highest-value commands to actually know well — searching logs or source code for a pattern is a constant task, and grep handles it faster than opening files one by one in an editor.
ps aux | grep node | wc -l
The pipe (|) sends one command's output directly into the next command's input. This example: list all running processes, filter to lines containing "node," then count how many lines remain — three simple tools combined into one useful answer, without any of them being specially designed to work together.
-rwxr-xr-- 1 alice staff 1024 Jan 5 10:00 script.sh
Reading left to right after the file type character: owner permissions (rwx — read, write, execute), group permissions (r-x), everyone else (r--). chmod 754 script.sh sets exactly this — each digit is the sum of read (4), write (2), and execute (1) for owner, group, and others respectively.
ps aux # list running processes
top # live view of resource usage
kill -9 1234 # forcibly terminate process ID 1234
nohup ./script.sh & # run a command that keeps running after you log out
kill -9 should be a last resort — it terminates a process immediately with no chance to clean up open files or connections. A plain kill (signal 15) asks the process to shut down gracefully first.
Ctrl+R to search history) instead of retyping, is the difference between the terminal feeling slow and feeling instant — most terminal fluency is really just muscle memory for these two habits.
echo "log entry" >> app.log # append to a file
command 2> errors.log # redirect only error output
command > /dev/null 2>&1 # discard all output entirely
A single > overwrites a file; >> appends. 2> specifically redirects stderr (error output), separate from stdout — useful when you want to log errors without cluttering normal output, or vice versa.
Comments