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/
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.
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.
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:
Based on the execute with timeout command in this site.
A more complex script:
# 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)
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
mounts an ISO file to a directory on the target file system
-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
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
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
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.
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.
Tested with NTFS and found on this site:
The first 32256 bytes is the MBR
Delete loopback file device
lofiadm -d /dev/lofi/1
Appended to grub boot parameters ... gives shell ... password recovery
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.
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.
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.
Packages: gmailfs fuse-utils libfuse2 gvfs-fuse
Config files: /etc/gmailfs/gmailfs.conf; ~/.gmailfs.conf (make a copy from the another one)
fusermount -u /mount/path/
none /mount/path/ gmailfs
noauto,user[,username=USERNAME,password=PASSWORD,fsname=VOLUME] 0 0
- 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
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 an smb share with this command. other options -ousername=$USERr,gid=$groupname,scope=rw
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.