What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. 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.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands by starchox from sorted by
Terminal - Commands by starchox - 26 results
find ./ ! -name 'excludepattern' | xargs -i cp --parents {} destdir
2010-09-27 21:36:50
User: starchox
Functions: cp find xargs
Tags: find xargs cp

Preserve file structure when coping and exclude some file o dir patterns

find . -name 'pattern'| xargs du -hc
cat /proc/acpi/thermal_zone/*/temperature
2010-03-28 01:30:14
User: starchox
Functions: cat

A quick way of know the temperature info.

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock
2010-01-26 17:50:10
User: starchox

If you wish to launch the kde4 screen saver without the password prompt to exit, use this command:

qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SetActive True

Also can be done with:

/usr/lib/kde4/libexec/kscreenlocker --forcelock
dir='path to file'; tar cpf - "$dir" | pv -s $(du -sb "$dir" | awk '{print $1}') | tar xpf - -C /other/path
2010-01-19 19:05:45
User: starchox
Functions: awk dir du tar
Tags: copy tar cp

This may seem like a long command, but it is great for making sure all file permissions are kept in tact. What it is doing is streaming the files in a sub-shell and then untarring them in the target directory. Please note that the -z command should not be used for local files and no perfomance increase will be visible as overhead processing (CPU) will be evident, and will slow down the copy.

You also may keep simple with, but you don't have the progress info:

cp -rpf /some/directory /other/path
file='path to file'; tar -cf - "$file" | pv -s $(du -sb "$file" | awk '{print $1}') | gzip -c | ssh -c blowfish [email protected] tar -zxf - -C /opt/games
2010-01-19 16:02:45
User: starchox
Functions: awk du file gzip ssh tar

You set the file/dirname transfer variable, in the end point you set the path destination, this command uses pipe view to show progress, compress the file outut and takes account to change the ssh cipher. Support dirnames with spaces.

Merged ideas and comments by http://www.commandlinefu.com/commands/view/4379/copy-working-directory-and-compress-it-on-the-fly-while-showing-progress and http://www.commandlinefu.com/commands/view/3177/move-a-lot-of-files-over-ssh

tune2fs -O extents,uninit_bg,dir_index /dev/yourpartition
2009-06-23 17:42:01
User: starchox
Functions: tune2fs

Before doing this, back-up all data on any ext3 partitions that are to be converted to ext4.

After running previous command you MUST run fsck, is needed to return the filesystem to a consistent state.

fsck -pDf /dev/yourpartition

Edit /etc/fstab and change the 'type' from ext3 to ext4 for any partitions that are converted to ext4.

ssh -L :: -L :: @
2009-06-22 19:12:48
User: starchox
Functions: ssh

Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command.

Remeber if you want a priviliged port on your machine, you must use root or sudo account.

convert image123.png -colors 14 -resize 640x480 grubimg.xpm
2009-03-12 22:55:10
User: starchox
Tags: Linux grub boot

* size must be 640?480 pixels

* only has 14 colors

* save it in XPM format

Edit /boot/grub/menu.lst and add


make sure for your path name and hard disk

find /usr/lib -maxdepth 1 -type l -print0 | xargs -r0 du -Lh
2009-03-07 00:17:45
User: starchox
Functions: du find xargs

You also can sum the file usage of all files

find /usr/lib -maxdepth 1 -type l -print0 | xargs -r0 du -Lch
ttmkfdir mkfontdir fc-cache /usr/share/fonts/miscttf
2009-03-06 21:28:17
User: starchox
Functions: fc-cache

First you have to create a directory in your system, where the fonts will be stored, and copy them.

sudo mkdir /usr/share/fonts/miscttf; sudo cp *.ttf /usr/share/fonts/miscttf

After recharge cache with the command

find . -type d \( -name DIR1 -o -name DIR2 \) -prune -o -type f -print0 | xargs -r0 md5sum
2009-03-05 21:26:24
User: starchox
Functions: find xargs
Tags: bash

Useful if you want get all the md5sum of files but you want exclude some directories. If your list of files is short you can make in one command as follow:

find . -type d \( -name DIR1 -o -name DIR2 \) -prune -o -type f -exec md5sum {} \;

Alternatively you can specify a different command to be executed on the resulting files.

tar zcpf backup.tgz --exclude=/proc --exclude=backup.tgz /
2009-02-18 19:31:27
User: starchox
Functions: tar

You can exclude more system folders or individual files which are not necessary for the backup and can be recreated after the restore procedure, like /lost+found, /mnt, /media, /tmp, /usr ...

Restoring the above backup procedure is as simple as becoming root and typing:

tar zxpf backup.tgz -C /

You can extract any file or directory out of the backup.tgz file for recovery, for instance, if you have a corrupt or mis-configured fstab file, you could simply issue the command:

tar zxpf backup.tgz /ect/fstab -C /

Other options:

v add verbose option to see files processed

A far safer solution is to restore the desired files under a different directory, and then compare, move, or update the files to their original locations afterward.

rm ./-filename
2009-02-18 18:36:25
User: starchox
Functions: rm

Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command.

Also works using:

rm -- -filename
blockdev --setra 1024 /dev/sdb
2009-02-18 16:27:01
User: starchox

(WARN) This will absolutely not work on all systems, unless you're running large, high speed, hardware RAID arrays. For example, systems using Dell PERC 5/i SAS/SATA arrays. If you have a hardware RAID array, try it. It certainly wont hurt.

You may be can test the speed disk with some large file in your system, before and after using this:

time dd if=/tmp/disk.iso of=/dev/null bs=256k

To know the value of block device parameter known as readahead.

blockdev --getra /dev/sdb

And set the a value 1024, 2048, 4096, 8192, and maybe 16384... it really depends on the number of hard disks, their speed, your RAID controller, etc. (see sample)

ls -d */
2009-02-18 14:00:42
User: starchox
Functions: ls

This command would be useful when it is desirable to list only the directories.

Other options

Hidden directory

ls -d .*/

Other path

ls -d /path/to/top/directory/.*/

Long format:

ls -ld */
nmap -sS -P0 -sV -O <target>
2009-02-18 07:32:03
User: starchox
Tags: Network net

Where < target > may be a single IP, a hostname or a subnet

-sS TCP SYN scanning (also known as half-open, or stealth scanning)

-P0 option allows you to switch off ICMP pings.

-sV option enables version detection

-O flag attempt to identify the remote operating system

Other option:

-A option enables both OS fingerprinting and version detection

-v use -v twice for more verbosity.

nmap -sS -P0 -A -v < target >
2009-02-18 05:56:07
User: starchox

You can convert a FAT or FAT32 volume to an NTFS volume without formatting the drive, though it is still a good idea to back up your data before you convert.

defaults write com.apple.dashboard mcx-disabled -boolean YES; killall Dock
2009-02-17 23:22:24
User: starchox
Functions: killall write

Dashboard is OS X utility application. When you hit F12, Dashboard springs forward, dimming the background, some people have claimed memory or performance problems. In my case, I just don't use it, there may be other reasons you?d rather not have Dashboard available.

Change YES to NO to restore the previous functionality.

wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
2009-02-17 22:53:07
User: starchox
Functions: wget

-p parameter tells wget to include all files, including images.

-e robots=off you don't want wget to obey by the robots.txt file

-U mozilla as your browsers identity.

--random-wait to let wget chose a random number of seconds to wait, avoid get into black list.

Other Useful wget Parameters:

--limit-rate=20k limits the rate at which it downloads files.

-b continues wget after logging out.

-o $HOME/wget_log.txt logs the output

vncserver -nohttpd -name hidef-server -depth 24 -geometry 1440x900
2009-02-17 17:50:33
User: starchox
Tags: Network , net

-nohttpd don't run mini-httpd if VNC java applet is found

-name change the name of the desktop, it's passed to xstartup script via $VNCDESKTOP, run different set of apps acording the name.

-depth pixel depth in bits of the desktop, default is 16

-geometry size of the desktop, default is 1024x768

grep -c -e '^cpu[0-9]\+' /proc/stat
fortune -s -c -a | cowthink -d -W 45
2009-02-16 21:45:33
User: starchox

The popular fortune program telling by a cow (see sample).

- fortune

- cowsay

perl -pi -e 's:^V^M::g' <filenames>
2009-02-16 21:17:40
User: starchox
Functions: perl

That "^M" is Ctrl-M, which is a carriage return, and is not needed in Unix file systems.

Where ^V is actually Ctrl-V and ^M is actually Ctrl-M (you must type these yourself, don't just copy and paste this command). ^V will not be displayed on your screen.

netstat -putona
2009-02-16 19:14:35
User: starchox
Functions: netstat

-p PID and name of the program

-u on a UDP port.

-t also TCP ports

-o networking timer

-n numeric IP addresses (don't resolve them)

-a all sockets