If you have ever run into this message when you’re trying to install some package, there are some steps you could follow in order to diagnose the issue properly. First let’s get down to the basics so we are on the same page.
in your system!
-bourne again shell: rpm: command not found
Let me guess: you typed some
rpm command into bourne again shell, and you ran into the following error:
-bourne again shell: rpm: command not found
If you tried using ‘rpm’ in the second most popular shell, zsh, you would see the following error message instead:
zsh: command not found: rpm
To fix this error, you need to configure your system to use the RPM Package Manager (RPM). Read the next section for how to configure your OS to use RPM.
What is RPM?
The RPM Package Manager (RPM) is a free and open-source package management system used by Red Hat Linux and its derivatives such as CentOS and Fedora. RPM also refers to the rpm command and .rpm file format. An RPM Package consists of an archive of files and metadata including information such as dependencies and install location.
The fact that you have seen that error means that you were trying to install, update, remove, verify, query or do some other operation on a package.
In this article, I will do my best to walk you, step by step, towards solving this issue. Let’s start with the first step:
Determine which GNU/Linux distro you are using:
Different GNU/Linux distros might use different package managers. If you are used to Fedora, for example, and you have decided to move to Ubuntu, you need to understand that both use entirely different package managers.
There are a few commands you could use in order to find out which GNU/Linux you have, one of the most common files that contains distro information is /etc/issue. You could view this file with this command :
Using that command, the terminal should print a line containing distro information. If you’re using Debian, for example, the line should look like this:
Debian GNU/Linux 11
Now that you have determined your distro name, you need to identify whether or not this distro is using RPM as its main package manager.
For RPM-based distros:
If your distro is RHEL (RedHat Enterprise Linux), CentOS, Fedora, openSUSE or Mandrake Linux, then you could follow these steps to diagnose the problem. Otherwise, you could skip this section and go to the next one.
Check your privilege:
As you might already know, GNU/Linux is a multi-user operating system. The act of installing, removing or upgrading a package requires administrative privileges. On GNU/Linux, the user with the most administrative privileges is usually the root user. If you don’t know which user you are, you could check with the following command:
If a username other than root is printed, you may need to switch to the root user. You could achieve that with the following command:
You will be prompted to enter a password. You need to enter the root password in order to switch to the root user.
You should now act as the root user. The text right before your terminal cursor should be something like this:
You could now try to use the rpm command again. If the issue still persists, you might not have the rpm command properly installed. In this case, just follow the rest of the steps.
Make sure that rpm command is properly installed.
Sometimes you just mess up your system by deleting an important link or binary. When that happens, don’t panic. GNU/Linux is a really good operating system for debugging and solving critical issues. Just follow basic diagnostic steps to get to the root of the problem.
You need to find where the rpm command binary is. In order to do that, you could run a basic command like this:
Typically, you should have a list of paths to different rpm locations. The binary you are looking for should be either in /usr/bin/rpm or /bin/rpm. This time, try the same command again. Only this time use /bin/rpm (or /usr/bin/rpm) instead of just rpm.
If the command worked, you need to fix your $PATH global variable.
Check your $PATH global variable:
This means that something went wrong with your $PATH global variable. You could check that out by echoing it:
If the output doesn’t include the directory which rpm resides at, it means something went wrong with your config. What this means is that bourne again shell will be unable to trace for that directory, essentially disabling you from running rpm. To fix this issue, you need to add one line of code to the .bashrc file, which should be located in your Home directory.
First, open the .bashrc file using a text editor like nano:
$ nano ~/.bashrc
Inside this file, append the following line:
The /usr/bin directory is where rpm is supposedly installed, so adding it should do the job.
Also, if you’re using some other shell than bourne again shell, than you need to add this line in the configuration file for that specific shell, instead of .bashrc.
For Debian-based distros:
If you’re not using an RPM-based distro, then most likely you are using a Debian-based one. Debian-based distros use a different package manager than RPM-based ones. The packages used by RPM-based distros like CentOS or Fedora will end with .rpm. Debian-based distros like Ubuntu will use .deb packages instead.
It’s usually a good idea to use apt/dpkg instead of rpm, but if you really need to install a .rpm you could follow these steps:
Convert .rpm to .deb:
In order to install .rpm on a Debian-based distro, you need to install a command called alien in order to convert the package to .deb first.
As root, install alien with the following command:
apt-get install alien
Verify alien installation:
To verify the installation, use the following command:
dpkg -l | grep alien
You should see a line that includes information about the alien package.
Convert the package:
Assuming you have a package named package.rpm on your current directory, you could convert it like this:
A package named package.deb should be found in the same directory.
Install the package:
Now all that’s left is to install the package itself. This is as simple as running the following command:
Dpkg -i package.deb
As a beginner user, you usually do not need to use the rpm command that much. Most beginner-friendly distros include a graphical interface that you could use to install the package without using the terminal. However, if you decided to use rpm anyway, the previous steps should have helped you achieve your objective. Hopefully, you have managed to solve your problems by now.