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.

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:



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.

Top Tags



Display which distro is installed

Terminal - Display which distro is installed
cat /etc/issue
2009-02-03 09:59:24
User: root
Functions: cat
Display which distro is installed


There are 11 alternatives - vote for the best!

Terminal - Alternatives
cat /etc/*release
2010-05-26 11:58:34
User: dog
Functions: cat

Works on nearly all linux distros

lsb_release -a
lsb_release -a
test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
2009-07-07 20:51:30
User: virtualshock
Functions: cat test uname

Found in comments section works on most Linux flavors.

rpm -qf /etc/*-release
2010-03-01 01:24:07
User: megacoder
Functions: rpm

This should work on any RPM-based distribution. It's more reliable than trying to parse the content of the files.

Know a better way?

If you can do better, submit your command here.

What others think

Doesn't work with Gentoo

Comment by scottix 322 weeks and 1 day ago

Is lsb_release a better command for this?

Comment by int19h 321 weeks and 5 days ago

ls /etc/*release

is better IMO, "issue" contais welcome message

Comment by unixmonkey1054 321 weeks and 5 days ago
ls /etc/*release

ls: /etc/*release: No such file or directory

cat /etc/issue

cat: /etc/issue: No such file or directory

uname -rms

FreeBSD 7.1-STABLE i386

uname works better

Comment by grep 321 weeks and 5 days ago

How about this one, does it work for everybody?

grep -qs "" /etc/lsb-release && lsb_release -a | grep -v n/a | grep -v none; uname -rms

Comment by int19h 321 weeks and 4 days ago

Checked it on Solaris, and noted that no such info was printed - it was a custom message set by the admin.

Comment by rommelsharma 321 weeks and 3 days ago

Hrm.. How about

test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
Comment by mulad 321 weeks and 2 days ago

Here's a csh script I use to find the OS version. Works on various Linuxes and Mac OS X:

#!/bin/csh -f

if(-r /etc/fedora-release) then

cat /etc/fedora-release

else if(-r /etc/lsb-release) then

perl -ne 'if(/DESCRIPTION/) { s/.*="(.*)"/$1/; print; }' /etc/lsb-release

else if(-r /etc/debian_version) then

echo "Debian `cat /etc/debian_version`"

else if(-d /System/Library) then

set version_plist=System/Library/CoreServices/SystemVersion.plist

foreach vol (/Volumes/*)

if(-r "$vol/$version_plist") then

set name=`defaults read "$vol/${version_plist:r}" ProductName`

set build=`defaults read "$vol/${version_plist:r}" ProductBuildVersion`

set version=`defaults read "$vol/${version_plist:r}" ProductUserVisibleVersion`

printf "%-16s %10s %-10s %10s\n" "${vol:t}" "$name" "$version" "(build $build)"




uname -s -r


Comment by rae 321 weeks and 2 days ago

rpm -qf /etc/*-release

Comment by megacoder 267 weeks and 5 days ago

This is the best alternative, but it's not bullet proof. /etc/issue can be any custom message provided by the administrator. While it might work on home machines, or small business servers, it's unlikely to give you anything useful in schools, government organizations, large corporate enterprises, etc.

Fact of the matter is, when you're using an operating system, for whatever purpose, you should know what it is long before you start using it.


Comment by atoponce 255 weeks and 2 days ago

Your point of view

You must be signed in to comment.