Skip to content
Log In Sign Up info@muvcloud.com

Check the Command First

type nginx
command -v nginx
echo "$PATH"
ls -l /usr/sbin/nginx

type and command -v tell you whether the shell can find a command and where it is; if they print nothing or say "not found", the shell cannot. echo "$PATH" prints the list of folders the shell searches, separated by colons. Work through the causes below in order.

1. A Typo

Commands are case-sensitive: Ls and sl are not ls. Some names also differ from what people expect, for example python3 instead of python on many current distributions. Press Tab after the first letters: the shell completes names it knows, and completes nothing for a name it cannot find.

2. The Package Is Not Installed

Minimal server images leave out many tools. Install the package that contains the command:

sudo apt install htop
sudo dnf install htop

The first line is for Ubuntu and Debian, the second for AlmaLinux and Rocky Linux; on AlmaLinux and Rocky Linux, htop is in the EPEL repository, which you enable with sudo dnf install epel-release. On Ubuntu, the shell often suggests the right package itself when a command is missing. Some old tools have been replaced: ifconfig and netstat come from the net-tools package, and ip and ss do the same jobs on every current distribution.

Find Which Package Provides a Command

On Ubuntu and Debian, apt-file searches the files of all packages, installed or not:

sudo apt install apt-file
sudo apt-file update
apt-file search bin/htop

On AlmaLinux and Rocky Linux, dnf can do this without extra tools:

dnf provides '*/htop'

For a file that is already on the system, dpkg -S /usr/bin/htop (Debian, Ubuntu) or rpm -qf /usr/bin/htop (AlmaLinux, Rocky Linux) names the package it came from.

3. The Program Is Not in Your PATH

Programs installed by hand often land in a folder such as /opt/app/bin or ~/.local/bin. Run it with the full path, or add the folder to PATH by putting this line at the end of ~/.bashrc:

export PATH="$PATH:/opt/app/bin"

Then run source ~/.bashrc or open a new session. If you installed a program and it is still not found, or bash still runs an old copy from another folder, hash -r clears the shell's memory of where commands are.

4. A System Tool That Needs sudo

Administration tools such as ufw, iptables, or useradd live in /usr/sbin. On Debian, that folder is not in the PATH of regular users, so the command is "not found" until you run it with sudo. sudo searches its own list of folders, set by secure_path in /etc/sudoers. That list can leave out /usr/local/bin: on AlmaLinux and Rocky Linux, a program installed there may work for your user and be "not found" with sudo. Give the full path in that case: sudo /usr/local/bin/tool. If you do change sudoers, edit it only with sudo visudo. On Debian, use su - with the dash, not plain su, to get root's PATH.

5. A Script in the Current Folder

The current folder is not part of PATH, so deploy.sh is not found even when it is right there. Run it with ./ in front, and give it the execute bit once:

chmod +x deploy.sh
./deploy.sh

Without the execute bit, the error is "Permission denied" instead. Do not use chmod 777: +x is enough. If the error is "bad interpreter", the first line of the script names a program that does not exist, or the file was saved with CRLF line endings on another computer; sed -i 's/\r$//' deploy.sh converts them.

For working on the server over SSH, see how to use PuTTY to SSH into a server. Package names differ a little between families; Debian vs Ubuntu Server and AlmaLinux vs Rocky Linux explain the differences.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations