LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-29-2007, 01:14 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
how to get OS name from command line


Hi

Which is the best way (which will work on any os) to get OS name and version from command line ?

Thank you!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-29-2007, 01:44 AM   #2
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
When you say "any" do you mean "any", or "any *nix"?
 
Old 05-29-2007, 01:46 AM   #3
mike33
Member
 
Registered: Jul 2004
Location: Houston Tx
Distribution: kubuntu, Debian, Suse 10.2
Posts: 31

Rep: Reputation: 15
The following command is probably what you want:

uname -a
 
Old 05-29-2007, 02:37 AM   #4
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by fukawi2
When you say "any" do you mean "any", or "any *nix"?
for example "uname -a" returns os name and versions on any os included freeBSD ?

For example "uname -a" on my system does not return "OS name and version" but only Linux Kernel.
 
Old 05-29-2007, 07:14 AM   #5
UK MAdMaN
Member
 
Registered: Jul 2004
Location: Manchester, England
Distribution: Gentoo
Posts: 211

Rep: Reputation: 30
The manual for uname (type "man uname" on the command line) should help.
 
Old 05-29-2007, 07:30 AM   #6
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by UK MAdMaN
The manual for uname (type "man uname" on the command line) should help.

Thanks , but there is no option on uname which can correctly show OS .
For example on a server with centos 4 , is simply shows "GNU/Linux"
 
Old 05-29-2007, 07:39 AM   #7
UK MAdMaN
Member
 
Registered: Jul 2004
Location: Manchester, England
Distribution: Gentoo
Posts: 211

Rep: Reputation: 30
Quote:
Originally Posted by graziano1968
Thanks , but there is no option on uname which can correctly show OS .
For example on a server with centos 4 , is simply shows "GNU/Linux"
I don't think there's a command that can identify distros. There has to be something unique to a distro for something to identify the distro, and as all distros use mostly the same code/programs there's nothing unique to be identified.
 
Old 05-29-2007, 07:40 AM   #8
Crito
Senior Member
 
Registered: Nov 2003
Location: Knoxville, TN
Distribution: Kubuntu 9.04
Posts: 1,168

Rep: Reputation: 53
cat /proc/version
 
Old 05-31-2007, 01:33 AM   #9
farkus888
Member
 
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Rep: Reputation: 15
Quote:
Originally Posted by Crito
cat /proc/version
doesn't work in solaris 9 so it doesn't qualify for the "all *nixes" requirement. don't have any BSD's available to mess with at this moment.

edit: also obviously won't work in windows which completely lacks /proc which is in *nixes.

Last edited by farkus888; 05-31-2007 at 01:35 AM.
 
Old 05-31-2007, 08:58 AM   #10
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,232
Blog Entries: 5

Rep: Reputation: 189Reputation: 189
Most versions of Linux put a version file in the /etc directory with the version number of the distro..
the downside is they don't all give the file the same name to make it easy..

for example
Code:
it-etch:$ cat /etc/debian_version
4.0
 
Old 05-31-2007, 09:37 AM   #11
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 60
I have rather quickly come to appreciate infobash, but I'm not sure that it works on anything except Debian.

Code:
debian64:~$ infobash -v3
Host/Kernel/OS  "debian64" running Linux 2.6.21-1-amd64 x86_64 [ Debian lenny/sid ]
CPU Info        AMD Athlon 64 3200+ 512 KB cache flags( sse sse2 nx lm ) clocked at [ 1989.862 MHz ]
Videocard       ATI RS480 [Radeon Xpress 200G Series]  X.Org 1.3.0  [ 1280x1024 @75hz ]
Network cards   Realtek RTL-8139/8139C/8139C+, at port: de00 
Processes 93 | Uptime 7:29 | Memory 291.1/436.0MB | HDD MAXTOR 6L080J4,WDC WD800JB-00JJC0 Size 160GB (60%used) | Client Shell | Infobash v2.65
 
Old 05-31-2007, 10:49 AM   #12
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
OP, you never clarified -- "any" or "any *nix"?

Granted we know that you probably mean "any *nix",
but it would be nice to be sure.

I don't think it's easily done -- even the /etc/debian-version
on my SimplyMEPIS boxen (3.3.2 & 6.0) say nothing about MEPIS,
just "testing/unstable" & "testing".

And then:
Code:
$ cat /proc/version
... (root@mepis-msi) ...
which isn't very helpful.
 
Old 05-31-2007, 11:57 AM   #13
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
Several distros maintain a text file containing the info. I asked a question on here a while ago to try and gather a list, you could search for it, contained information on distro information paths.

For example arch has /etc/arch-release however as of the latest release, it doesn't contain anything.

Which is a pig since i had a system information script that would poll various files to state the distro
 
Old 07-31-2007, 04:16 AM   #14
Tomas_IV
LQ Newbie
 
Registered: Nov 2005
Distribution: LinuxMint XFCE (Debian Edition).
Posts: 4

Rep: Reputation: 4
Quote:
Originally Posted by ethics
Several distros maintain a text file containing the info. <snip>

For example arch has /etc/arch-release however as of the latest release, it doesn't contain anything.

<snip>
I found that on Ubuntu I have two similar files:
Quote:
/etc/debian_version
/etc/lsb-release
The former one contains only number 4, which probably means on which version of Debian was current Ubuntu based on. The lsb-release file contains all the information needed.
Similarly, on CentOS I found file /etc/redhat-release.
It seems that
Quote:
cat /etc/*release
or
Quote:
cat /etc/*version
should do on many Linux systems (but of course not on any).
 
2 members found this post helpful.
Old 07-31-2007, 08:50 AM   #15
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
I smell the possibility of a good HowTo here.

Where should we start?
 
  


Reply

Tags
commandline, distribution, version


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 08:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 02:28 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 11:48 AM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 01:24 AM


All times are GMT -5. The time now is 08:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration