Linux One Command Per Day

I started using Linux as my operating system many years ago — I believe it was in the early 2000s. Over the years, I’ve used several distributions, from Mandrake Linux to Ubuntu and Debian. Currently, my favorite is Manjaro Linux with the KDE desktop environment. For most of this time, I used the default Bash shell, but for the last 2–3 years I’ve been using Oh My Zsh — partly because I also have a Mac, and I installed it there as well. Most of the commands I know in the terminal I originally studied many years ago. That’s why I’ve added 5 minutes to my daily routine to either review a Linux command or learn a new one. I’m doing the same for Oh My Zsh aliases and functions — with the help of ChatGPT. Below, I’ve included the commands in a table.

Linux One Command Per Day

Command Description Examples
tldr Get command description.
tldr ls
bat Advanced alternative to cat, with syntax highlighting and line numbers. Useful for reading code or config files.
bat file.txt
bat script.sh
cat file.txt | bat
cat Displays the contents of one or more files, or concatenates them. Useful for quick viewing or merging files.
cat file.txt
cat file1.txt file2.txt
cat file1.txt file2.txt > merged.txt
cat /etc/passwd | less
grep Searches for a pattern in files or input. Supports regular expressions. Use -i for case-insensitive search.
grep 'error' logfile.txt
grep -i 'warning' logfile.txt
cat file.txt | grep 'pattern'
grep -r 'TODO' src/
du Displays disk usage of files and directories. Add -h for human-readable sizes and -s to summarize.
du -sh ~
du -sh *
du -ah /var/log | sort -rh | head -10
du -c *.txt
xargs Reads input and passes it as arguments to another command. Useful in pipelines or when dealing with long lists.
echo "file1.txt file2.txt" | xargs rm
find /var/log -name "*.log" | xargs rm
find . -name "*.jpg" | xargs -n 1 -I % cp % /backup/
find . -print0 | xargs -0 ls -lh
find Searches for files and directories based on name, type, size, permissions, and more. Very powerful for recursive search and cleanup.
find ~ -name "file.txt"
find /tmp -name "*.tmp" -delete
find / -size +100M
find . -type f -mtime -1
find . -name "*.bak" -delete
rsync Efficiently synchronizes files and directories. Ideal for backups and remote copies.
rsync -av source/ destination/
rsync -av --delete ~/Docs/ /mnt/backup/
rsync -avz -e ssh ~/Docs/ user@host:/backup/
rsync -av --progress bigfile.iso /mnt/backup/
ncdu Interactive disk usage viewer. Great for finding large files and folders quickly.
ncdu
ncdu /home
ncdu /var/log
tmux Terminal multiplexer: split windows, manage sessions, run processes in background.
tmux
tmux new -s session_name
tmux attach -t session_name
tmux list-sessions
fzf Fuzzy finder to search files, history, directories interactively. Super fast.
fzf
history | fzf
find . -type f | fzf | xargs nano
cd $(find . -type d | fzf)
z Jump to frequently used directories. Learns your habits over time.
z projects
z dev
z -l
cut Extracts columns or characters from text. Useful for processing structured output.
cut -d',' -f1 data.csv
cut -c1-5 file.txt
cut -d':' -f1 /etc/passwd
ls -l | cut -d' ' -f9
sort Sorts lines of text alphabetically or numerically. Combine with uniq for cleanup.
sort file.txt
sort -n numbers.txt
sort -r file.txt
sort -t',' -k2 file.csv
uniq Removes or identifies duplicate lines. Input should be sorted for best results.
sort file.txt | uniq
sort file.txt | uniq -c
sort file.txt | uniq -d
sort file.txt | uniq -u
awk Powerful text processor and mini language for field-based data manipulation.
awk '{print $1}' file.txt
awk -F',' '{print $2}' data.csv
ls -l | awk '{print $9}'
awk '/error/ {print $0}' logfile.txt
head Displays the first lines of a file. By default, shows the first 10 lines.
head file.txt
head -n 20 file.txt
ls -lh | head -n 5
head -c 100 file.txt
tail Displays the last lines of a file. Great for monitoring logs in real time.
tail file.txt
tail -n 20 file.txt
tail -f /var/log/syslog
tail -n +5 file.txt
wc Counts lines, words, and characters in a file or input. Use with pipes or files.
wc file.txt
wc -l file.txt
wc -w file.txt
ls | wc -l
basename Extracts the filename from a full path. Useful in scripts to isolate filenames.
basename /home/user/file.txt
basename /var/log/syslog
basename /path/photo.jpg .jpg
filename=$(basename "$1")
dirname Extracts the directory path from a full file path. Often used in shell scripts.
dirname /home/user/file.txt
dirname /var/log/syslog
dir=$(dirname "$1")
echo "Folder: $(dirname "$filepath")"
tee Reads from standard input and writes to both standard output and a file.
echo "Hello" | tee output.txt
ls -l | tee filelist.txt
echo "Line" | tee -a log.txt
echo "127.0.0.1 example.com" | sudo tee -a /etc/hosts
diff Compares two files line by line. Great for spotting changes or debugging configs.
diff file1.txt file2.txt
diff -i a.txt b.txt
diff -y file1 file2
diff -r dir1 dir2
chmod Changes file or directory permissions using symbolic or numeric modes.
chmod 755 script.sh
chmod u+x script.sh
chmod 444 readonly.txt
chmod g-w file.txt
ps Displays information about active processes. Use aux for full details.
ps
ps aux
ps -u $USER
ps aux | grep python
kill Sends signals to processes by PID. Typically used to stop or restart processes.
kill 12345
kill -9 12345
pkill firefox
kill -l
which Shows the full path of the executable that would run for a given command.
which ls
which python3
which git
which node
env Displays environment variables or runs a command with a modified environment.
env
env VAR=value command
env DEBUG=1 python script.py
env -i bash

Oh My Zsh Aliases

to do :)

Comments