Need to get Linux Dist name from different Dists - linux

want to code a script that is for multiple linux distributions.
Also want to add commands that check, and if not exist install some packages.. So, need a solution to ckeck Dist name (like Debian or RedHat) to execute the right command for this Dist.
I have tryed "lsb_release" but is this working all the follow dists? : Debian / Ubuntu | Red Hat / Fedora / Suse / Cent OS" If yes, any idea where i can get the lsb_release output from all the Dists above?
in Debian I get this from lsb_release -a 2>/dev/null | grep Distributor:
Distributor ID: Debian
at Rasberry, I get this:
Distributor ID: Raspbian
but what about other Distributions?

Yes, the lsb_release should print the distribution information after installing the required package.
e,g:
On debian based distro:
apt-get install lsb-release
On RHEL based distro:
yum install redhat-lsb-core
or
yum install redhat-lsb
Alernative method : You can get the distribution information through:
On debian based disto
cat /proc/version
cat /etc/issue
cat /etc/issue.net
cat /etc/lsb-release
cat /etc/os-release
On RHEL based distro :
cat /proc/version
cat /etc/centos-release
cat /etc/lsb-release
cat /etc/redhat-release
cat /etc/system-release

seems that all modern linux distributions have /etc/os-release file with ID=distribution (unfortunately have no Raspberry around to test).

Related

mono: command not found

I followed these instructions (for ubuntu 20.04) ending in sudo apt install mono-complete. Everything looks fine during download/install, but afterwards my console looks roughly like this:
$ mono
command not found: mono
$ which mono
mono not found
find / -name mono finds some directories, but no executables.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Pop
Description: Pop!_OS 21.04
Release: 21.04
Codename: hirsute
I've been searching SO and google for an hour now with no luck. Where's my mono???

How to list the 3rd party softwares installed in Centos

Is there a way to list the 3rd party softwares installed in Centos?
I have tried using rpm -qa
but it contains the native packages also.
I am looking for something similar like Installed section in "Software Center in GUI mode" in CLI mode.
I do not have CentOS install. So I will show it how I will do that on my Fedora:
$ rpm -qi rpm |grep Vendor
Vendor : Fedora Project
This will get me who is vendor of rpm package. You may have there something like CentOS. Get that string. And then:
$ rpm -qa --qf '%{name} %{vendor}\n' | grep -v 'Fedora Project'
This will print all installed packages which are not from vendor "Fedora Project".

how can I install Percona Server on Red Hat Community version i.e. on Fedora?

Currently I am working on Fedora 21. I want to install Percona server but it seems it does not support for community version. Is there any workaround for this??
You'll be fine to download the RPMs from Percona.com
https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.11-4/binary/redhat/6/x86_64/Percona-Server-5.7.11-4-r5c940e1-el6-x86_64-bundle.tar
Untar the archive and perform the install using YUM so that Fedora can satisfy any dependencies;
bash-4.3# cat /etc/issue
Fedora release 21 (Twenty One)
Kernel \r on an \m (\l)
bash-4.3# yum install -y Percona-Server-server-57-5.7.11-4.1.el6.x86_64.rpm Percona-Server-client-57-5.7.11-4.1.el6.x86_64.rpm Percona-Server-shared-57-5.7.11-4.1.el6.x86_64.rpm
bash-4.3# rpm -qa | grep -i percona
Percona-Server-shared-57-5.7.11-4.1.el6.x86_64
Percona-Server-client-57-5.7.11-4.1.el6.x86_64
Percona-Server-server-57-5.7.11-4.1.el6.x86_64

Installing files in Ubuntu

I need to download the NVIDIA CUDA tool kit. I am running on Ubuntu server, I don't know which one to download. I checked the ubuntu version, below is the output.
root#ubuserver3:/home/admin# uname -m && cat /etc/*release
i686
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"
NAME="Ubuntu"
VERSION="12.04.4 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.4 LTS)"
VERSION_ID="12.04"
The download link is this - https://developer.nvidia.com/cuda-downloads
Which one should I download? There are 2 files .run and .deb under 32 bit of Ubuntu 12.04. I have no idea.
They are both work, but there is a little difference.
For the deb package, you can use
$ sudo dpkg -i cuda_deb_file.deb
the .run package, just
$ chmod +x cuda_run_file.run
$ ./cuda_run_file.run
The first one install the file to /usr/bin/ /usr/include/ /usr/lib/, but
the second one need you specify the path before installation.

How do I know which Linux package to install for my Linux AMI

Ubuntu/Debian
Red Hat/Fedora/CentOS
Mac OS X
openSUSE
FreeBSD
OpenBSD
Gentoo
I have an application which has been natively packed on the above platforms, how do I know which one to install on my Linux AMI on EC2.
uname -a displays the following
Linux ip-10-315-48-29 3.7.31.31-83.9.amzn1.i686 #1 SMP Sat Feb 18 20:11:16
UTC 2011 i686 i686 i386 GNU/Linux
It's obviously some kind of Linux, so look for a file in /etc that ends in -release or _version:
ls /etc/*-release /etc/*_version
That should help you determine which Linux distribution you have. lsb-release is usually Ubuntu, while fedora-release, redhat-release indicate Fedora, RedHat, or CentOS. You can find a more complete listing here.
Alternatively, you can see if rpm or dpkg are installed by trying to run those commands:
rpm --version
dpkg --version
If dpkg is installed, it's probably Ubuntu/Debian based. If rpm is installed, it's probably RedHat/CentOS or openSUSE based.

Resources