Commands tagged partition (23)

  • 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. Show Sample Output

    hwinfo --block --short
    Schneckentreiber · 2009-04-24 11:13:31 4
  • Shows the UUID of the given partition (here /dev/sda7). Doesn't need to be root. Show Sample Output

    blkid /dev/sda7
    lineak · 2010-09-05 12:20:45 1
  • Suppose you made a backup of your hard disk with dd: dd if=/dev/sda of=/mnt/disk/backup.img This command enables you to mount a partition from inside this image, so you can access your files directly. Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img). Show Sample Output

    INFILE=/path/to/your/backup.img; MOUNTPT=/mnt/foo; PARTITION=1; mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
    Alanceil · 2009-03-06 21:29:13 3
  • See size of partitions as human readable and get extra informations about hdd and partitions Show Sample Output

    parted /dev/sda print
    mesuutt · 2012-06-05 09:11:06 0
  • 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.

    lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo
    olorin · 2009-07-22 11:32:52 1

  • 4
    losetup /dev/loop0 harddrive.img; kpartx -a -v /dev/loop0; mount /dev/mapper/loop0p1 /mountpoint/
    oernii3 · 2010-10-30 11:52:11 3
  • Shows all block devices in a tree with descruptions of what they are.

    BasketCase · 2012-09-12 15:30:25 0

  • 2
    sfdisk -d /dev/sda | sed 's/sda/sdb/g' | sfdisk /dev/sdb
    kobayashison · 2009-12-22 23:35:30 0
  • 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) Show Sample Output

    df -l | grep -e "9.%" -e "100%"
    dooblem · 2010-04-26 17:57:54 0
  • The above command assumes the lost data is on /dev/sda and you previously issued the following command to mount _another_ disk or partition (/dev/sdb1) on /recovery sudo mount /dev/sdb1 /recovery If you don't do this, the data could be overwrited! foremost is a very powerful carving tool. By default foremost recovers all known file types. If you want to reduce the amount of files that are recovered you can specify the file type you are looking for. Read the man page to know the available file types. i.e to recover JPEG pictures append to foremost the switch -tjpg

    sudo foremost -i /dev/sda -o /recovery
    vlan7 · 2010-08-19 22:27:41 0
  • `blkid` is an interface to libuuid - it can read Device Mapper, EVMS, LVM, MD, and regular block devices. -c /dev/null - Do not use cached output from /etc/ or /etc/blkid/ (RHEL) -i - Display I/O Limits (aka I/O topology) information (not available in RHEL) -p - Low-level superblock probing mode (not available in RHEL) Show Sample Output

    blkid -c /dev/null
    mhs · 2012-09-12 13:34:41 2
  • lsblk | grep mountpoint Show Sample Output

    lsblk | grep <mountpoint>
    totti · 2014-02-05 09:41:00 1

  • 1
    sfdisk -d /dev/sda | sfdisk /dev/sdb
    wincus · 2010-02-03 14:49:07 1
  • Necessary for fsck for example. The remount functionality follows the standard way how the mount command works with options from fstab. It means the mount command doesn't read fstab (or mtab) only when a device and dir are fully specified. After this call all old mount options are replaced and arbitrary stuff from fstab is ignored, except the loop= option which is internally generated and maintained by the mount command. It does not change device or mount point.

    mount -o remount,ro /dev/foo /
    vlan7 · 2010-10-30 03:51:53 1
  • To get most of you HDD/SSD driver you need to make sure you partition are aligned, if not the speed penalty can be up to 50% slower! this simple one liner will check to see if each partition start sector is divided by 512 you need to change sda with your driver if you find the one of your partitions is not aligned use gparted to move the start sector of the partition to be divided of 512 Show Sample Output

    fdisk -l /dev/sda | grep -E sda[0-9]+ | sed s/*// | awk '{printf ("%s %f ",$1,$2/512); if($2%512){ print "BAD" }else {print "Good"} }' | column -t
    The_IceMan_Blog · 2012-05-18 08:34:36 1
  • Show the UUID-based alternate device names of ZEVO-related partitions on Darwin/OS X. Adapted from the lines by dbrady at and following the disk device naming scheme at Show Sample Output

    ls /dev/disk* | xargs -n 1 -t sudo zdb -l | grep GPTE_
    grahamperrin · 2012-10-06 20:19:45 0

  • 1
    mount -o sb=98304 /dev/sda5 /mnt/data5
    rugina · 2013-06-25 08:50:44 1
  • XX is your device partition number like /dev/sdc1 . to see how many inodes your partition have type: df --inodes (or df -i) Default formatting with ext4 would create small inode count for the new partition if you need big count of inodes is the fstype news the correct one. in debian you can see which fstype exists as template in: vim /etc/mke2fs.conf if you format default ext for a partition size with 1TB you would get 1 Million inodes (not enough for backupStorages) but if you format with fstype news you would get hunderd of millions of inodes for the partition. you have tune /etc/sysctl.conf also with following sysconfig parameters fs.file-max = XXX fs.nr_open = XXX where XXX is the count of max inodes for whole system

    mkfs.ext4 -T news /dev/sdcXX
    aysadk · 2019-07-02 13:31:23 0
  • Creates a single primary partition starting at sector 0 and extending to the end of the disk. Use with care.

    echo "0,,L" | sfdisk /dev/sdX
    twobitsprite · 2012-04-09 18:36:24 0
  • Another alternative to blkid, lsblk, file -s, cat /proc/paritions, fdisk -l, etc.. Show Sample Output

    fsarchvier probe simple
    0xFF · 2013-04-28 10:16:18 0

  • 0
    sudo dumpe2fs /dev/sda1 | grep superblock
    rugina · 2013-06-25 08:48:49 36

  • -1
    diskutil list
    grahamperrin · 2012-10-06 21:18:27 0
  • *as long as the drives are exactly the same* then this command copies the partition table on /dev/sda to /dev/sdb

    sfdisk /dev/sdb <(sfdisk -d /dev/sda| perl -pi -e 's/sda/sdb/g')
    linuxrawkstar · 2009-12-22 22:45:41 0

What's this? is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands

Check These Out

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

remove lines which are longer than 255

recursively change file name from uppercase to lowercase (or viceversa)
Example of zsh globing, glob qualifier, and substitution: -Q state that the parameter will contain a glob qualifier. (**/)(*) is recursive (.) is our glob qualifier, with states the match is a file "." The first parameter $1, is then substituted with $2 but with lowercasing '(L)' ... a (U) would of course be from lower to upper.

summarize a list of IP addresses, verifying IP address and giving counts for each IP found
Working with lists of IP addresses it is sometimes useful to summarize a count of how many times an IP address appears in the file. This example, summarizeIP, uses another function "verifyIP" previously defined in to ensure only valid IP addresses get counted. The summary list is presented in count order starting with highest count.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Easy way to scroll up und down to change to one of n last visited directories.
This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key. Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg...

Read PDFs in the command line
Turns a PDF into HTML (without images) and prints it to the standard out which is picked up and interpreted by w3m.

Given process ID print its environment variables
Same as previous but compatible with BSD/IPSO

Print the IPv4 address of a given interface

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.


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: