LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-01-2018, 08:35 PM   #1
iorih0304
LQ Newbie
 
Registered: Jul 2017
Posts: 26

Rep: Reputation: Disabled
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...

Last edited by iorih0304; 03-01-2018 at 08:36 PM.
 
Old 03-01-2018, 11:06 PM   #2
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 03-02-2018, 12:13 AM   #3
iorih0304
LQ Newbie
 
Registered: Jul 2017
Posts: 26

Original Poster
Rep: Reputation: Disabled
Thank you for your reply. ^^

It's not a laptop.
"ls" and "ifconfig" cannot work.
"cd" can work, but almost path I cannot cd in.
Code:
cd /home      .......ok
cd /home/user .......No such file or directory
 
Old 03-02-2018, 12:56 AM   #4
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 03-02-2018, 01:23 AM   #5
iorih0304
LQ Newbie
 
Registered: Jul 2017
Posts: 26

Original Poster
Rep: Reputation: Disabled
I tried the commands before
Code:
#ls
-bash: /bin/ls: No such file or directory
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.
 
Old 03-02-2018, 06:23 AM   #6
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
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.

Let me know what happens.
 
1 members found this post helpful.
Old 03-02-2018, 06:47 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.)

This post on SuperUser.com spells it out quite well, and leads to other related links.

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.
 
Old 03-04-2018, 07:56 PM   #8
iorih0304
LQ Newbie
 
Registered: Jul 2017
Posts: 26

Original Poster
Rep: Reputation: Disabled
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.

Thank you for your suggestions and help.
 
Old 03-04-2018, 09:23 PM   #9
pholland
Member
 
Registered: Jun 2015
Posts: 86

Rep: Reputation: Disabled
Does this problem happen after the computer hibernates, but not after a sleep? https://ubuntuforums.org/showthread.php?t=2273886
 
Old 03-04-2018, 09:32 PM   #10
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] When I type "sudo grub" it says "command not found" in Ubuntu 9.10 Live CD. msbstar Linux - Newbie 10 04-01-2020 11:54 PM
Centos Server Failed @ Bootup: Missing "/sbin/blkid" & "fsck" command not found beagle7 Linux - Newbie 4 08-24-2012 01:33 AM
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
When I type "sudo grub" it says "command not found" in Ubuntu 10.10 poumtatalia Linux - Newbie 5 09-14-2010 05:21 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration