Opens profile photo
Follow
Click to Follow climagic
Command Line Magic
@climagic
Cool Unix/Linux Command Line tricks you can use in $TWITTER_CHAR_LIMIT characters or less. Here mostly to inspire. Also on mastodon.social/@climagic
$HOMEclimagic.orgJoined November 2009

Command Line Magic’s posts

Matrix while :;do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(printf "\U$(($RANDOM % 500))");sleep 0.05;done|gawk '{a[$3]=0;for (x in a){o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH\033[2;32m%s",o,x,$4;printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,$4;if (a[x] >= $1){a[x]=0;} }}'
Embedded video
0:15
30
2,657
inotifywait -e open art.jpg && s=$(stat -c %s art.jpg );h=$(($s/2));r=$((s-h)); dd if=/dev/urandom | grep -a -o -P "[\x01-\xD0]" | tr -d $'\n' | dd of=art.jpg bs=1 seek=$h count=$r # Digitally "shred" half a file after it is opened. #Banksy
Image
13
2,067
I like to put sine waves in my log files because that's how I roll. 😎 awk -v cols=$(tput cols) '{c=int(sin(NR/10)*(cols/6)+(cols/6))+1;print(substr($0,1,c-1) "\x1b[41m" substr($0,c,1) "\x1b[0m" substr($0,c+1,length($0)-c+2))}' access_log | less -SR
A screenshot of an Apache access_log file where a vertical sine wave has been "drawn" into the file using a red background on specific characters.
25
1,391
Print an access_log with indicator chart bars under each request line to show the size of the data transfer using log() to keep things "in control". awk -v cols=$(tput cols) '{e=int(log($10)*5); print("\x1b[42m" substr($0, 1, e) "\x1b[0m" substr($0, e+1) )}' access_log | less -SR
A screenshot of a web server log file where each line of the log has a green bar  acting as a background color for the text, whose horizontal size from the left is controlled by the size of the web server response.
16
1,180
Dear university computer science/informatics/infosec programs of the world, stop letting students graduate without command line experience. We still need that experience.
25
1,014
PROMPT_COMMAND='[ $? -eq 0 ] || printf "(╯°□°)╯︵ ┻━┻\n"' # You can set this in your bash shell config to flip a table whenever a command fails with a non-zero exit status.
9
991
for i in {128512..128591} {128640..128725} ; do printf "\U$(echo "ibase=10;obase=16;$i;" | bc) " ; done ; echo # Your terminal in Linux may now support color emoji in case you didn't notice. 😵🙈
A screenshot of a terminal window displaying many color emojis
17
1,038
p=3.14;for i in $( seq 0 0.04 100 );do r=$( printf "128+127*s($i)\n" |bc -l |cut -d. -f1) g=$( printf "128+127*s($i+$p*(1/3))\n" |bc -l |cut -d. -f1 ) b=$( printf "128+127*s($i+$p*(2/3))\n" |bc -l |cut -d. -f1 ); printf "\e[48;2;$r;$g;${b}m\n"; done # Sunrise in a 24-bit terminal
Embedded video
0:15
21
939
curl -s http://artscene.textfiles\.com/vt100/globe.vt | pv -L9600 -q # Spinning ASCII art globe. Visit the parent directory in that URL for more animations.
Embedded video
0:03
11
892
for f in {1..100};do L=UNIX;o=convert;k=50;i=0;a=($($o -list font|awk '/nt:/{print $2}'|shuf));x="eval w";s="";w(){ s=$s" -font ${a[$i]} -draw 'text $[k+150*$i],0 ${L:$i:1}'";i=$[++i]; };$x;$x;$x;$x;echo "$o -size 600x400 xc: -gravity west -pointsize 80 $s -negate $f.png";done|sh
The frames generated by the command in the post. It generates an animation where the word UNIX is spelled with different fonts (white on black background) and every half second the fonts change to something random. This is a similar effect to that which is used in title for the the TV show Loki.
GIF
16
889
A programmer was sentenced to 255 days in jail. He asked the judge if he could make it 256 days instead. The judge granted his request and the programmer walked free the next day.
27
725
"Google Now Bans Some Linux Web Browsers From Their Services" I think we should ban Google from using Linux now. Let's see how they feel about that.
22
635
Right now I'm logged into a server with a massive 4 petabyte filesystem within the Scholarly Data Archive at . I think the whole service has 42PB total storage. Someday this tweet may not be impressive, but not today! :D
Image
27
645
ping 8.8.8.8 | stdbuf -oL awk -F[=\ ] '/from/{ms=$(NF-1); print ms/1000.0 " " 1-ms/1000.0}' | while read on off ; do echo $on $off ; xset led 3 ; sleep $on ; xset -led 3 ; sleep $off ; done # Ping Google, but use Keyboard LED light 3 for feedback. Completely pointless, but fun.
10
676
convert inputmemeimage.png -font impact -fill white -pointsize 84 -stroke black -strokewidth 3 -gravity north -annotate +0+20 'TOP MEME TEXT' -gravity south -annotate +0+20 'BOTTOM MEME TEXT' outputmemeimage.png # Make your own meme image using Imagemagick.
Image
11
658
jp2a Photo.jpg | tee photo.ascii # Convert a photo into an ASCII art representation directly into the terminal and save it to photo.ascii at the same time.
Image
3
657
curl -r 28705-29696 -s http://artscene.textfiles\.com/vt100/globe.vt | sed -r '/^\e\[H /q' | GREP_COLORS="ms=01;32" egrep --color=always "[^ ]+" | GREP_COLORS="ms=01;44" grep -P --color=always -e "(?<=[^\ ])\ +" # Only take what you need. Happy #EarthDay!
A color ASCII or ANSI art of the Earth centered on Africa.
14
633
Whoops, I forgot to create my dynamic tunnel on this SSH session. No problem, just press [enter] in the ssh session, then literally ~C to open the SSH options prompt (ssh>). You can then specify your tunnel option of -D 8022 or whatever and it will create it.
10
614
sshfs user@remotehost:/remotedir localdir # sshfs is a util that uses FUSE and SSH to mount a remote directory as a local one. Saves the hassle of having to login to a remote system or copying files back and forth.
13
619
Downloading/installing Open Source Software: Run "$[packagemanager] install $[package]" Downloading "Mainstream" (such as Windows) software: Read fluffy article, looking for link. Click link (ad) Click back Click link (ad) Click back Click link Wait for download Delete malware
21
562
Son, now that you're 6, it's time I taught you about SSH. This is how you ssh into the computer upstairs and play a loud sound on it to scare your sister.
9
569
Happy 60th Birthday to Mark Adler (), who co-wrote gzip, zip and the zlib library, contributed to PNG development and has had significant roles in planetary exploration missions while at JPL and has an extremely out of date website. ;)
Image
8
572
Yes, right now something related to terminals and the command line is trending globally. Sure, it's Windows Terminal, but who cares. This just proves that the command line is here to stay because people find the CLI useful. It's not "old school", it's alternative.
Image
20
568
For the next time this comes up. IRC: 1. Free 2. Open 3. Extensible 4. Software on every platform. 5. Still there after 29 years. Ex: weechat ircs://irc.freenode.org/climagic
Image
17
547
Remember that certificate you created 10 years ago with a 10 year expiration time thinking you wouldn't need to worry about it expiring in 10 years because it'd be way past the system's lifetime? Well....
16
569
montage -font FreeSans-Bold -strokewidth 3 -stroke black -fill white -pointsize 80 -gravity south \( 1.jpg -annotate 0 LINKEDIN \) \( 2.jpg -annotate 0 FACEBOOK \) \( 3.jpg -annotate 0 INSTAGRAM \) \( 4.jpg -annotate 0 TINDER \) -tile 2x2 -mode Concatenate dc.jpg #DollyChallenge
Image
5
571
TIL: vim can directly work with zip file contents, viewing the files inside, and even editing them in place then re-compressing it when you're done.
Embedded video
0:26
17
568
git log --author=$USER --format="- %B" --since=-7days --reverse |mail -s "What I've done this week" boss@company\.com # Send a commit report to your boss
6
529
cd ~/Pictures && mkdir blurrybackgrounds && for i in *.jpg *.JPG *.png *.PNG ; do out=$(uuidgen).jpg ; convert -quality 75 "$i" -strip -auto-orient -resize 4x4 -resize 1920x1080\! "blurrybackgrounds/${out}" ; done # Use your photos and images to make nebulous backgrounds.
Image
Image
Image
Image
7
538
The command line is the jazz of the programming world; Once you learn the scales and have the feels, you can live-improvise a solution to nearly any problem. Not everyone likes jazz, but not everyone likes sonotas either.
6
474
clear ; for t in "Wake up" "The Matrix has you" "Follow the white rabbit" "Knock, knock";do clear;pv -qL10 <<<$'\e[2J'$'\e[32m'$t$'\e[37m';sleep 5;done
10
474
Running out of space on that 1TB drive? On Linux, the ext[234] filesystems reserve 5% of the space by default to only used by the root user, that's 50GB! You can reduce it to 2% with the following command (Replace sda1 with whatever): sudo tune2fs -m2 /dev/sda1
13
471