When starting with Linux systems, you might have encountered a tutorial or manual telling you to use the
su command to switch to a given user.
However, depending on the target system, you might encounter an error when invoking the
What is the
su command, or substitute user or switch user a command-line utility available in Unix-like operating systems. The
su command allows us to change the current user context to another during a login session.
In simple terms, the
su command allows us to log in as another use in the current system without logging out of the current session. This is especially useful when you need to perform specific tasks as another user quickly and then go back to your regular session.
What causes the
su: command not found Error?
If you run the
su command and get the
command not found error, the shell cannot find the
su binary in the
The biggest cause of this issue is you do not have the
su binary installed on your system. It might also mean that you need to reload your shell session if you have just installed the binary,
Install su - Debian/Ubuntu.
To resolve this error, installing the su binary on your system is the simplest method. If you are on Debian, Ubuntu, or any other Debian-based system that uses
apt as the package manager, you can run the command below to install it:
sudo apt-get -y install util-linux
sudo apt install util-linux -y
Install su - Arch/Manjaro
On Arch Linux and other Arch-based distributions, use
pacman to install
su as shown:
sudo pacman -S util-linux
Install su - Fedora.
If you have Fedora, run the command below to install the
su utility on your system:
sudo dnf install util-linux
Install su - CentOS/REHL
If you have CentOS, REHL, Oracle-Linux, or any other similar system, use yum to install su as shown:
sudo yum install util-linux
Install su - Alpine Linux.
On Alpine Linux, you can use the app command to install su as shown:
sudo apk add util-linux
Install su - macOS
If you are running macOS, you can install the su utility by using Homebrew, as shown in the command below:
brew install util-linux
In this short post, you learned how to resolve the su command not found error in any Unix-based system by installing the su binary.