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

detect partitions

Terminal - detect partitions
sudo file -bs /dev/sda | sed -e 's/.*partition 1\(.*\) code offset.*/partition 1\1/g' -e 's/\(.\);/\1\n/g'
2012-08-17 12:54:05
User: jlaunay
Functions: file sed sudo
0
detect partitions

Alternatives

There is 1 alternative - vote for the best!

Terminal - Alternatives
file -s /dev/sd*
2010-12-28 09:56:03
User: mhs
Functions: file
Tags: file devfs
24

file(1) can print details about certain devices in the /dev/ directory (block devices in this example). This helped me to know at a glance the location and revision of my bootloader, UUIDs, filesystem status, which partitions were primaries / logicals, etc.. without running several commands.

See also:

file -s /dev/dm-* file -s /dev/cciss/*

etc..

file -s /dev/sd*
2010-12-28 09:56:03
User: mhs
Functions: file
Tags: file devfs
24

file(1) can print details about certain devices in the /dev/ directory (block devices in this example). This helped me to know at a glance the location and revision of my bootloader, UUIDs, filesystem status, which partitions were primaries / logicals, etc.. without running several commands.

See also:

file -s /dev/dm-* file -s /dev/cciss/*

etc..

blkid -c /dev/null
2012-09-12 13:34:41
User: mhs
2

`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/blkid.tab or /etc/blkid/blkid.tab (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)

lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,MODEL,MOUNTPOINT
2012-09-12 15:30:25
User: BasketCase
2

Shows all block devices in a tree with descruptions of what they are.

fsarchvier probe simple
0

Another alternative to blkid, lsblk, file -s, cat /proc/paritions, fdisk -l, etc..

Know a better way?

If you can do better, submit your command here.

What others think

Interesting.

You don't need to create a temporary file, simply add '-s' to the file command.

sudo file -bs /dev/sda | sed -e 's/.*partition 1\(.*\) code offset.*/partition 1\1/g' -e 's/\(.\);/\1\n/g'
Comment by flatcap 108 weeks and 5 days ago

I did not know the -s option to make file read a block device, thanks for pointing this.

I update the command according to your advices

Comment by jlaunay 108 weeks and 5 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts