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 using mount from sorted by
Terminal - Commands using mount - 60 results
NFSPATH=/mountpoint TIMEOUT=5; perl -e "alarm $TIMEOUT; exec @ARGV" "test -d $NFSPATH" || (umount -fl $NFSPATH; mount $NFSPATH)
2010-06-04 07:58:53
User: keymon
Functions: mount perl umount
-1

Based on the execute with timeout command in this site.

A more complex script:

#!/bin/sh

# This script will check the avaliability of a list of NFS mount point,

# forcing a remount of those that do not respond in 5 seconds.

#

# It basically does this:

# NFSPATH=/mountpoint TIMEOUT=5; perl -e "alarm $TIMEOUT; exec @ARGV" "test -d $NFSPATH" || (umount -fl $NFSPATH; mount $NFSPATH)

#

TIMEOUT=5

SCRIPT_NAME=$(basename $0)

for i in $@; do

echo "Checking $i..."

if ! perl -e "alarm $TIMEOUT; exec @ARGV" "test -d $i" > /dev/null 2>&1; then

echo "$SCRIPT_NAME: $i is failing with retcode $?."1>&2

echo "$SCRIPT_NAME: Submmiting umount -fl $i" 1>&2

umount -fl $i;

echo "$SCRIPT_NAME: Submmiting mount $i" 1>&2

mount $i;

fi

done

mount -o loop -t iso9660 my.iso /mnt/something
2009-12-30 18:49:30
User: kanzure
Functions: mount
Tags: mount iso
6

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

mount -t msdos /dev/fd0 /mnt/floppy
2009-12-10 06:46:53
User: eastwind
Functions: mount
-2

-t option tells the system to look for a msdos filesystem

The /dev/fd0 is your floppy drive ( This may be different for you check /dev folder to confirm)

/mnt/floppy is the point where you want to mount the device to

mount -t iso9660 /dev/cdrom /media/cdrom
mount -o loop,offset=$((512*x)) /path/to/dd/image /mount/path
2009-11-25 15:49:30
User: rocku
Functions: mount
3

Assuming we have a disk image, ie. created by

dd if=/dev/sda of=image.dd

we can check the image's partition layout with

fdisk -ul image.dd

then, we substitute "x" with starting sector of the partition we want to mount. This example assumes that the disk uses 512 B sectors

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
-2

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:

username="username"

password="password"

best option i belive

sudo mount -t cifs -o user,username="samba username" //$ip_or_host/$sharename /mnt
sudo mount -t cifs //$ip_or_host/$sharename /mnt
2009-11-23 14:24:02
User: sb
Functions: mount sudo
-2

Mount a Windows share. Usually the IP is needed for the $ip_or_host option. Getting hostnames working on a local network never seems to work.

mount | awk '/:/ { print $3 } ' | xargs sudo umount
sudo mount -t vfat /dev/sdb1 /mnt/sdb1
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
hdiutil mount sample.iso
mount -t ntfs-3g -o ro,loop,uid=user,gid=group,umask=0007,fmask=0117,offset=0x$(hd -n 1000000 image.vdi | grep "eb 52 90 4e 54 46 53" | cut -c 1-8) image.vdi /mnt/vdi-ntfs
mount -t unionfs -o dirs=/tmp/unioncache=rw:/mnt/readonly=ro unionfs /mnt/unionfs
2009-08-23 14:16:13
User: Cowboy
Functions: mount
3

First look into /etc/modules if you have unionfs (or squashfs) support. If not, add the modules. UnionFS combines two filesystems. If there is a need to write a file, /tmp/unioncache will be used to write files (first create that directory). Reads will be done where the file is found first.

http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html

vditool COPYDD my.vdi my.dd ; sudo mount -t ntfs -o ro,noatime,noexex,loop,offset=32256 my.dd ./my_dir
mount -F hsfs -o ro `lofiadm -a /sol-10-u7-ga-sparc-dvd.iso` /mnt
2009-07-29 13:56:25
User: apaton
Functions: mount
2

Unmount

umount /mnt

Delete loopback file device

lofiadm -d /dev/lofi/1
mount -t vfat /dev/sdx1 /media/psp/
init=/bin/bash; mount -o remount,rw /
2009-06-18 08:51:24
User: m03hr3
Functions: init mount
2

Appended to grub boot parameters ... gives shell ... password recovery

mkdir -p /cdrom/unnamed_cdrom ; mount -F hsfs -o ro `ls -al /dev/sr* |awk '{print "/dev/" $11}'` /cdrom/unnamed_cdrom
2009-05-31 08:42:20
User: felix001
Functions: awk mkdir mount
-2

This will allow you to mount a CD-ROM on Solaris SPARC 9 or lower. This will not work on Solaris 10 due to void and the volume management daemons.

www.fir3net.com

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
3

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.

mount --bind /old/directory/path /new/directory/path
2009-04-19 01:44:59
User: dryicerx
Functions: mount
4

Like symlinked directories, you can mount a directory at a different location. For example mounting a directory from one location in to the http root without having to make your program follow symlinks or change permissions when reading.

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
4

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.

mount.gmailfs none /mount/path/ [-o username=USERNAME[,password=PASSWORD][,fsname=VOLUME]] [-p]
2009-03-28 13:00:47
User: cammarin
Functions: mount
Tags: gmailfs fuse
5

Packages: gmailfs fuse-utils libfuse2 gvfs-fuse

Config files: /etc/gmailfs/gmailfs.conf; ~/.gmailfs.conf (make a copy from the another one)

Unmount:

fusermount -u /mount/path/

/etc/fstab (Optional):

none /mount/path/ gmailfs

noauto,user[,username=USERNAME,password=PASSWORD,fsname=VOLUME] 0 0

NOTES:

- The options between [] are optional since they already setuped on the config files.

- The '-p' flag shows a prompt for the password entry.

- It's necessary to add the user to the 'fuse' group. You can do that with:

sudo chgrp fuse /dev/fuse

and

sudo usermod -a -G fuse USER

- The volume name is not needed but highly recommended to avoid file corruption. Also choose a non-trivial name.

- Google doesn't approve the use of Gmail account other than e-mail purposes. So, I recommend the creation of a new account for this.

mount -t smbfs //$server/share /local/mount -o rw,username=$USER
2009-03-25 01:05:17
User: sufoo
Functions: mount
1

Mount an smb share with this command. other options -ousername=$USERr,gid=$groupname,scope=rw

mount | column -t
2009-03-20 14:18:56
User: thechile
Functions: column mount
233

Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.