How can I get system information from the command line?












2















Sometimes when I log on to a system via SSH (for example to the production server), I have such privileges that there can install some software, but to do that I need to know the system with which I am dealing.



I would be able to check how the system is installed there.



Is there a way from the CLI to determine what distribution of Unix/Linux is running?










share|improve this question



























    2















    Sometimes when I log on to a system via SSH (for example to the production server), I have such privileges that there can install some software, but to do that I need to know the system with which I am dealing.



    I would be able to check how the system is installed there.



    Is there a way from the CLI to determine what distribution of Unix/Linux is running?










    share|improve this question

























      2












      2








      2


      0






      Sometimes when I log on to a system via SSH (for example to the production server), I have such privileges that there can install some software, but to do that I need to know the system with which I am dealing.



      I would be able to check how the system is installed there.



      Is there a way from the CLI to determine what distribution of Unix/Linux is running?










      share|improve this question














      Sometimes when I log on to a system via SSH (for example to the production server), I have such privileges that there can install some software, but to do that I need to know the system with which I am dealing.



      I would be able to check how the system is installed there.



      Is there a way from the CLI to determine what distribution of Unix/Linux is running?







      ssh command-line distributions






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 16 '16 at 7:35









      simhumilecosimhumileco

      1529




      1529






















          6 Answers
          6






          active

          oldest

          votes


















          5














          Try:



          uname -a


          It will give you output such as:



          Linux debianhost 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux


          You can also use:



          cat /etc/*release*
          PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
          NAME="Debian GNU/Linux"
          VERSION_ID="8"
          VERSION="8 (jessie)"
          ID=debian
          HOME_URL="http://www.debian.org/"
          SUPPORT_URL="http://www.debian.org/support"
          BUG_REPORT_URL="https://bugs.debian.org/"





          share|improve this answer
























          • In my case uname -a works, but cat /etc/*relase* it's not.

            – simhumileco
            Dec 16 '16 at 7:50











          • Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

            – maulinglawns
            Dec 16 '16 at 7:54











          • But it's good that you have entered it, because certainly in many cases it may be helpful...

            – simhumileco
            Dec 16 '16 at 7:56



















          2














          To get the hostname, kernel version, and other useful information about the system:



          uname -a


          To get the version of the Linux distribution, there is not an unique command. Every distro implements it differently. On Debian and Ubuntu:



          cat /etc/debian_version


          On Red Hat:



          cat /etc/redhat-release 
          cat /etc/lsb-release
          lsb_release -a


          On Fedora:



          cat /etc/fedora-release





          share|improve this answer



















          • 1





            Systems using systemd should also have an /etc/os-release file.

            – James Sneeringer
            Dec 16 '16 at 17:59





















          1














          For Linux you can try lsb_release command which provides Linux Standard Base and distro specific information. Try:



          lsb_release -d


          Also check for other options in man page






          share|improve this answer































            1














            This has been answered a couple of times over on SuperUser with the usual tricks already mentioned here. But this answer has a novel method I quite like:



            python -c "import platform; print platform.dist()"


            Note this only works if Python 2.3 or later is available and is no longer available in Python 3.8.






            share|improve this answer





















            • 1





              Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

              – simhumileco
              Jan 8 at 7:27



















            0














            In a concise way you can do it like this (thanks to @daemontosh answer):



            lsb_release -a


            ...show all the information.



            Another concise way to get information is (thanks to @HeathRaftery and @JourneymanGeek answers):



            cat /proc/version


            but there are many Unixes that don't support the /proc pseudo-filesystem.






            share|improve this answer

































              0














              Indeed this problem can also be solved using Python and the platform module (thanks to @HeathRaftery):



              Using platform() function:



              python -c 'import platform; print platform.platform()'
              # Linux-4.9.0-8-amd64-x86_64-with-debian-9.6



              Returns a single string identifying the underlying platform with as much useful information as possible.




              Or using uname() function:



              python -c 'import platform; print platform.uname()'
              # ('Linux', 'debian', '4.9.0-8-amd64', '#1 SMP Debian 4.9.130-2 (2018-10-27)', 'x86_64', '')



              Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.







              share|improve this answer

























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "106"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f330785%2fhow-can-i-get-system-information-from-the-command-line%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                6 Answers
                6






                active

                oldest

                votes








                6 Answers
                6






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                5














                Try:



                uname -a


                It will give you output such as:



                Linux debianhost 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux


                You can also use:



                cat /etc/*release*
                PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
                NAME="Debian GNU/Linux"
                VERSION_ID="8"
                VERSION="8 (jessie)"
                ID=debian
                HOME_URL="http://www.debian.org/"
                SUPPORT_URL="http://www.debian.org/support"
                BUG_REPORT_URL="https://bugs.debian.org/"





                share|improve this answer
























                • In my case uname -a works, but cat /etc/*relase* it's not.

                  – simhumileco
                  Dec 16 '16 at 7:50











                • Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                  – maulinglawns
                  Dec 16 '16 at 7:54











                • But it's good that you have entered it, because certainly in many cases it may be helpful...

                  – simhumileco
                  Dec 16 '16 at 7:56
















                5














                Try:



                uname -a


                It will give you output such as:



                Linux debianhost 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux


                You can also use:



                cat /etc/*release*
                PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
                NAME="Debian GNU/Linux"
                VERSION_ID="8"
                VERSION="8 (jessie)"
                ID=debian
                HOME_URL="http://www.debian.org/"
                SUPPORT_URL="http://www.debian.org/support"
                BUG_REPORT_URL="https://bugs.debian.org/"





                share|improve this answer
























                • In my case uname -a works, but cat /etc/*relase* it's not.

                  – simhumileco
                  Dec 16 '16 at 7:50











                • Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                  – maulinglawns
                  Dec 16 '16 at 7:54











                • But it's good that you have entered it, because certainly in many cases it may be helpful...

                  – simhumileco
                  Dec 16 '16 at 7:56














                5












                5








                5







                Try:



                uname -a


                It will give you output such as:



                Linux debianhost 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux


                You can also use:



                cat /etc/*release*
                PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
                NAME="Debian GNU/Linux"
                VERSION_ID="8"
                VERSION="8 (jessie)"
                ID=debian
                HOME_URL="http://www.debian.org/"
                SUPPORT_URL="http://www.debian.org/support"
                BUG_REPORT_URL="https://bugs.debian.org/"





                share|improve this answer













                Try:



                uname -a


                It will give you output such as:



                Linux debianhost 3.16.0-4-686-pae #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) i686 GNU/Linux


                You can also use:



                cat /etc/*release*
                PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
                NAME="Debian GNU/Linux"
                VERSION_ID="8"
                VERSION="8 (jessie)"
                ID=debian
                HOME_URL="http://www.debian.org/"
                SUPPORT_URL="http://www.debian.org/support"
                BUG_REPORT_URL="https://bugs.debian.org/"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 16 '16 at 7:39









                maulinglawnsmaulinglawns

                6,23121225




                6,23121225













                • In my case uname -a works, but cat /etc/*relase* it's not.

                  – simhumileco
                  Dec 16 '16 at 7:50











                • Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                  – maulinglawns
                  Dec 16 '16 at 7:54











                • But it's good that you have entered it, because certainly in many cases it may be helpful...

                  – simhumileco
                  Dec 16 '16 at 7:56



















                • In my case uname -a works, but cat /etc/*relase* it's not.

                  – simhumileco
                  Dec 16 '16 at 7:50











                • Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                  – maulinglawns
                  Dec 16 '16 at 7:54











                • But it's good that you have entered it, because certainly in many cases it may be helpful...

                  – simhumileco
                  Dec 16 '16 at 7:56

















                In my case uname -a works, but cat /etc/*relase* it's not.

                – simhumileco
                Dec 16 '16 at 7:50





                In my case uname -a works, but cat /etc/*relase* it's not.

                – simhumileco
                Dec 16 '16 at 7:50













                Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                – maulinglawns
                Dec 16 '16 at 7:54





                Ok. My bad, I thought that command would work across all distributions, I was apparently wrong!

                – maulinglawns
                Dec 16 '16 at 7:54













                But it's good that you have entered it, because certainly in many cases it may be helpful...

                – simhumileco
                Dec 16 '16 at 7:56





                But it's good that you have entered it, because certainly in many cases it may be helpful...

                – simhumileco
                Dec 16 '16 at 7:56













                2














                To get the hostname, kernel version, and other useful information about the system:



                uname -a


                To get the version of the Linux distribution, there is not an unique command. Every distro implements it differently. On Debian and Ubuntu:



                cat /etc/debian_version


                On Red Hat:



                cat /etc/redhat-release 
                cat /etc/lsb-release
                lsb_release -a


                On Fedora:



                cat /etc/fedora-release





                share|improve this answer



















                • 1





                  Systems using systemd should also have an /etc/os-release file.

                  – James Sneeringer
                  Dec 16 '16 at 17:59


















                2














                To get the hostname, kernel version, and other useful information about the system:



                uname -a


                To get the version of the Linux distribution, there is not an unique command. Every distro implements it differently. On Debian and Ubuntu:



                cat /etc/debian_version


                On Red Hat:



                cat /etc/redhat-release 
                cat /etc/lsb-release
                lsb_release -a


                On Fedora:



                cat /etc/fedora-release





                share|improve this answer



















                • 1





                  Systems using systemd should also have an /etc/os-release file.

                  – James Sneeringer
                  Dec 16 '16 at 17:59
















                2












                2








                2







                To get the hostname, kernel version, and other useful information about the system:



                uname -a


                To get the version of the Linux distribution, there is not an unique command. Every distro implements it differently. On Debian and Ubuntu:



                cat /etc/debian_version


                On Red Hat:



                cat /etc/redhat-release 
                cat /etc/lsb-release
                lsb_release -a


                On Fedora:



                cat /etc/fedora-release





                share|improve this answer













                To get the hostname, kernel version, and other useful information about the system:



                uname -a


                To get the version of the Linux distribution, there is not an unique command. Every distro implements it differently. On Debian and Ubuntu:



                cat /etc/debian_version


                On Red Hat:



                cat /etc/redhat-release 
                cat /etc/lsb-release
                lsb_release -a


                On Fedora:



                cat /etc/fedora-release






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 16 '16 at 12:33









                dr01dr01

                16k114971




                16k114971








                • 1





                  Systems using systemd should also have an /etc/os-release file.

                  – James Sneeringer
                  Dec 16 '16 at 17:59
















                • 1





                  Systems using systemd should also have an /etc/os-release file.

                  – James Sneeringer
                  Dec 16 '16 at 17:59










                1




                1





                Systems using systemd should also have an /etc/os-release file.

                – James Sneeringer
                Dec 16 '16 at 17:59







                Systems using systemd should also have an /etc/os-release file.

                – James Sneeringer
                Dec 16 '16 at 17:59













                1














                For Linux you can try lsb_release command which provides Linux Standard Base and distro specific information. Try:



                lsb_release -d


                Also check for other options in man page






                share|improve this answer




























                  1














                  For Linux you can try lsb_release command which provides Linux Standard Base and distro specific information. Try:



                  lsb_release -d


                  Also check for other options in man page






                  share|improve this answer


























                    1












                    1








                    1







                    For Linux you can try lsb_release command which provides Linux Standard Base and distro specific information. Try:



                    lsb_release -d


                    Also check for other options in man page






                    share|improve this answer













                    For Linux you can try lsb_release command which provides Linux Standard Base and distro specific information. Try:



                    lsb_release -d


                    Also check for other options in man page







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 16 '16 at 13:42









                    daemontoshdaemontosh

                    3917




                    3917























                        1














                        This has been answered a couple of times over on SuperUser with the usual tricks already mentioned here. But this answer has a novel method I quite like:



                        python -c "import platform; print platform.dist()"


                        Note this only works if Python 2.3 or later is available and is no longer available in Python 3.8.






                        share|improve this answer





















                        • 1





                          Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                          – simhumileco
                          Jan 8 at 7:27
















                        1














                        This has been answered a couple of times over on SuperUser with the usual tricks already mentioned here. But this answer has a novel method I quite like:



                        python -c "import platform; print platform.dist()"


                        Note this only works if Python 2.3 or later is available and is no longer available in Python 3.8.






                        share|improve this answer





















                        • 1





                          Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                          – simhumileco
                          Jan 8 at 7:27














                        1












                        1








                        1







                        This has been answered a couple of times over on SuperUser with the usual tricks already mentioned here. But this answer has a novel method I quite like:



                        python -c "import platform; print platform.dist()"


                        Note this only works if Python 2.3 or later is available and is no longer available in Python 3.8.






                        share|improve this answer















                        This has been answered a couple of times over on SuperUser with the usual tricks already mentioned here. But this answer has a novel method I quite like:



                        python -c "import platform; print platform.dist()"


                        Note this only works if Python 2.3 or later is available and is no longer available in Python 3.8.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 9 at 10:24

























                        answered Jan 7 at 16:51









                        Heath RafteryHeath Raftery

                        26018




                        26018








                        • 1





                          Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                          – simhumileco
                          Jan 8 at 7:27














                        • 1





                          Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                          – simhumileco
                          Jan 8 at 7:27








                        1




                        1





                        Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                        – simhumileco
                        Jan 8 at 7:27





                        Thank you for this great answer, but notice that it is deprecated since Python 3.5 and will be removed in Python 3.8.

                        – simhumileco
                        Jan 8 at 7:27











                        0














                        In a concise way you can do it like this (thanks to @daemontosh answer):



                        lsb_release -a


                        ...show all the information.



                        Another concise way to get information is (thanks to @HeathRaftery and @JourneymanGeek answers):



                        cat /proc/version


                        but there are many Unixes that don't support the /proc pseudo-filesystem.






                        share|improve this answer






























                          0














                          In a concise way you can do it like this (thanks to @daemontosh answer):



                          lsb_release -a


                          ...show all the information.



                          Another concise way to get information is (thanks to @HeathRaftery and @JourneymanGeek answers):



                          cat /proc/version


                          but there are many Unixes that don't support the /proc pseudo-filesystem.






                          share|improve this answer




























                            0












                            0








                            0







                            In a concise way you can do it like this (thanks to @daemontosh answer):



                            lsb_release -a


                            ...show all the information.



                            Another concise way to get information is (thanks to @HeathRaftery and @JourneymanGeek answers):



                            cat /proc/version


                            but there are many Unixes that don't support the /proc pseudo-filesystem.






                            share|improve this answer















                            In a concise way you can do it like this (thanks to @daemontosh answer):



                            lsb_release -a


                            ...show all the information.



                            Another concise way to get information is (thanks to @HeathRaftery and @JourneymanGeek answers):



                            cat /proc/version


                            but there are many Unixes that don't support the /proc pseudo-filesystem.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 8 at 6:25

























                            answered Jul 26 '17 at 12:13









                            simhumilecosimhumileco

                            1529




                            1529























                                0














                                Indeed this problem can also be solved using Python and the platform module (thanks to @HeathRaftery):



                                Using platform() function:



                                python -c 'import platform; print platform.platform()'
                                # Linux-4.9.0-8-amd64-x86_64-with-debian-9.6



                                Returns a single string identifying the underlying platform with as much useful information as possible.




                                Or using uname() function:



                                python -c 'import platform; print platform.uname()'
                                # ('Linux', 'debian', '4.9.0-8-amd64', '#1 SMP Debian 4.9.130-2 (2018-10-27)', 'x86_64', '')



                                Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.







                                share|improve this answer






























                                  0














                                  Indeed this problem can also be solved using Python and the platform module (thanks to @HeathRaftery):



                                  Using platform() function:



                                  python -c 'import platform; print platform.platform()'
                                  # Linux-4.9.0-8-amd64-x86_64-with-debian-9.6



                                  Returns a single string identifying the underlying platform with as much useful information as possible.




                                  Or using uname() function:



                                  python -c 'import platform; print platform.uname()'
                                  # ('Linux', 'debian', '4.9.0-8-amd64', '#1 SMP Debian 4.9.130-2 (2018-10-27)', 'x86_64', '')



                                  Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.







                                  share|improve this answer




























                                    0












                                    0








                                    0







                                    Indeed this problem can also be solved using Python and the platform module (thanks to @HeathRaftery):



                                    Using platform() function:



                                    python -c 'import platform; print platform.platform()'
                                    # Linux-4.9.0-8-amd64-x86_64-with-debian-9.6



                                    Returns a single string identifying the underlying platform with as much useful information as possible.




                                    Or using uname() function:



                                    python -c 'import platform; print platform.uname()'
                                    # ('Linux', 'debian', '4.9.0-8-amd64', '#1 SMP Debian 4.9.130-2 (2018-10-27)', 'x86_64', '')



                                    Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.







                                    share|improve this answer















                                    Indeed this problem can also be solved using Python and the platform module (thanks to @HeathRaftery):



                                    Using platform() function:



                                    python -c 'import platform; print platform.platform()'
                                    # Linux-4.9.0-8-amd64-x86_64-with-debian-9.6



                                    Returns a single string identifying the underlying platform with as much useful information as possible.




                                    Or using uname() function:



                                    python -c 'import platform; print platform.uname()'
                                    # ('Linux', 'debian', '4.9.0-8-amd64', '#1 SMP Debian 4.9.130-2 (2018-10-27)', 'x86_64', '')



                                    Fairly portable uname interface. Returns a namedtuple() containing six attributes: system, node, release, version, machine, and processor.








                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Jan 8 at 7:43

























                                    answered Jan 8 at 7:35









                                    simhumilecosimhumileco

                                    1529




                                    1529






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f330785%2fhow-can-i-get-system-information-from-the-command-line%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Morgemoulin

                                        Scott Moir

                                        Souastre