Commands by kostis (3)

  • As an alternative to the above command, this one ditches the unnecessary and complicated for loop in favor of a way faster multi-core approach for a task that's more CPU than I/O intensive, making it a perfect suite for GNU parallel

    parallel cwebp -q 80 {} -o {.}.webp ::: *.png
    kostis · 2018-12-07 23:37:24 1
  • You could have that little benchmark run on all cores in parallel, as a multi-core benchmark or stress test First find the number of cores, then have parallel iterate over that in, well, parallel Show Sample Output

    time cat /proc/cpuinfo |grep proc|wc -l|xargs seq|parallel -N 0 echo "2^2^20" '|' bc
    kostis · 2018-12-06 05:36:55 0
  • Broken in two parts, first get the number of cores with cat /proc/cpuinfo |grep proc|wc -l and create a integer sequence with that number (xargs seq), then have GNU parallel loop that many times over the given command. Cheers! Show Sample Output

    time cat /proc/cpuinfo |grep proc|wc -l|xargs seq|parallel -N 0 echo "scale=4000\; a\(1\)\*4" '|' bc -l
    kostis · 2018-12-06 05:15:24 2

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Hostname tab-completion for ssh
This is meant for the bash shell. Put this function in your .profile and you'll be able to use tab-completion for sshing any host which is in your known_hosts file. This assumes that your known_hosts file is located at ~/.ssh/known_hosts. The "complete" command should go on a separate line as such: function autoCompleteHostname() { local hosts=($(awk '{print $1}' ~/.ssh/known_hosts | cut -d, -f1)); local cur=${COMP_WORDS[COMP_CWORD]}; COMPREPLY=($(compgen -W '${hosts[@]}' -- $cur )) } complete -F autoCompleteHostname ssh

Remove multiple same rpm packages
If somehow if you get more than 1 same name rpm package install, then it cannot be removed by using simple rpm -e as it gives you more than one rpm matches error. The --matches will help to remove all the same name rpm packages.

Find the package that installed a command

Restore user,group and mod of an entire website
I often use it at my work, on an ovh server with root ssh access and often have to change mod after having finished an operation. This command, replace the user, group and mod by the one required by apache to work.

DVD to YouTube ready watermarked MPEG-4 AVI file using mencoder (step 2)
Reencodes to MPEG-4 DivX output video file from step 1. Audio stream is simply copied. Resizes to 320x240 and deinterlaces as needed. A heading subtitle file is applied as watermark. This heading subtitle file can be a URL.

Copy without overwriting

Start an X app remotely
Launch a gui app remotely. In this example smplayer is installed on the remote machine, and movie.avi is in the remote user's home dir. Note that stdout/stderr is still local, so you'll have feedback locally, add '&>/dev/null' to suppress. This is surprisingly not well known (compared to running an X app locally via ssh -X). (NB. if your distro requires ~/.Xauthority file present, then try -fX if you have problems) Resubmitted (and trimmed, thanks sitaram) due to ridiculous voting on previous submission. Fingers crossed, it gets a better rating this time.

Run a command as root, with a delay
$ sleep 1h ; sudo command or $ sudo sleep 1h ; sudo command won't work, because by the time the delay is up, sudo will want your password again.

See entire packet payload using tcpdump.
This command will show you the entire payload of a packet. The final "s" increases the snaplength, grabbing the whole packet.

Create a file of a given size in linux

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: