Why ubuntu terminal unable to find file or directory? - windows

I'm using Ubuntu 20.4.05 LTS. It is not locating any directory as you can see in the image. For example, cd ~/Downloads doesn't take me to the directory.No such file or directory image What should I do?

as a first step you must know the position of the directory by writing the command pwd
pwd
then you can write the ls command to see the contents of the list of folders or directories
ls
if the file you need is in that directory, you can enter that file by writing the command cd
cd
access folder

Related

Command not found in ssh but is in direcory

I am using an ssh account that connects to an external server, i have downloaded through guix some software like samtools and bedtools but when i try to use them in my directory it gives me this error:
-bash: samtools: command not found
In my direcory, however, there is the directry guix.profile and if I go into the bin folder of this, I have everything I downloaded.
What am I doing wrong?
Thank you
enter image description here
To run a file from the shell you need two things:
The shell must find the file
Being in the same directory does not enable the shell to find the file. You have to either supply an absolute or relative path the file, or have the directory in your PATH environment variable
In simplest terms this means instead of
$ samtools
try
$ ./samtools
The relative path tells the shell it wants that file
To run it from another directory, either use the whole absolute path, e.g. /home/yourname/samtools , or move the file into a directory that is on your $PATH
The file needs to be executable
If the file is not executable you will need
$ chmod +x ./samtools

-bash: cd: /tensorflow1: No such file or directory in ubuntu, but the file is there

I am using ubuntu 16.04 and created a virtual environment called 'tensorflow1' as shown above. I am using putty to access a machine remotely. So I was trying to change directory by typing "cd /tensorflow1/models/research" but it says "-bash: cd: /tensorflow1: No such file or directory" in ubuntu, but the file is there. I typed "ls" and it also shows the file. Why is it so?
When you type ls you see the content of the current directory. When you type cd /tensorflow1 you're trying to enter a directory tensorflow1 at the root (/) of the filesystem and the directory is certainly not there. You just need
cd tensorflow1/models/research
to enter a subdirectory of the current directory. Or
cd ./tensorflow1/models/research
because . means "the current directory".
You probably want cd ./tensorflow1/models/research or just cd tensorflow1/models/research.
Read about root directory, home directory, working directory then about path_resolution(7)

Change directory in bash script in windows

How can I change my working directory in bash script in windows. I have
~dp0 = C:\test\docker\windows and I want to change my directory to C:\test\build
So it means 2 levels up and then int o build folder
Thanks
Since C:\ is mounted by default into /mnt/c this will work.
Create a .bashrc in your home path by following command:
echo "BUILDDIR=/mnt/c/test/build" >> ~/.bashrc;source ~/.bashrc
cd $BUILDDIR
# Do your work below for example ./configure.
./configure
On my system in Git bash the C:\ root is just /c/ and other dirs from there are whatever they are, so it would be cd /c/test/build/.
You could also still say cd ../../build/.
Good luck.
To change the directory using a bash script is just like you would using normal bash.
cd "C:/test/build"
echo "You're now in the folder, do what you will."
Save the file as .sh and it can be used as such.
Note, when navigation your folders using a bash script remember the directory you'll be starting from is always the home directory.

No such file or directory - terminal won't recognize directory

When I simply try to cd into a directory on my desktop (cd command + drag folder to terminal to generate file path) I get an error that says "No such file or directory" however, as you can see in the screenshot the folder is there on my desktop. What could be the problem? Thanks.
Seems you have to put a space after the cd command, otherwise the Desktop is available with ~/Desktop on macos shell

What happens when you try to move a file to a non-existant location MAC?

On executing the following lines via the terminal on a MAC,
mv terraform2 ~/bin
cd ~/bin
I get the error that '/Users/myname/bin: Not a directory`. However, I can't see the file terraform2 in its original location. Where did it go?
Given
mv terraform2 ~/bin
If ~/bin doesn't exist before you run that command, your file terraform2 will be renamed to a file called ~/bin.
Thus, when you try
cd ~/bin
you get
/Users/myname/bin: Not a directory
because it's a file - your original terraform2 file.
The command
mv terraform2 ~/bin/.
is much better when you're trying to mv a file into a directory.

Resources