LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 05-29-2007, 01:14 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 172
Thanked: 0
how to get OS name from command line


[Log in to get rid of this advertisement]
Hi

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

Thank you!
graziano1968 is offline     Reply With Quote
Old 05-29-2007, 01:44 AM   #2
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux
Posts: 418
Thanked: 1
When you say "any" do you mean "any", or "any *nix"?
fukawi2 is offline     Reply With Quote
Old 05-29-2007, 01:46 AM   #3
mike33
Member
 
Registered: Jul 2004
Location: Houston Tx
Distribution: kubuntu, Debian, Suse 10.2
Posts: 31
Thanked: 0
The following command is probably what you want:

uname -a
mike33 is offline     Reply With Quote
Old 05-29-2007, 02:37 AM   #4
graziano1968
Member
 
Registered: Sep 2004
Posts: 172
Thanked: 0

Original Poster
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.
graziano1968 is offline     Reply With Quote
Old 05-29-2007, 07:14 AM   #5
UK MAdMaN
Member
 
Registered: Jul 2004
Location: Manchester, England
Distribution: Linux From Scratch
Posts: 211
Thanked: 0
The manual for uname (type "man uname" on the command line) should help.
UK MAdMaN is offline     Reply With Quote
Old 05-29-2007, 07:30 AM   #6
graziano1968
Member
 
Registered: Sep 2004
Posts: 172
Thanked: 0

Original Poster
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"
graziano1968 is offline     Reply With Quote
Old 05-29-2007, 07:39 AM   #7
UK MAdMaN
Member
 
Registered: Jul 2004
Location: Manchester, England
Distribution: Linux From Scratch
Posts: 211
Thanked: 0
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.
UK MAdMaN is offline     Reply With Quote
Old 05-29-2007, 07:40 AM   #8
Crito
Senior Member
 
Registered: Nov 2003
Location: Knoxville, TN
Distribution: Kubuntu 9.04
Posts: 1,170
Thanked: 13
cat /proc/version
Crito is offline     Reply With Quote
Old 05-31-2007, 01:33 AM   #9
farkus888
Member
 
Registered: Oct 2006
Distribution: usually use arch
Posts: 103
Thanked: 0
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..
farkus888 is offline     Reply With Quote
Old 05-31-2007, 08:58 AM   #10
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: Debian Lenny / Squeeze / Sid
Posts: 7,213
Blog Entries: 5
Thanked: 246
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
farslayer is offline     Reply With Quote
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,253
Thanked: 1
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
rickh is offline     Reply With Quote
Old 05-31-2007, 10:49 AM   #12
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 3,599
Blog Entries: 9
Thanked: 45
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.
archtoad6 is offline     Reply With Quote
Old 05-31-2007, 11:57 AM   #13
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,526
Thanked: 0
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
ethics is offline     Reply With Quote
Old 07-31-2007, 04:16 AM   #14
Tomas_IV
LQ Newbie
 
Registered: Nov 2005
Distribution: Ubuntu, Debian
Posts: 3
Thanked: 0
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).
Tomas_IV is offline  
Tag This Post , ,
Reply With Quote
Old 07-31-2007, 08:50 AM   #15
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 3,599
Blog Entries: 9
Thanked: 45
I smell the possibility of a good HowTo here.

Where should we start?
archtoad6 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 Off
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 07:26 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration