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.

Universal configuration monitoring and system of record for IT.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands tagged mount from sorted by
Terminal - Commands tagged mount - 30 results
sudo mount -o remount,rw /
2016-02-07 17:57:19
User: bugmenot
Functions: mount sudo

Warning this will allow you to write to the system image on the phone, not recommended. But sometimes useful.

mount -t cifs -o username=SlackerMojo,domain=BIGGREEDY,rw // /mnt/storage
(mountpoint -q "/media/mpdr1" && df /media/mpdr1/* > /dev/null 2>&1) || ((sudo umount "/media/mpdr1" > /dev/null 2>&1 || true) && (sudo mkdir "/media/mpdr1" > /dev/null 2>&1 || true) && sudo mount "/dev/sdd1" "/media/mpdr1")
2014-04-12 11:23:21
User: tweet78
Functions: df mkdir mount sudo umount

In my example, the mount point is /media/mpdr1 and the FS is /dev/sdd1

/mountpoint-path = /media/mpdr1


Why this command ?

Well, in fact, with some external devices I used to face some issues : during data transfer from the device to the internal drive, some errors occurred and the device was unmounted and remounted again in a different folder.

In such situations, the command mountpoint gave a positive result even if the FS wasn't properly mounted, that's why I added the df part.

And if the device is not properly mounted, the command tries to unmount, to create the folder (if it exists already it will also work) and finally mount the FS on the given mount point.

dpipe /usr/lib/openssh/sftp-server = ssh $REMOTE_HOST sshfs whatever:$LOCAL_PATH $REMOTE_PATH -o slave
2014-03-25 17:40:34
User: em
Functions: ssh

While `sshfs $REMOTE_HOST:$REMOTE_PATH $LOCAL_PATH` "pulls" a directory from the remote server to the local host, the above command does the reverse and "pushes" a directory from the local host to the remote server.

This makes use of the "slave" option of sshfs which instructs it to communicate over plain stdin/stdout and the `dpipe` tool from vde2 to connect the sftp-server stdout to the sshfs stdin and vice-versa.

proot -r /media/user/ubuntu12.10/ cat /etc/motd
2014-01-21 07:50:22
User: totti
Functions: cat

PRoot is a user-space implementation of chroot, mount --bind, and binfmt_misc. This means that users don't need any privileges or setup to do things like using an arbitrary directory as the new root filesystem, making files accessible somewhere else in the filesystem hierarchy, or executing programs built for another CPU architecture transparently through QEMU user-mode. Also, developers can use PRoot as a generic Linux process instrumentation engine thanks to its extension mechanism, see CARE for an example. Technically PRoot relies on ptrace, an unprivileged system-call available in every Linux kernel.


mount -o sb=98304 /dev/sda5 /mnt/data5
dd if=/dev/zero of=T bs=1024 count=10240;mkfs.ext3 -q T;E=$(echo 'read O;mount -o loop,offset=$O F /mnt;'|base64|tr -d '\n');echo "E=\$(echo $E|base64 -d);eval \$E;exit;">F;cat <(dd if=/dev/zero bs=$(echo 9191-$(stat -c%s F)|bc) count=1) <(cat T;rm T)>>F
2013-01-31 01:38:30
User: rodolfoap

This is just a proof of concept: A FILE WHICH CAN AUTOMOUNT ITSELF through a SIMPLY ENCODED script. It takes advantage of the OFFSET option of mount, and uses it as a password (see that 9191? just change it to something similar, around 9k). It works fine, mounts, gets modified, updated, and can be moved by just copying it.


The file is composed of three parts:

a) The legible script (about 242 bytes)

b) A random text fill to reach the OFFSET size (equals PASSWORD minus 242)

c) The actual filesystem

Logically, (a)+(b) = PASSWORD, that means OFFSET, and mount uses that option.

PLEASE NOTE: THIS IS NOT AN ENCRYPTED FILESYSTEM. To improve it, it can be mounted with a better encryption script and used with encfs or cryptfs. The idea was just to test the concept... with one line :)

It applies the original idea of http://www.commandlinefu.com/commands/view/7382/command-for-john-cons for encrypting the file.

The embedded bash script can be grown, of course, and the offset recalculation goes fine. I have my own version with bash --init-file to startup a bashrc with a well-defined environment, aliases, variables.

for P in $(mount | awk '/type nfs / {print $3;}'); do echo $P; sudo umount $P && sudo mount $P && echo "ok :)"; done
2012-10-14 22:39:58
User: amatix
Functions: awk echo mount sudo umount
Tags: Linux mount nfs

`mount -o remount` doesn't pick up new NFS options (eg. timeo, soft, retrans, etc) so you need to do a full mount/remount cycle. This one-liner makes it quick and easy :) Update your fstab with the new options, then run it.

umount -a -t cifs
cryptmount -m <name>
2012-01-17 18:02:47
User: totti

In order to create a new encrypted filing system managed by cryptmount,

you can use the supplied 'cryptmount-setup' program, which can be used

by the superuser to interactively configure a basic setup.

Alternatively, suppose that we wish to setup a new encrypted filing

system, that will have a target-name of "opaque". If we have a free

disk partition available, say /dev/hdb63, then we can use this directly

to store the encrypted filing system. Alternatively, if we want to

store the encrypted filing system within an ordinary file, we need to

create space using a recipe such as:

dd if=/dev/zero of=/home/opaque.fs bs=1M count=512


cryptmount --generate-key 32 opaque


cryptmount --prepare opaque


mke2fs /dev/mapper/opaque


cryptmount --release opaque


mkdir /home/crypt


cryptmount -m opaque


cryptmount -u opaque

For detail see sample output

for D in `mount -lt cifs | sed 's/.*on \(\/.\+\) type.*/\1/'`; do echo -n "UNMOUNTING $D..."; sudo umount $D; echo " [DONE]"; done;
2011-10-19 18:14:19
User: crazedsanity
Functions: echo sed sudo umount

Unmounts all CIFS-based network drives. Very nice for shutting down network mounts on a Linux laptop just prior to going to sleep.

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

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

losetup /dev/loop0 harddrive.img; kpartx -a -v /dev/loop0; mount /dev/mapper/loop0p1 /mountpoint/
( di $TOFSCK -h ; /bin/umount $TOFSCK ; time /sbin/e2fsck -y -f -v $FSCKDEV ; /bin/mount $TOFSCK ) |& /bin/mail $MAILTO -s "$MAILSUB"
2010-10-24 00:35:23
User: px
Functions: time

This one-liner is for cron jobs that need to provide some basic information about a filesystem and the time it takes to complete the operation. You can swap out the di command for df or du if that's your thing. The |& redirections the stderr and stdout to the mail command.

How to configure the variables.




FSCKDEV=`grep $TOFSCK /proc/mounts | cut -f1 -d" "`

MAILSUB="weekly file system check $TOFSCK "

df -l | grep -e "9.%" -e "100%"
2010-04-26 17:57:54
User: dooblem
Functions: df grep

Reports all local partitions having more than 90% usage.

Just add it in a crontab and you'll get a mail when a disk is full.

(sending mail to the root user must work for that)

truecrypt volume.tc
2010-04-14 18:34:09
User: rkulla

This should automatically mount it to /media/truecrypt1. Further mounts will go to /media/truecrypt2, and so on. You shouldn't need sudo/su if your permissions are right.

I alias tru='truecrypt' since tr and true are commands.

To explicitly create a mount point do: tru volume.tc /media/foo

To make sure an GUI explorer window (nautilus, et al) opens on the mounted volume, add: --explorer

To see what you currently have mounted do: tru -l

To dismount a volume do: tru -d volume.tc. To dismount all mounted volumes at once do: tru -d

Tested with Truecrypt v6.3a / Ubuntu 9.10

smbmount //<ip>/<resource> <local_mount_point>
mount -o loop -t iso9660 my.iso /mnt/something
2009-12-30 18:49:30
User: kanzure
Functions: mount
Tags: mount iso

mounts an ISO file to a directory on the target file system

sudo mount -t cifs -o credentials=/path/to/credenials //hostname/sharename /mount/point
2009-11-23 23:55:20
User: magma_camel
Functions: mount sudo

mounts a samba share on a remote machine using a credentials file that can be in a file tht is not accessable by other users the file will look like:



best option i belive

for file in *.iso; do mkdir `basename $file | awk -F. '{print $1}'`; sudo mount -t iso9660 -o loop $file `basename $file | awk -F. '{print $1}'`; done
column -t /proc/mounts
2009-08-09 17:00:41
Functions: column

since fuse mounts do not appear in /etc/mtab (fuse can't write there, dunno if it would if it could) this is propably a better way.

lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo

Instead of calculating the offset and providing an offset option to mount, let lomount do the job for you by just providing the partition number you would like to loop mount.

hwinfo --block --short
2009-04-24 11:13:31

Yields entries in the form of "/dev/hda1" etc.

Use this if you are on a new system and don't know how the storage hardware (ide, sata, scsi, usb - with ever changing descriptors) is connected and which partitions are available.

Far better than using "fdisk -l" on guessed device descriptors.

for i in sys dev proc; do sudo mount --bind /$i /mnt/xxx/$i; done
2009-04-20 16:52:14
User: amosshapira
Functions: mount sudo
Tags: bash mount chroot

The command is useful when, e.g., booting an existing system with a rescue or installation CD where you need to chroot into the hard-disk and be able to do stuff which accesses kernel info (e.g. when installing Ubuntu desktop with LVM2 you need to mount and chroot the hard disk from a shell window in order to install packages and run initramfs inside chroot).

The command assumes that /mnt/xxx is where the chroot'ed environment's root file system on the hard disk is mounted.

sudo vi /etc/fstab; Go//smb-share/gino /mnt/place smbfs defaults,username=gino,password=pass 0 0<esc>:wq; mount //smb-share/gino
2009-04-02 16:04:35
User: GinoMan2440
Functions: mount sudo vi

the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.