How to discover what Linux distribution is in use

前端 未结 12 1526
青春惊慌失措
青春惊慌失措 2020-12-02 20:46

Sometimes I need to access some servers running Linux (or maybe another Unix-like SO), but I don\'t know how to verify which distribution is in use on the server (there are

相关标签:
12条回答
  • 2020-12-02 21:14
    uname -r
    

    should print the kernel version currently running (at least, it does for Linux, don't know if it's the same for *BSD or others). That's not the same as the distro but the kernel version often includes the distro name if it's customised, like "2.6.27-gentoo-r1" or something.

    Init often prints something at boot, but that's not much good when it's running.

    Otherwise as far as I know there isn't anything universal.

    0 讨论(0)
  • 2020-12-02 21:20

    lsb_release -i may work for you.

    More detail is available with lsb_release -a

    Some discussion at http://etbe.coker.com.au/2007/08/30/identifying-the-distribution-of-a-linux-system/

    0 讨论(0)
  • 2020-12-02 21:22

    There are different commands you can use to check which distribution is in use. Here I am mentioning only 5 of them.

    1. lsb_relase -a

    lsb_release provides distribution-specific information. Whereas -a display all information about the distribution. You can also use -d which only shows the description.

    1. uname -a

    uname also provides system information. Whereas -a display all information. You can use man uname for other options.

    1. cat /etc/*release

    You can also use cat command to print out all specific release information from etc folder. This command actually reads the lsb-release and os-release files from the /etc folder.

    1. cat /etc/issue

    This command reads the issue file from the /etc folder.

    1. cat /proc/version

    This command reads the version file from the /proc folder. /proc folder contains information about system process.

    0 讨论(0)
  • 2020-12-02 21:24

    You should ask yourself if you really need to know which distro is in use (perhaps because you want to build a package specific for this distribution). In many other cases it is a far better idea, to just test and see if the features you need are there or not. This might look like a lot more work because you have to test every feature one by one but this way, your software becomes far more flexible.

    0 讨论(0)
  • 2020-12-02 21:25

    I found that the /etc/issue usually has something about the distribution in use.

    But I don't know about its availability on all distributions.

    0 讨论(0)
  • 2020-12-02 21:25

    You can use 'uname':

    [anton@localhost ~]$ uname -a
    Linux localhost 2.6.26-ARCH #1 SMP PREEMPT Tue Aug 26 21:15:43 UTC 2008 i686 AMD Athlon(tm) 64 Processor 3000+ AuthenticAMD GNU/Linux
    
    0 讨论(0)
提交回复
热议问题