Hide

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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands by 0disse0 from sorted by
Terminal - Commands by 0disse0 - 56 results
mount -o loop,offset=$((512*x)) /path/to/dd/image /mount/path
2011-06-14 19:30:54
User: 0disse0
Functions: mount
Tags: dd mount fdisk
0

Assuming we have a disk image, created by dd if=/dev/sda of=image.dd we can check the image's partition layout with fdisk -ul image.dd, then substitute "x" with starting sector of the partition we want to mount. This example assumes that the disk uses 512Byte sectors

sudo update-rc.d -f nomescript stop 90 0 6
sudo update-rc.d -f nomemioscript start 99 2 3 4 5
mtop se -1
2011-06-14 19:12:13
User: 0disse0
Tags: mysql mtop
-2

mtop allows you to monitor the operation of a MySQL application in real time. See, among the high, the number of queries performed per second, slower queries, the number of active processes.

To install on Ubuntu

sudo apt-get-y install mtop

echo %logonserver%
2011-06-13 09:52:51
User: 0disse0
Functions: echo
-1

The command line can be accessed by using the cmd command which will open a command window with a DOS interface. The command line is a throw back to the early days of computing before there was a Windows interface.

xinput list | grep -i touchpad
2011-03-20 14:22:14
User: 0disse0
Functions: grep
-2

then

xinput set-prop 13 "Device Enabled" 0

how to disable touchpad, and

xinput set-prop 13 "Device Enabled" 1

how to enable again

"intelligenti pauca"

find /protocollo/paflow -type f -mtime +5 | xargs tar -cvf /var/dump-protocollo/`date '+%d%m%Y'_archive.tar`
2010-06-29 12:43:30
User: 0disse0
Functions: find tar xargs
Tags: find tar dump
0

The following command finds all the files not modified in the last 5 days under /protocollo/paflow directory and creates an archive files under /var/dump-protocollo in the format of ddmmyyyy_archive.tar

find / -type f -name *.tar.gz -size +10M -exec ls -l {} \;
2010-06-29 12:39:02
User: 0disse0
Functions: find ls
Tags: find ls exec rm type
0

Please be careful while executing the following command as you don?t want

to delete the files by mistake. The best practice is to execute the same

command with ls ?l to make sure you know which files will get deleted when

you execute the command with rm.

VBoxManage openmedium dvd "/path/name.iso"
2010-04-23 06:56:42
User: 0disse0
0

No comment... it's easy! Using the VBoxManage list and the switch 'hdds' or 'dvds' you can show the list of hard disks and DVD registered on the system.

VBoxManage createvm --name "vm-name" --ostype Ubuntu --register
VBoxManage list ostypes
2010-04-23 06:50:42
User: 0disse0
-1

If you want to know what OS are supported on "guest" machines on the Sun VirtualBox server.

VBoxManage showvminfo "cicciobox" --details
2010-04-23 06:45:29
User: 0disse0
Tags: virtualbox
-1

where "cicciobox" is the name of your virtual machine in a Sun VirtualBox server

VBoxManage list systemproperties
2010-04-23 06:43:49
User: 0disse0
Tags: virtualbox
-1

How to show the system properties of a Sun VirtualBox server

sudo ethtool -s eth0 speed 100 duplex full
2010-04-05 10:36:27
User: 0disse0
Functions: sudo
1

ethtool is used for querying settings of an ethernet device and changing them. In this example I setup 100 Mb/s full duplex on my Linux Box

hwclock --systohc -utc
scp -l10 pippo@serverciccio:/home/zutaniddu/* .
2010-02-19 16:44:24
User: 0disse0
Functions: scp
Tags: ssh scp bandwidth
11

the command is obvious, I know, but maybe not everyone knows that using the parameter "-l" you can limit the use of bandwidth command scp.

In this example fetch all files from the directory zutaniddu and I copy them locally using only 10 Kbs

-A INPUT -i eth1 -m mac ?mac 00:BB:77:22:33:AA -j ACCEPT
2010-01-31 15:34:31
User: 0disse0
2

edit the /etc/sysconfig/iptables file and try to work whit this:

-A INPUT -i (interface) -m mac (mac address) -j ACCEPT/DROP

mailq | grep MAILER-DAEMON | awk ?{print $1}? | tr -d ?*? | postsuper -d -
shred -u -z -n 17 rubricasegreta.txt
2010-01-31 15:24:54
User: 0disse0
Functions: shred
6

Instead, install apt-get install secure-delete and you can use:

-- srm to delete file and directory on hard disk

-- smem to delete file in RAM

-- sfill to delete "free space" on hard disk

-- sswap to delete all data from swap

sshpass -p [password] rsync -av -e ssh [utente]@[indirizzoip]:/directorydacopiare/ /directorydidestinazione
2010-01-31 15:21:14
User: 0disse0
Functions: rsync ssh
0

Check the ssh_config file and set the variable:

StrictHostKeyChecking no

python fsrecovery.py -P 0 -f <path-to-instance>/Data.fs <path-to-instance-destination>/Data.fs.packed
dd if=/dev/cdrom of=whatever.iso
2009-09-05 09:19:41
User: 0disse0
Functions: dd
Tags: backup dd iso dvd
7

A dear friend of mine asked me how do I copy a DVD to your hard drive? If you want to make a copy of the ISO image that was burned to a CD or DVD, insert that medium into your CD/DVD drive and (assuming /dev/cdrom is associated with your computer?s CD drive) type the following command

sudo dd if=/dev/hda1 of=/dev/hdb2
2009-09-05 09:16:52
User: 0disse0
Functions: dd sudo
5

This command clone the first partition of the primary master IDE drive to the second partition

of the primary slave IDE drive (!!! back up all data before trying anything like this !!!)

od -vt x1 /tmp/spaghettifile
sudo mknod /dev/ttyS4 c 4 68
2009-09-05 09:12:44
User: 0disse0
Functions: c++ mknod sudo
Tags: serial mknod tty
0

When you need to add another tty device that can automatically start at boot time