LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to get OS name from command line (https://www.linuxquestions.org/questions/linux-general-1/how-to-get-os-name-from-command-line-557339/)

graziano1968 05-29-2007 12:14 AM

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!

fukawi2 05-29-2007 12:44 AM

When you say "any" do you mean "any", or "any *nix"?

mike33 05-29-2007 12:46 AM

The following command is probably what you want:

uname -a

graziano1968 05-29-2007 01:37 AM

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.

UK MAdMaN 05-29-2007 06:14 AM

The manual for uname (type "man uname" on the command line) should help.

graziano1968 05-29-2007 06:30 AM

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"

UK MAdMaN 05-29-2007 06:39 AM

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.

Crito 05-29-2007 06:40 AM

cat /proc/version

farkus888 05-31-2007 12:33 AM

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.

farslayer 05-31-2007 07:58 AM

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


rickh 05-31-2007 08:37 AM

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


archtoad6 05-31-2007 09:49 AM

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.

ethics 05-31-2007 10:57 AM

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

Tomas_IV 07-31-2007 03:16 AM

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

archtoad6 07-31-2007 07:50 AM

I smell the possibility of a good HowTo here.

Where should we start?


All times are GMT -5. The time now is 08:41 AM.