df . # This is an easy way to find out what partition the current directory is on, regardless of symlinks.

echo * | xargs -n1 id > /dev/null # Was in /var/spool/cron and wanted to check for stray (unowned) crontabs. Errors would show me and I can throw stdout away.

I could have you submit a hash (sha1sum) of your username, but that seems boring.

To explain, playing involved submitting to a leaderboard using curl and submitting your $USER environment variable for credit in the high score list. While this would have been old-timey cool, it's just not reasonable anymore.

That moment when you realize the command game you wrote and were going to post would have probably violated GDPR.

sleep $(( 3600 + $RANDOM % 3600 )) # Sleep a random number of seconds between 1 and 2 hours. If you're wondering how one would use this, I used this to set a delay between the last 4 tweets.

awk -F: {'print $1 ":" $2'} messages |uniq -c # Count syslog hits per minute in your messages log file. Useful for doing quick stats.

diff <(grep = config.txt) <(grep = config.txt-new) # Compare just the assignment lines of two config files that use = for value assignment.

rename 's/_(\d{4})(\d{2})(\d{2}).txt/_$1-$2-$3.txt/' *_????????.txt # Rename set of files with non-hyphened date at the end to have hyphens. Uses Larry Wall's version of rename.

mv Picture{,-of-my-cat}.jpg # I find brace expansion useful for renaming files. This cmd expands to "mv Picture.jpg Picture-of-my-cat.jpg"

Monitoring free memory in real time is interesting too. Or you can combine multiple commands together separated by ; and get more of a dashboard going.

watch -n0.1 "grep "[M]Hz" /proc/cpuinfo" # Monitor your dynamic CPU frequency in Linux in real time using the watch and grep commands. This is 2.81 and the race spaceship demo behind the terminal window to exercise the CPU (and GPU ;)

long_running_command ; [Ctrl-Z] ; bg ; disown ; screen ; reptyr $( pidof long_running_command ) # Suspend and reattach a process within screen.

sudo tail -F /var/log/syslog /var/log/auth.log # A Tail of Two Files

PROMPT_COMMAND="echo pipe statuses: \${PIPESTATUS[@]}" # In bash, this will show the return status of each command in the pipeline in the previous pipeline. So for instance 'ls | grep unmatchingexpression | wc -l' might return '0 1 0' showing that the grep didn't match.

convert -evaluate-sequence Min $( for i in $( seq 34 7 99 ) ; do echo $i.png ; done ) every7th-frame.jpg # Using frames 34 through 99 from a video, take every 7th frame and overlay it into a composite image. The 'convert' command is part of the ImageMagick package.

nmap --open -p T:22 # Scan your internal home network for hosts listening on TCP port 22 (SSH protocol).

mv lego* legos/ # I've always appreciated that mv doesn't stop me from doing this (matching a bunch of other files with the same prefix as the directory) and I'm fine with the error, but maybe not the return code. ;)

Show more

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!