Why did Linux server refuse the command ?
When we use linux server like XSERVER through SSH connection, we usually use these commands like
But one day your server would refuse your command, and you may see the error below.
bash: ls: command not found
What is root cause of this error.
How to find root cause without commands like
So today I will introduce how to fix "ls: command not found" error in Linux.
Advantage to read
You can understand how to fix "ls: command not found" error in Linux.
Reason of "ls: command not found" error
Reason of "ls: command not found" error is that PATH settings is broken.
Because of broken PATH settings, server can not find program of input command.
So server said "command not found".
So you can run command with full path.
It depends on environment.
In XSERVER, you can run
ls command with
How to fix error
Now we understand cause of error.
Then how can we fix the error ?
Path settings is in
(In case of that default shell is bash.)
So you can see and fix that content.
In order to open file, you can use this command.
When I found this error,
~/.bash_profile was like below.
Cause is read area.
PATH=$PATH:$HOME/bin export PATHeval $(/home/xxxx/.linuxbrew/bin/brew shellenv)
This text should have line break between
export PATH and
(Maybe I did mistake when I installed linuxbrew.)
PATH=$PATH:$HOME/bin export PATH eval $(/home/xxxx/.linuxbrew/bin/brew shellenv)
So modify it then you can solve "command not found" error.
Today I introduced How to fix "ls: command not found" error in Linux.
Reason of "command not found" error is that PATH settings is broken.
In this case, you can use full path like
In order to solve this error, you should open
And modify path settings.
Knowledge about Linux is very important for web engineer.
These GCP,AWS,OracleVM, XSERVER serve Linux server.
So it is good to learn linux.
There are related articles like ssh connection to linux server and how to install.