Why is the 'ps' command not found?
The "ps: command not found" error typically occurs when the command isn't available on your system. This can happen if the 'procps' package isn't installed or if there are PATH issues.
For Debian-based systems like Ubuntu, install it with:
sudo apt-get install procps
For Red Hat-based systems, use:
sudo yum install procps-ng
To check your PATH, run echo $PATH
and ensure it includes /bin
and /usr/bin
. Update if necessary using:
export PATH=$PATH:/bin:/usr/bin
In minimal environments like Alpine Linux, the full 'procps' package might not be included. Install it by running:
apk add procps
after updating with:
apk update
How to install 'ps' on various systems
Debian-based systems (Ubuntu):
- Update package index:
sudo apt-get update
- Install:
sudo apt-get install procps
Red Hat-based systems (CentOS, AlmaLinux, Rocky Linux):
- Update package manager:
sudo yum update
- Install:
sudo yum install procps-ng
Fedora:
- Refresh repository data:
sudo dnf makecache
- Install:
sudo dnf install procps-ng
Arch Linux:
- Sync package databases:
sudo pacman -Syu
- Install:
sudo pacman -S procps-ng
Alpine Linux (Docker):
- Update repositories:
apk update && apk upgrade
- Install:
apk add procps
How to resolve PATH issues for 'ps'
- Check your current PATH:
echo $PATH
- If
/bin
and/usr/bin
are missing, temporarily add them:export PATH=$PATH:/bin:/usr/bin
- For permanent changes, add this line to
~/.bashrc
or~/.bash_profile
:export PATH=$PATH:/bin:/usr/bin
- Apply changes:
source ~/.bashrc
Ensure you're using the appropriate file and command for your specific shell configuration.
Alternative methods for using 'ps'
- Switch to a more complete shell environment like Bash.
- In Docker with Alpine Linux, install the full 'procps' package.
- Build from source for customized installation, if development tools are available.
These approaches can help overcome limitations in minimal environments and provide access to a more robust version of 'ps'.
Did you know? The 'ps' command stands for "process status" and provides a snapshot of the currently running processes on a system1.
Writio: Your automated content creation solution. This article was crafted by Writio.
- Linuxize. PS Command in Linux (Process Status). Linuxize. 2019.