[SOLVED] Almost commands say "command not found" or "No such file or directory"
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Almost commands say "command not found" or "No such file or directory"
Hi ALL,
My systems is Ubuntu 16.04.1 sever, and my system is installed in USB-disk.
It's no problem when I usually use it.
However, after I don't use the system about 3 hours, I key almost command that it says "command not found" or "No such file or directory".
"cd" command is ok, but some directories seem to be missing.
Code:
#cat, grep, ps, tar, cp, ls, dir ....
: command not found
#sleep 1
/bin/sleep: No such file or directory
Do anyone meet this problem before?
I guess it's the problem of USB-disk.
I will change another USB-disk to test later...
Specifically what is happening is this: the computer is not finding the executable file you have named in any of the places it knows to look. The places it knows to look are the current directory, the directory (path) you have included as part of the filename, and the directories on the $PATH environment variable (your $PATH).
Now, as to why this is happening. If there is no problem before you let your computer idle for a while, and then it happens after the computer sits idle then for some reason your computer is missing part of the above search process after idle. You didn't specify what what has happened during the time you didn't use it, just let it sit idle, closed the lid, unplugged something, etc.
If it is a laptop and you closed the lid then when you open the lid it is not fully 'waking up'. That could be a function of your computer, your system, and some other things. More information would be necessary to see what is specifically happening and why.
If it is not a laptop and simply sits idle then something else is happening. Try being specific about the commands that will and will not work. Can hyou change directories (cd)? Can you list the contents of a directory (ls)? Can you run ifconfig? All three of these are in different locations. Can you run a file in another location that will not run otherwise if you give it the full path? The answers to these questions will help narrow down the source of the problem.
My initial guess is that during the idle period your USB port is being dismounted for some reason or your $PATH variable is being lost, or something of that nature. We cannot really tell until you run some tests and give us more information.
Ok. It doesn't matter what directory you are in at this point, but when it is working try a simple ls command and see if you get a listing of whatever directory you are in. Then, when it is not and the command fails, try /bin/ls. If it works then something is happening to your $PATH variable. If it doesn't then something is happening to your mounts. You might try 'echo $PATH' at both times and see if there is a difference. You might also try listing the /proc/mounts file and see if there is anything different at both times. Less, by the way should be in /usr/bin, so the full command would be '/usr/bin/less /proc/mounts'.
By the way, do you have a user whose username is 'user'? Are you sure you have a /home/user directory? You might try 'ls /home' and see. If you don't then of course you can't cd into it.
I will try "/bin/ls" and "echo $PATH" next time when the problem happens because I reboot the system 6 hours ago
By the way, I am sure I have /home/user directory.
I suspect you will find there is no problem with your $PATH, but that is just a guess at this point. I recently had a similar problem and it turned out to be my hard drive. In your case I suspect it will be your USB disk, but I obviously don't know yet. Let me know what you find out the next time it happens. I am leaning toward suggesting you install on a new USB disk and see what happens, but I'm not sure yet.
You say USB disk and I assume you mean external disk drive, not a thumb drive. You might also try plugging it into a different port to make sure it isn't the port itself.
Ordinarily, the value of $PATH is set when the shell starts up and reads the content of a hidden file which might be named .bashrc. (The leading-period in the name makes it hidden ... use "ls -a .*" to see them.)
Fixing your problem might be as simple as executing something like: source ~/.bashrc.
(The source command is used because this file is not "executable." Rather, it contains a series of commands that the shell is to execute. This command tells the shell to read and process what the specified file contains. Also, "~/" means, "in my $HOME directory ...")
Last edited by sundialsvcs; 03-02-2018 at 06:52 AM.
I install the Ubuntu system on a new USB disk (thumb drive), and let it idle for 2 days. It hasn't happened any problem yet.
Therefore, I think the problem is my USB disk (thumb drive). I will find out why the USB disk cannot work well next time.
I ha that happen to me not long ago which is why I suspected that was the problem. Of course other things had to be eliminated first, it was cheaper that way in case you had to by something to find out. Anyway, I'm glad it worked for you.
I don't know exactly what the cause is, but my first guess would be a matter of heat causing problems but it could be other things, too. What I finally did once I made sure it was the external drive and everything else was working all right was to mount it, move everything off of it I needed, wipe it and then trash it. With the price of drives today it wasn't worth risking anything by continuing to use it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.