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.

Universal configuration monitoring and system of record for IT.
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

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Hide

Credits

Display which distro is installed

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

Alternatives

There are 5 alternatives - vote for the best!

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

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

Found in comments section works on most Linux flavors.

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

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 332 weeks and 4 days ago

Is lsb_release a better command for this?

Comment by int19h 332 weeks and 2 days ago

ls /etc/*release

is better IMO, "issue" contais welcome message

Comment by unixmonkey1054 332 weeks and 1 day 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 332 weeks and 1 day 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 332 weeks and 1 day 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 331 weeks and 6 days ago

Hrm.. How about

test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
Comment by mulad 331 weeks and 6 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)"

endif

end

else

uname -s -r

endif

Comment by rae 331 weeks and 5 days ago

rpm -qf /etc/*-release

Comment by megacoder 278 weeks and 2 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.

FYI.

Comment by atoponce 265 weeks and 5 days ago

Your point of view

You must be signed in to comment.