1. If you're using linux can you run this command please?

cat /etc/*-release | grep ^NAME 

It should tell you the name of your Linux distribution. I need to know if it is accurate for your distro please. Also it should return only one line NAME=????.

Works on my box! smile

[ronald@localhost ~]$ cat /etc/*-release | grep ^NAME 
NAME=Fedora 

Thanks.

new topic     » topic index » view message » categorize

2. Re: If you're using linux can you run this command please?

grep ^NAME is not adapted to Ubuntu and derivatives:

cat /etc/lsb-release 
DISTRIB_ID=LinuxMint 
DISTRIB_RELEASE=17.2 
DISTRIB_CODENAME=rafaela 
DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela" 

Regards

Jean-Marc

new topic     » goto parent     » topic index » view message » categorize

3. Re: If you're using linux can you run this command please?

I have one PC which is dedicated to virtiualization and runs Proxmox, so I can run many OSes without needing as much resources as full virtualization (Vmware, Virtualbox, etc), but only Lunix ones.

I will download many templates, 32-bit and 64-bit, to check many commands on various distributions.

new topic     » goto parent     » topic index » view message » categorize

4. Re: If you're using linux can you run this command please?

I tried this:

find /etc -maxdepth 1 -type f -name "*-release" -exec grep -H NAME {} \; 
/etc/os-release:NAME="Ubuntu" 
/etc/os-release:PRETTY_NAME="Ubuntu 14.04.2 LTS" 
/etc/lsb-release:DISTRIB_CODENAME=rafaela 

It identifies Linux Mint As Ubuntu, so it is not very precise but maybe ^NAME can nevertheless be enough if completed with arch.

new topic     » goto parent     » topic index » view message » categorize

5. Re: If you're using linux can you run this command please?

To find Linux Mint, you have to look in /etc/lsb-release:

/etc/lsb-release:DISTRIB_ID=LinuxMint 
/etc/lsb-release:DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela" 

There is another option: cat /etc/issue.net

Linux Mint 17.2 Rafaela: Linux Mint 17.2 Rafaela 
Debian 7 Wheezy: Debian GNU/Linux 7 

But it fails on CentOS 7:

\S 
Kernel \r on an \m 

So there seems to be not only one method but a combination of many to identify Linux systems.

new topic     » goto parent     » topic index » view message » categorize

6. Re: If you're using linux can you run this command please?

Here is a command anyone can run on his distribution to help find how to correctly identify linuxes:

echo "/etc/issue.net:"$(cat /etc/issue.net); find /etc -maxdepth 1 -type f -name "*-release" -exec grep -H -E "NAME|DISTRIB" {} \; 

An here is the result on different OSes.

Linux Mint 17.2 Rafaela 
/etc/issue.net:Linux Mint 17.2 Rafaela 
/etc/os-release:NAME="Ubuntu" 
/etc/os-release:PRETTY_NAME="Ubuntu 14.04.2 LTS" 
/etc/lsb-release:DISTRIB_ID=LinuxMint 
/etc/lsb-release:DISTRIB_RELEASE=17.2 
/etc/lsb-release:DISTRIB_CODENAME=rafaela 
/etc/lsb-release:DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela" 
 
Debian 7 Wheezy 
/etc/issue.net:Debian GNU/Linux 7 
/etc/os-release:PRETTY_NAME="Debian GNU/Linux 7 (wheezy)" 
/etc/os-release:NAME="Debian GNU/Linux" 
 
CentOS 7 
/etc/issue.net:\S Kernel \r on an \m 
/etc/os-release:NAME="CentOS Linux" 
/etc/os-release:PRETTY_NAME="CentOS Linux 7 (Core)" 
/etc/os-release:CPE_NAME="cpe:/o:centos:centos:7" 
 
Fedora 22 
/etc/issue.net:Fedora release 22 (Twenty Two) Kernel \r on an \m (\l) 
 
Arch Linux 2014 
cat: /etc/issue.net: No such file or directory 
/etc/issue.net: 
/etc/os-release:NAME="Arch Linux" 
/etc/os-release:PRETTY_NAME="Arch Linux" 
 
Ubuntu 14.04 
/etc/issue.net:Ubuntu 14.04.1 LTS 
/etc/os-release:NAME="Ubuntu" 
/etc/os-release:PRETTY_NAME="Ubuntu 14.04.1 LTS" 
/etc/lsb-release:DISTRIB_ID=Ubuntu 
/etc/lsb-release:DISTRIB_RELEASE=14.04 
/etc/lsb-release:DISTRIB_CODENAME=trusty 
/etc/lsb-release:DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS" 
new topic     » goto parent     » topic index » view message » categorize

7. Re: If you're using linux can you run this command please?

To get it work correctly on Fedora, I had to add an option -L (follow links)

echo "/etc/issue.net:"$(cat /etc/issue.net); find -L /etc -maxdepth 1 -type f -name "*-release" -exec grep -H -E "NAME|DISTRIB" {} \; 

The result is now correct

/etc/issue.net:Fedora release 22 (Twenty Two) Kernel \r on an \m (\l) 
/etc/os-release:NAME=Fedora 
/etc/os-release:PRETTY_NAME="Fedora 22 (Twenty Two)" 
/etc/os-release:CPE_NAME="cpe:/o:fedoraproject:fedora:22" 
new topic     » goto parent     » topic index » view message » categorize

8. Re: If you're using linux can you run this command please?

OWL 3.1

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

NAME filter is not adapted here

root@owl:/ # cat /etc/owl-release  
Owl 3.1-stable 
new topic     » goto parent     » topic index » view message » categorize

9. Re: If you're using linux can you run this command please?

Same problem for Slackware 13.37

/etc/issue.net: 
-bash: find: command not found 
root@slackware:/# cat /etc/slackware-version  
Slackware 13.37.0 

and Suse 13.1

cat: /etc/issue.net: No such file or directory 
/etc/issue.net: 
-bash-4.2# cat /etc/SuSE-brand  
BasedOnopenSUSE 
VERSION = 13.1 
new topic     » goto parent     » topic index » view message » categorize

10. Re: If you're using linux can you run this command please?

Here is how grub recognizes OSes:

duro@duro-HP-Compaq-dc7700-Small-Form-Factor:~/Téléchargements > sudo /usr/lib/os-probes/mounted/40lsb 
[sudo] password for duro:  
:Linux Mint 17.2 Rafaela (17.2):LinuxMint:linux 
duro@duro-HP-Compaq-dc7700-Small-Form-Factor:~/Téléchargements > sudo /usr/lib/os-probes/mounted/90linux-distro 
:Debian GNU/Linux (jessie/sid):Debian:linux 

Basically, they look for DISTRIB_RELEASE, DISTRIB_CODENAME and DISTRIB_DESCRIPTION, then for one specific release file per distibution, which name can end with -release or -version (they specify the exact name per each distribution).

For Slackware they use pkgtool, for Caldera OpenLinux they use /etc/issue. There is no unique solution. A big switch case would better fit all the needs, with one case per distribution.

Regards

Jean-Marc

new topic     » goto parent     » topic index » view message » categorize

11. Re: If you're using linux can you run this command please?

jmduro said...

Basically, they look for DISTRIB_RELEASE, DISTRIB_CODENAME and DISTRIB_DESCRIPTION, then for one specific release file per distibution, which name can end with -release or -version (they specify the exact name per each distribution).

For Slackware they use pkgtool, for Caldera OpenLinux they use /etc/issue. There is no unique solution. A big switch case would better fit all the needs, with one case per distribution.

Awesome! I'll integrate the OS check into the project as soon as I get home. And I've created a github for the project.

new topic     » goto parent     » topic index » view message » categorize

12. Re: If you're using linux can you run this command please?

Can't you just do uname -a?

new topic     » goto parent     » topic index » view message » categorize

13. Re: If you're using linux can you run this command please?

uname -a 
Linux localhost.localdomain 4.1.6-200.fc22.x86_64 #1 SMP Mon Aug 17 19:54:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 

This will give kernel info and some other helpful things but I would still need to parse the info to determine that it's a Fedora box.

At this point I'm thinking of scrapping the OS detection all together in favor of user configuration. Without too much effort I'm sure I can tell the difference between a Debian based distro and a RedHat based one. I might just leave it at that for now as that will cover the majority and serve my needs for the moment.

new topic     » goto parent     » topic index » view message » categorize

14. Re: If you're using linux can you run this command please?

jaygade said...

Can't you just do uname -a?

That usually works if you are running a distro provided kernel (as then the kernel version (uname -v) that is returned likely contains the distro name), however if you build your own kernel then this command won't identify the distro.

It's also possible that some smaller distros might not provide this information in their stock kernels.

new topic     » goto parent     » topic index » view message » categorize

15. Re: If you're using linux can you run this command please?

Linux Mint 17.0

$cat /etc/*-release | grep ^NAME 
cat: /etc/upstream-release: Is a directory 
NAME="Ubuntu" 

new topic     » goto parent     » topic index » view message » categorize

16. Re: If you're using linux can you run this command please?

SDPringle said...

Linux Mint 17.0

$cat /etc/*-release | grep ^NAME 
cat: /etc/upstream-release: Is a directory 
NAME="Ubuntu" 

Protip: you don't have to cat files and pipe them into grep, you can just grep files directly.

$ grep -E "^NAME=" /etc/*-release
/etc/os-release:NAME="Ubuntu"

I'm not sure why more people don't know this, but I see it all the time.

-Greg

new topic     » goto parent     » topic index » view message » categorize

17. Re: If you're using linux can you run this command please?

ghaberek said...
SDPringle said...

Linux Mint 17.0

$cat /etc/*-release | grep ^NAME 
cat: /etc/upstream-release: Is a directory 
NAME="Ubuntu" 

Protip: you don't have to cat files and pipe them into grep, you can just grep files directly.

$ grep -E "^NAME=" /etc/*-release
/etc/os-release:NAME="Ubuntu"

I'm not sure why more people don't know this, but I see it all the time.

-Greg

Don't infer that because people are apparently typing the commands in verbatim that they do not know the other ways it could be done. It is faster and less error prone to copy and paste the challenge command and then paste the results. This is what people ought to do. We shouldn't debate command line style here.

Shawn Pringle

new topic     » goto parent     » topic index » view message » categorize

18. Re: If you're using linux can you run this command please?

SDPringle said...

Don't infer that because people are apparently typing the commands in verbatim that they do not know the other ways it could be done.

The problem here is that using the cat/grep combo does not let grep know anything about the files it's searching. So when you cat a wildcard and pass that to grep, the grep process cannot possibly tell you in which file it found the content you were looking for. Do you see the problem there? How do we know which file that matched the pattern /etc/*-release was the one that contained the search string? It seems unlikely that the mere presence of the information on the system would be helpful to the OP, and that it would be more relevant to know which file contained said information. Otherwise we may have a false positive and send him on a wild goose chase. "Yes, my system contains that information, but it turns out that what you were looking for was in another file."

SDPringle said...

It is faster and less error prone to copy and paste the challenge command and then paste the results. This is what people ought to do.

No. It most definitely is not. Following directions blindly is unwise and could very well lead to errors in the process or worse, people screwing up their systems because they were asked to enter a command that they (or maybe even the requester) did not properly understand. If the question being asked is flawed, then we should all do better to ensure we are solving the problem instead of answering the question.

-Greg

new topic     » goto parent     » topic index » view message » categorize

19. Re: If you're using linux can you run this command please?

I was actually trying to concat any file that matched the pattern *-release looking for NAME=. The hope was that no matter what the distro named the file, the NAME= pattern would find the name of distro. I found something using Google that put me on the path of this oneliner. Sadly, it turned out to be false for several reasons. First Mint actually supplements distro with their own release file. So, NAME= still means Ubuntu. That doesn't adversely affect the reason I wanted to know what distro but, it opened my eyes to other problems. As Jean-Marc pointed out in his responses, the simple one liner becomes a lot more complicated with the addition of Linux distros. Coupled with the fact that there may be multiple *-release files, there is also the possibility of *-release directories. At the moment, I'm not interested in those directories or content.

In any case, too me it seemed clearer to use cat | grep for what I wanted at the time. What I wanted to express with cat /etc/*-release | grep ^NAME was the following English expression.

"Somewhere in the /etc directory there should be a file that looks like *-release. Find the single line in whatever that file is that begins with NAME=. It holds the single value I'm interested in at the moment."

Unfortunately, this plan didn't work. So I revised my plan. I appreciate all of you and the time you took to answer my question.

new topic     » goto parent     » topic index » view message » categorize

20. Re: If you're using linux can you run this command please?

xecronix said...

Unfortunately, this plan didn't work. So I revised my plan. I appreciate all of you and the time you took to answer my question.

I'm currently writing a program in Euphoria that does the job. It is just a question of time. I hope to get it ready by the end of the week.

It won't run anything, just give the real distribution name. It could then be correlated with a table showing installers for each distibution by the means of vlookup instruction.

Regards

Jean-Marc

new topic     » goto parent     » topic index » view message » categorize

21. Re: If you're using linux can you run this command please?

Try this:

include std/filesys.e 
include std/text.e 
include std/sequence.e 
include std/io.e 
include std/search.e 
include myLibs/myDebug.e 
 
------------------------------------------------------------------------------ 
 
function readFile(sequence filename) 
  sequence s = read_lines(filename) 
  sequence content = {} 
  for i = 1 to length(s) do 
    sequence line = trim(s[i]) 
    if length(line)>0 then 
      sequence t = split(line, '=') 
      for j = 1 to length(t) do t[j] = dequote(trim(t[j])) end for 
      content = append(content, t ) 
    end if 
  end for 
  return content 
end function 
 
------------------------------------------------------------------------------ 
 
function cat(sequence filename) 
  sequence s = read_file(filename) 
  return trim(s) 
end function 
 
------------------------------------------------------------------------------ 
 
sequence s, short, long, release, description, name, version 
object o 
 
  long = "" 
  short = "" 
  if file_exists("/etc/lsb-release") then 
    s = readFile("/etc/lsb-release") 
    o = vlookup("DISTRIB_RELEASE", s, 1, 2) 
    if atom(o) then 
      release = vlookup("DISTRIB_CODENAME", s, 1, 2) 
    else 
      release = o 
    end if 
    o = vlookup("DISTRIB_DESCRIPTION", s, 1, 2) 
    if atom(o) then 
      description = vlookup("DISTRIB_CODENAME", s, 1, 2) 
    else 
      description = o 
    end if 
    if length(description) then 
      if length(release) then 
        long = description & " (" & release & ")" 
      else 
        long = description 
      end if 
    end if 
    o = vlookup("DISTRIB_ID", s, 1, 2) 
    if atom(o) then 
      short = "UnknownLSB" 
    else 
      short = match_replace(" ", o, "") 
    end if 
  else 
    if file_exists("/etc/debian_version") then 
      short = "Debian" 
      s = readFile("/etc/os-release") 
      name = vlookup("NAME", s, 1, 2) 
      version = vlookup("VERSION", s, 1, 2) 
      long = name & " " & version 
    -- RPM derived distributions may also have a redhat-release or 
    -- mandrake-release, so check their files first. 
    elsif file_exists("/etc/altlinux-release") then 
      short = "ALTLinux" 
      long = cat("/etc/altlinux-release") 
    elsif file_exists("/etc/magic-release") then 
      short = "Magic" 
      long = cat("/etc/magic-release") 
    elsif file_exists("/etc/blackPanther-release") then 
      short = "blackPanther" 
      long = cat("/etc/blackPanther-release") 
    elsif file_exists("/etc/ark-release") then 
      short = "Ark" 
      long = cat("/etc/ark-release") 
    elsif file_exists("/etc/arch-release") then 
      short = "Arch" 
      long = cat("/etc/arch-release") 
    elsif file_exists("/etc/asplinux-release") then 
      short = "ASPLinux" 
      long = cat("/etc/asplinux-release") 
    elsif file_exists("/etc/lvr-release") then 
      short = "LvR" 
      long = cat("/etc/lvr-release") 
    elsif file_exists("/etc/caos-release") then 
      short = "cAos" 
      long = cat("/etc/caos-release") 
    elsif file_exists("/etc/aurox-release") then 
      short = "Aurox" 
      long = cat("/etc/aurox-release") 
    elsif file_exists("/etc/engarde-release") then 
      short = "EnGarde" 
      long = cat("/etc/engarde-release") 
    elsif file_exists("/etc/vine-release") then 
      short = "Vine" 
      long = cat("/etc/vine-release") 
    elsif file_exists("/etc/whitebox-release") then 
      short = "WhiteBox" 
      long = cat("/etc/whitebox-release") 
    elsif file_exists("/etc/pld-release") then 
      short = "PLD" 
      long = cat("/etc/pld-release") 
    elsif file_exists("/etc/startcom-release") then 
      short = "StartCom" 
      long = cat("/etc/startcom-release") 
    elsif file_exists("/etc/trustix-release") then 
      short = "Trustix" 
      long = cat("/etc/trustix-release") 
    elsif file_exists("/etc/openna-release") then 
      short = "OpenNA" 
      long = cat("/etc/openna-release") 
    elsif file_exists("/etc/conectiva-release") then 
      short = "Conectiva" 
      long = cat("/etc/conectiva-release") 
    elsif file_exists("/etc/mandrake-release") then 
      short = "Mandrake" 
      long = cat("/etc/mandrake-release") 
    elsif file_exists("/etc/fedora-release") then 
      short = "Fedora" 
      long = cat("/etc/fedora-release") 
    elsif file_exists("/etc/redhat-release") then 
      short = "RedHat" 
      long = cat("/etc/redhat-release") 
    elsif file_exists("/etc/SuSE-release") then 
      short = "SuSE" 
      if file_exists("/etc/SuSE-release") then 
        long = cat("/etc/SuSE-release") 
      else 
        long = cat("/etc/SuSE-brand") 
      end if 
    elsif file_exists("/etc/gentoo-release") then 
      short = "Gentoo" 
      long = cat("/etc/gentoo-release") 
    elsif file_exists("/etc/cobalt-release") then 
      short = "Cobalt" 
      long = cat("/etc/cobalt-release") 
    elsif file_exists("/etc/yellowdog-release") then 
      short = "YellowDog" 
      long = cat("/etc/yellowdog-release") 
    elsif file_exists("/etc/turbolinux-release") then 
      short = "Turbolinux" 
      long = cat("/etc/turbolinux-release") 
    elsif file_exists("/etc/pardus-release") then 
      short = "Pardus" 
      long = cat("/etc/pardus-release") 
    elsif file_exists("/etc/kanotix-version") then 
      short = "Kanotix" 
      long = cat("/etc/kanotix-version") 
    elsif file_exists("/etc/slackware-version") then 
      short = "Slackware" 
      long = cat("/etc/slackware-version") 
    elsif file_exists("/sbin/pkgtool") then 
      short = "Slackware" 
      long="Slackware Linux" 
    elsif match("OpenLinux", "/etc/issue") then 
      short = "Caldera" 
      long="Caldera OpenLinux" 
    elsif file_exists("/etc/frugalware-release") then 
      short = "Frugalware Linux" 
      long = cat("/etc/frugalware-release") 
    elsif file_exists("/etc/kdemar-release") then 
      short = "K-DEMar" 
      long = cat("/etc/kdemar-release") 
    elsif file_exists("/etc/lfs-release") then  --Linux From Scratch 
      short = "LFS" 
      long = cat("/etc/lfs-release") 
    elsif file_exists("/etc/meego-release") then 
      short = "MeeGo" 
      long = cat("/etc/meego-release") 
    else 
      short = "Linux" 
      long = "unknown Linux distribution" 
    end if 
  end if 
 
puts(1, "Short name = " & short & "\n") 
puts(1, "Long name = " & long & "\n") 

It has not been tested on all those distributions, so if people could try it and share results, it would be fine.

Here is for Linux Mint 17.2 Rafaela:

Short name = LinuxMint 
Long name = Linux Mint 17.2 Rafaela (17.2) 

and for Fedora 22

Short name = Fedora 
Long name = Fedora release 22 (Twenty Two) 
new topic     » goto parent     » topic index » view message » categorize

22. Re: If you're using linux can you run this command please?

Let's continue with Ubuntu 14.04

Short name = Ubuntu 
Long name = Ubuntu 14.04.1 LTS (14.04) 
new topic     » goto parent     » topic index » view message » categorize

23. Re: If you're using linux can you run this command please?

I'll have a go on my Puppy, Centos 5.7 and 5.11 32 bits later today, when I boot them.
Funny quotes about Unix (Linix)... Loves standards, thats why there are so many of them
And contrary to popular belief, Unix is friendly - it just chooses who to be friendly with! :)

new topic     » goto parent     » topic index » view message » categorize

24. Re: If you're using linux can you run this command please?

jmduro said...

It has not been tested on all those distributions, so if people could try it and share results, it would be fine.

Here is for Linux Mint 17.2 Rafaela:

Short name = LinuxMint 
Long name = Linux Mint 17.2 Rafaela (17.2) 

and for Fedora 22

Short name = Fedora 
Long name = Fedora release 22 (Twenty Two) 

Very nice work! I can use this is the EuAnyRepo project to determine reasonable defaults.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu