Ubuntu Server 16.04安装imgmin后提示command not found求助
Let’s work through this issue step by step—this is a common hiccup after compiling software from source, and it’s usually straightforward to fix.
Step 1: Confirm if imgmin was actually installed
First, let’s check if the imgmin executable exists anywhere on your system. Run this search command:
sudo find / -name imgmin -type f
- If the search returns a path like
/usr/local/bin/imgmin, the binary was installed successfully, and the problem is likely with your shell’sPATHenvironment variable. - If no results show up, that means
make installdidn’t copy the binary to a system directory—even though it didn’t throw an explicit error.
Step 2: Fix PATH issues (if the binary exists)
Ubuntu 16.04 typically includes /usr/local/bin (the default install location for source-compiled tools) in bash’s default PATH, but this can sometimes get misconfigured. Let’s verify:
echo $PATH
Look for /usr/local/bin in the output. If it’s missing:
- Temporary fix (works only for your current session):
Try runningexport PATH=$PATH:/usr/local/binimgmin original.jpg optimized.jpgagain—this should work now. - Permanent fix (persists across reboots):
Open your bash profile file in a text editor:
Add this line at the bottom of the file:nano ~/.bashrc
Save and exit (press Ctrl+O, hit Enter, then Ctrl+X), then reload the profile to apply changes:export PATH=$PATH:/usr/local/binsource ~/.bashrc
Step 3: Manually install the binary (if it wasn’t found)
If the find command didn’t locate imgmin, go back to the directory where you compiled the project:
cd imgmin/src
Check if the compiled binary exists here:
ls -l imgmin
If you see an executable file named imgmin, copy it manually to /usr/local/bin (the standard directory for user-compiled tools):
sudo cp imgmin /usr/local/bin/
Now test the imgmin command again—it should work as expected.
Bonus: Verify the install process (optional)
If you want to double-check the installation flow, re-run sudo make install and watch the output closely. You should see a line similar to:
installing imgmin to /usr/local/bin
If you don’t see this line, there might be a build configuration issue. Try re-running the configure step with an explicit prefix to enforce the install path:
./configure --prefix=/usr/local make sudo make install
内容的提问来源于stack exchange,提问作者Niranda

