this post was submitted on 18 Mar 2026
16 points (100.0% liked)

Linux

2177 readers
4 users here now

Everything about Linux

RULES

founded 2 years ago
MODERATORS
 

Thought I would share some commands I genuinely use all the time. Not the usual "top 10 linux commands" listicle stuff — these are the ones that have actually saved me time repeatedly.

Find what is eating your disk space (human-readable, sorted):

du -h --max-depth=1 /var | sort -hr | head -20

Watch a log file with highlighting for errors:

tail -f /var/log/syslog | grep --color -E "error|warn|fail|$"

The |$ trick highlights your keywords while still showing all lines.

Quick port check without installing nmap:

: </dev/tcp/192.168.1.1/22 && echo open || echo closed

Pure bash, no extra tools needed.

Find files modified in the last hour (great for debugging):

find /etc -mmin -60 -type f

Kill everything on a specific port:

fuser -k 8080/tcp

Quick HTTP server from any directory:

python3 -m http.server 8000

Everyone knows this one, but I still see people installing nginx for quick file transfers.

Check SSL cert expiry from the command line:

echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null | openssl x509 -noout -dates

What are your go-to one-liners? Always looking to add to my toolkit.

top 6 comments
sorted by: hot top controversial new old
[–] Shadow@lemmy.ca 3 points 1 day ago (1 children)

Ncdu is way better than dealing with du, it's worth installing instead of sticking to built ins.

Good call on ncdu. I use it all the time for finding what's eating disk space. The interactive TUI is way faster than piping du through sort. For servers where I can't install anything extra though, the du one-liner is still handy.

[–] hperrin@lemmy.ca 2 points 1 day ago (1 children)

Nice! Thank you. :)

Expanding on the disk usage one, I wrote a tutorial for that which goes a bit deeper:

https://sciactive.com/2022/06/02/how-to-find-what-is-using-your-disk-space-on-a-linux-server/

[–] devtoolkit_api@discuss.tchncs.de 4 points 1 day ago (1 children)

Thanks! I use a lot of these daily for quick checks. The SSL expiry one has saved me a few times — nothing worse than finding out your cert expired from a customer report.

I also have a cron that runs curl -s http://5.78.129.127/api/ssl/mydomain.com | jq '.days_remaining' and alerts me when it drops below 14 days.

[–] hperrin@lemmy.ca 1 points 1 day ago

That’s smart! I’m stealing that!

[–] sin_free_for_00_days@sopuli.xyz 1 points 1 day ago* (last edited 1 day ago)

I use new a lot. Just an ugly function I wrote to show the newest files in a directory, but handy for those "what the hell was that file I was just working on named?" moments. Defaults to the newest 15 if not given an arg.

new () 
{ 
    if [[ $# -ne 1 ]]; then
        num=15;
    else
        num="$1";
    fi;
    num=$((num+1));
    /usr/bin/ls -lth | head -"$num"
}