command l to access downloads directory in raspian - linux

lines I have tried:
cd ~/downloads
cd /home/pi/downloads
cd ~/user/home/downloads
ls ~/downloads
cd ~./downloads
If I use the nano command the screen will come up but if Try to change directory it says "no such file or directory". Don't laugh its probably simple but I'm new to Linux and trying to learn command lines.

Related

How to fix cd command does not work in Kali Linux

This is what happens when i type cd.
kali#kali:~$ cd
kali#kali:~$
Nothing pops out
kali#kali:~$ cd
kali#kali:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
kali#kali:~$ pwd
/home/kali
kali#kali:~$ cd Desktop
kali#kali:~/Desktop$ cd
kali#kali:~$
still nothing
Without arguments, cd changes directory to your $HOME directory.
If you look to your output, something has changed. You were in directory Desktop kali#kali:~/Desktop$ and after cd, the shell changed the directory to ~ (kali#kali:~$) which is the $HOME directory of the current user.
By default if the cd command executes with success no output is displayed and the directory is changed, but if you try to change to some directory that does not exist an error message will be output.
For instance, assuming you don't have directory abc in your root, doing the following in a bash shell will output an error:
$ cd /abd
bash: cd: /abd: No such file or directory
In the newest versions of Kali anyway (2020+), there is no cd command. Simply type the directory name (e.g. Downloads -no slashes brackets or flags at all), this is why nothing happens. I've only done this from root but I expect it works the same from a regular user account as well.

Ubuntu: how to enter a directory in shell

On my Desktop I have created a folder called "Files", I would like to know how to access that folder through a shell script
When in Linux file system using bash you can navigate to the home directory in many ways:
After you reach the home directory everything is easy from there including reaching Desktop.
The ~ or $HOME reference:
In Linux based systems the keyword ~ or $HOME refers to the home directory of the computer.
For example say you are currently at /bin, to navigate to home if you know your username you would do :
$ cd /home/yourusername
#The directory is now switched to :
$ pwd #This command stands for print working directory
'/home/yourusername'
Now you can do it alternatively by:
(Again assuming you are in /bin)
$ cd $HOME
$ pwd
'/home/yourusername'
#Alternatively
$ cd /bin
$ cd ~
$ pwd
'/home/yourusername'
These shortcuts let you go to home without writing much and are even recommended.
Now for your problem you can easily navigate to your folder by:
cd ~/Desktop/Files/

Launch Bash script with command line and full path

I launch bash scripts normally with the ./ command.
But if I try to launch the script with the full path I get an error
No such file or directory
I am so confused, I made a search to be sure to get the right path.
$ pwd
/home/pi/server/
$ ls
start_scan
$ sudo chmod 777 start_scan
$ sudo find / -xdev -name start_scan
/home/pi/server/start_scan
$ ./home/pi/server/start_scan
-bash: ./home/pi/server/start_scan: No such file or directory
Do you have any idea what could the problem be? I am using a macbook to use SSH and connect to a Rapsberry Pi under Raspbian and execute the script there.
./ is no command, but a path that means the current working directory.
Your line is almost correct, just remove the dot at the beginning:
/home/pi/server/start_scan
When you type any path starting with a dot, the shell expands it to the current working directory, effectively searching in
/home/pi/server/home/pi/server/start_scan
which is obviously wrong.

How can I use a dot file in a bash script unix

I am trying to install git's autocomplete (and I do not want to use Homebrew to do this), so I placed the following in my bash_profile
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
The .git-completion.bash is an install script I donwload from github, specifically:
https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
The .git-completion.bash file exists, I can see it when I run ls -la however, every time I open a terminal window, I see
-bash: /Users/Username/git-completion.bash: No such file or directory
(I do not know why it does not have a "." in that error)
I would appreciate any guidance on how to fix this without homebrew. Thanks

mkdir $HOME/ error

I tried a one line script that worked in one Linux based distro(Linux mint) but doesn't work in another(Fedora). I typed the following line in my bash script.
mkdir $HOME/folder123
The error i receive:
bash: create.sh: No such file or directory
I tried creating a folder myself, it gave me a permission denied?
To clear things hopefully: mkdir is in the script create.sh and i run it in the terminal with the command bash create.sh
If I interpret your post correctly, you have a file create.sh that contains mkdir $HOME/folder123, and you're trying to run it by typing create.sh.
To execute a script, chmod +x yourscript.sh then run it with either ./yourscript.sh if it's in the current directory, or /home/whatever/yourdir/yourscript.sh if it's in another directory.
To make just yourscript.sh work, you have to place it in a directory listen in $PATH.
You can do this by copying it to any of the directories listed in echo $PATH.
Alternatively, you can create a new directory such as mkdir /home/you/bin and then add export PATH="$PATH:/home/you/bin" at the end of your ~/.bashrc. Also make sure ~/.bash_profile contains the line source .bashrc. Then log out and in again.

Resources