0
votes

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

1
what does echo $HOME show? is that var in the environment of whatever shell you're running this script in? - Marc B
what does which mkdir show? - Patrick B.
echo $HOME shows/home/liveuser which mkdir shows mkdir/bin I updated my post, not sure what's up with the permission, would that be the problem?(or is this another problem of it's own)? I dont know how to edit the permission. - user1880760
try \mkdir $HOME/folder123 - Fredrik Pihl
mkdir should be a binary and not a script, so it should never call any subscript like create.sh. Perhaps the command is aliased to something else. Alternatively, and please don't get all upset about it, someone might have been messing with your system, making it look like mkdir is still there, but also does some extra things, perhaps in the hopes that you run it as root - Miquel

1 Answers

0
votes

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.