"no such file or directory" linux - linux

I am quite a beginner in Linux and trying to install gurobi for linux. The installation guide says to move the downloaded file with the following command:
sudo mv ~/Downloads/gurobi9.5.2_linux64.tar.gz /opt/
When I run this, I get the response:
mv: cannot stat '/home/laukna/Downloads/gurobi9.5.2_linux64.tar.gz': No such file or directory
Is there any way to fix this?

The tilde "~" symbol is "a Linux 'shortcut' to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory." (quoted from twiki.org)
So if your file isn't located in your home directory (which is what your message "No such file..." implies) then you need to write the absolute path to where that file is. If you don't know, you can find it with
find / -name "gurobi9.5.2_linux64.tar.gz"

The issue is that Linux is not recognizing the gurobi file, What is the file name? seems that is not gurobi9.5.2_linux64.tar.gz
You need check the file name in Downloads folder, replace in the command and run again.
sudo mv ~/Downloads/<FILE NAME>.tar.gz /opt/

Related

How do I move files out of a broken directory in linux?

I know the premise of the question may be confusing, but I want to understand what happened.
Recently I have been experimenting with the rockchip OK3399 single-chip computer(see here) and have installed a linux system on it with TF card installation. Using Putty and connecting with serial protocol, I was able to establish a connection with the OK3399 computer and control it through my laptop.
I am trying to self-learn some linux with the OK3399 system. I created a bash code by the name of displayvids.sh inside the directory /usr/bin, which is meant to take a variable number of pictures with a mipi camera and then save in a directory for work.
I finished writing the code, but for some reason I cannot run the .sh file when my working directory is not the /usr/bin directory, despite /usr/bin being in the %PATH% environment variable. So, I executed the following command:
mv /usr/bin/display* /usr/local/bin
... attempting to move the file to /usr/local/bin instead. The command ran successfully, but when I tried to run the command:
cd /usr/local/bin
It tells me that I cannot cd to bin
As seen from the above image, the /usr/local/bin is not even a directory. Why would mv succeed if the target was not a directory? How can I retrieve my bash file?
Why would mv succeed if the target was not a directory?
mv can also rename files:
mv foo.txt bar.txt
You renamed your script to bin and moved it under /usr/local.
You may want to remember to add a trailing slash next time, to have mv barf if the target isn't a directory:
mv /usr/bin/display* /usr/local/bin/
How can I retrieve my bash file?
Rename it back.
mv bin displayvids.sh
For future reference, you can use the file command to (try to) identify the contents of a file, if it's installed:
file bin
would have probably said bin: Bash script or similar.

Renaming a script using Linux mv / rename

I'm trying to rename the script audience_segment_map.sh to audience_segment_map_dedupe.sh using the Linux command line.
I have tried using the mv and the rename commands but they're not having the desired effect:
mv user/local/dmp_job/audience_segment_map.sh user/local/dmp_job/audience_segment_map_deupe.sh
This returns the error
'audience_segment_map.sh' No such file or directory"
but when I use the ls command, the file clearly shows up.
How should I proceed?
Pointing to a path with and without leading / slashes are different (absolute versus relative, respectively). Unless you are in the root directory, most likely you want your command to look like
mv /user/local/dmp_job/audience_segment_map.sh /user/local/dmp_job/audience_segment_map_deupe.sh
where the path is pointing to /user/local/... instead of user/local/...

shell script mv is throwing unhelpful error "No such file or directory" even though i see it

I need to use a shell script to move all files in a directory into another directory. I manually did this without a problem and now scripting it is giving me an error on the mv command.
Inside the directory I want to move files out of are 2 directories, php and php.tmp. The error I get is cd: /path/to/working/directory/php: No such file or directory. I'm confused because it is there to begin with and listed when I ls the working directory.
The error I get is here:
ls $PWD #ensure the files are there
mv $PWD/* /company/home/directory
ls /company/home/directory #ensure the files are moved
When I use ls $PWD I see the directories I want to move but the error afterward says it doesn't exist. Then when I ssh to the machine this is running on I see the files were moved correctly.
If it matters the directory I am moving files from is owned by a different user but the shell is executing as root.
I don't understand why I would get this error so, any help would be great.
Add a / after the path to specify you want to move the file, not rename the directory.
You should try this:
mv $PWD/\* /home/user/directory/
Are your variables properly quoted? You could try :
ls "$PWD" #ensure the files are there
mv "$PWD"/* "/company/home/directory"
ls "/company/home/directory" #ensure the files are moved
If any of your file or directory names contains characters such as spaces or tabs, your "mv" command may not be seeing the argument list you think it is seeing.

/cygdrive path is broken

My cygwin used to work properly before, but suddenly it starts to complain: "file does not exist" under /cygdrive/d ...
The problem looks like this: if I cd to that folder I can saw that file and cat/ls afile without any problem, but if I use something like ls /cygdrive/d/afile it will complain "file does not exist".
So I traced backwards on the file system, and found there's some issue with the virtual path /cygdrive
/cygdrive
cd /cygdrive/
Error: Current working directory is a virtual Cygwin directory which
does not exist for a native Windows application. Can't start native
Windows application from here.
Seems this /cygdrive is broken, does anyone know how to fix it?
Adding more detail:
$grep cygdrive /etc/fstab
# none /cygdrive cygdrive binary,posix=0,user 0 0
$type -a cd
#cd is a shell builtin
I get that error message if I do a cd /cygdrive and then try to execute a (non-Cygwin) Windows command. I don't get it if I just cd /cygdrive.
The only explanation I can think of is that you've assigned a value to the bash special variable $PROMPT_COMMAND.
Quoting the bash documentation:
'PROMPT_COMMAND'
If set, the value is interpreted as a command to execute before
the printing of each primary prompt ('$PS1').
For example:
$ PROMPT_COMMAND=cmd.exe ; cd /cygdrive
Error: Current working directory is a virtual Cygwin directory which does
not exist for a native Windows application.
Can't start native Windows application from here.
-bash: /cygdrive/c/Windows/system32/cmd.exe: Not a directory
move to the right directory by replacing (if you are in C drive for example)
cd /cygdrive
by
cd c:/cygdrive
also suitable:
cd /c/<rest of your path>

cd Desktop gives an error no such file/ directory in terminal

In Terminal, on mac, when i use the cd Desktop to view files through the terminal i get an error "no such file or directory"
When i checked the current working directory, it shows I'm in /home/
I do not understand why suddenly it doesn't work.
I tried using a .profile file to have some alias and path change. Could this change in .profile file cause this error?
Try use cd (with no parameters) for jump to your home directory which should be /Users/username. Then use cd Desktop. Alternatively you can do "cd ~/Desktop"
First of all, make a desktop folder in the home folder, then open the command prompt
Also, try the " cd desktop " command you will not get an error. Always remember the case-sensitive words before running Command.

Resources