Some of the best command-line habits aren’t from tutorials or docs. They’re weird little things you stumbled into or accidentally discovered while trying not to break something in production.
Whether it’s a clever alias, a one-liner you’ve used a hundred times, or a keybind that changed your life, drop your go-to terminal trick below.
Oh nice, this is your own post so you want to kick off the replies. Here’s a first-person reply you can drop in:
For me, it’s ctrl+r for reverse search in bash. I used to just hit the up arrow like 50 times trying to find that one command I ran earlier. Once I discovered reverse search I couldn’t believe I’d gone so long without it. Just hit ctrl+r and start typing any part of the command and it pulls it right up.
Close second would be !! to repeat the last command. Mostly because of sudo !! when you forget to run something as root.
That’s a solid approach! I made a similar switch from screen to tmux a while back and never looked back. The ability to script your session layout like that is hard to beat.
Do you have it wired up to run automatically on SSH login?
(LXTerminal) One I recently started making use of is CTRL-W for deleting a word to the left.
Otherwise, mostly CTRL-SHIFT-T for new terminal tab, CTRL-SHIFT-W to close terminal, and ALT-1 to ALT-9 to switch between them, similar to the browser.
I often use ctrl + l (lowercase L) to clear the screen. It’s the same as running the clear command, with the difference that ctrl + l still lets you “scroll back” (so it doesn’t delete the scrollback buffer), so you can see the commands and outputs that happened before pressing ctrl + l
There are other ones but I’m guessing the cd - command is rather useful to switch “back and forth” between two directories. Here’s an example:
ricmarques@mypc:~$ cd /boot/grub/
ricmarques@mypc:/boot/grub$
ricmarques@mypc:/boot/grub$ ls -l
total 2404
drwxr-xr-x 2 root root 4096 dez 5 2022 fonts
-rw-r--r-- 1 root root 712 fev 8 2025 gfxblacklist.txt
-rw-rw-r-- 1 root root 8731 abr 17 23:56 grub.cfg
-rw-rw-r-- 1 root root 1024 abr 18 2026 grubenv
drwxr-xr-x 2 root root 4096 mai 4 2025 locale
-rw-r--r-- 1 root root 2411806 mai 24 2025 unicode.pf2
drwxr-xr-x 2 root root 20480 mai 4 2025 x86_64-efi
ricmarques@mypc:/boot/grub$
ricmarques@mypc:/boot/grub$ cd /etc/default/grub.d/
ricmarques@mypc:/etc/default/grub.d$ ls -l
total 0
ricmarques@mypc:/etc/default/grub.d$ cd -
/boot/grub
ricmarques@mypc:/boot/grub$ cd -
/etc/default/grub.d
ricmarques@mypc:/etc/default/grub.d$
:||cat<<BASH_MULTILINE_COMMENT_TRICK
To add multiline comments,
without needing a '#' preceding every line.
and without processing 'here document' at all.
BASH_MULTILINE_COMMENT_TRICK
I often end up working a lot with different drives and needing to know, definitively, which drive is really /dev/sdaN or /dev/nvme0nN. I added this alias to help me better identify which is which.
alias lsblk+=‘lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,TYPE,MOUNTPOINTS,LABEL,PARTLABEL,FSTYPE’
Today (25th May 2026), I’ve “invented” a small but cute “command trick” to run in terminal. As far as I remember, nobody taught it to me (although I’m sure there must be plenty of people in the World who already - and independently - have had the same idea). To see a clock being updated every second, type the following command:
watch -n 1 date
(When you get tired of watching the clock, press Ctrl + C to exit)
The watch command is quite useful—I also use it to see “live” GPU usage with nvidia-smi (we run some scientific software pipelines that make use of the GPU, and for debugging purposes it can be helpful to see the realtime usage).
Thanks for mentioning that. Especially because that reminds me of something else (14 years ago) that nobody taught me:
On a remote videoserver I had to make sure that the application I wrote would make an administrative video backup to a removable harddisk and I could be certain that neither the UUID , not the serialnumber, nor the label was predictable with a drive swap.
I then digged through the /dev/disk directory and I ended up using the location of the drivebay: /dev/disk/by-path
Funny backstory: b.t.w. the server would have had a more than satisfying uptime if it wasn’t for the time the whole datacenter went down (which took out many racks and damaged many servers despite being hooked on two different electricity nets , both backed up by generators).
And the time that the company moved it to another datacenter 100km eastwards.
Not that it mattered anyway: If you have about 700 days uptime it might be a good idea to bring it down anyway for securitypatches (which, ofcourse, is a good opportunity to update the OS since it is down anyway).