This command creates a rar archive from all files in the current folder and names the archive after the folder name.
waste the band width Show Sample Output
Useful for massive files where doing a full diff would take too long. This just runs diff on the first 500 lines of each. The use of subshells to feed STDIN is quite a useful construct.
Return the current shell. It is better than print $SHELL which can sometimes return a false value. Show Sample Output
Add @mail.com each line of a list Show Sample Output
This open the cd rom device and close it in a loop
Check if Fail2Ban is running on the system and alert it with a message in the terminal Show Sample Output
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)
#!/bin/sh _HOSTNAME=`hostname` _HOSTTYPE=`echo $HOSTTYPE` _MACHINETYPE=`echo $MACHTYPE` _OSTYPE=`echo $OSTYPE` _VENDOR=`echo $VENDOR` _KERNEL=`uname -r | awk -F- '{print $1}'` _GLIBC=`ls /lib/libc-*.so | awk -F- '/lib/ {print $2}' | awk -F. '{print $1"."$2}'` _MEM=`cat /proc/meminfo | awk '/MemTotal/ {print $2 $3}'` _CPU=`cat /proc/cpuinfo | grep 'cpu MHz' | awk '{print $4}'` echo '==============================' echo 'HOSTNAME ' $_HOSTNAME echo 'HOSTTYPE ' $_HOSTTYPE echo 'MACHINETYPE ' $_MACHINETYPE echo 'OSTYPE ' $_OSTYPE echo 'VENDOR ' $_VENDOR echo 'KERNEL ' $_KERNEL echo 'GLIBC ' $_GLIBC echo 'MEM INFO ' $_MEM echo 'CPU INFO ' $_CPU echo '==============================' Show Sample Output
This command requires the imagemagick libraries and will resize all files with the .jpg extension to a width of 1024 pixels and will keep the same proportions as the original image.
apt-get must be run as root, and it is useless to run it as your own user. So just run it as root. Saves you the "sudo !!" every time you're adding a package.
If your web server is down, this command will periodically attempt to connect to it. If the output is blank, your server is not yet up. If you see HTML, your server is up. Obviously, you need to replace the Google URL with your web server URL... * 'watch' -- a command for re-executing a command and displaying the output * '-n 15' -- tells watch to redo the command every 15 seconds * 'curl' -- a handy utility for getting the source of a web page * '-s' -- tells curl to be silent about failing * '--connect-timeout 10' -- Try to connect for 10 seconds
get subversion diff output without distracting whitespace changes. good for when you are cleaning up code to make sure you didn't change anything important. also useful when working with old code, or someone else's code.
copying files from one server to another using rysnc. Root access need to be allowed on the destination.
Changing a file extension to a new one for all files in a directory.
Changing files ownership in a directory recursivley from a user to another
A useful bash function: gztardir() { if [ $# -ne 1 ] ; then echo "incorrect arguments: should be gztardir " else tar zcvf "${1%/}-$(date +%Y%m%d-%H%M).tar.gz" "$1" fi }
This removes the type prefix used in Hungarian notation (v. bad) for PHP variables. Eg. variables of the form $intDays, $fltPrice, $arrItems, $objLogger convert to $days, $price, $Items, $logger.
commandlinefu.com 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.
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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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: