I created a bash script to add
#This Script is used to add a folder/diectory to the PATH..
echo -e "\e[92m\e[1mCREATING PATH...........\n\n"
echo -e "\e[92m\e[1mPATH CREATON SUCCESSFUL\n \e[39m"
root@kali:~/Desktop# bash add_path
PATH CREATON SUCCESSFUL
bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory
First thing - you should use
echo $PATH. By simply typing
$PATH you're trying to execute the command, hence the "No such file or directory error"
Next - the
/root/My_Scripts/Bash_Scripts wasn't really added to the
PATH. The first output you see in done inside the script, so the changes could be seen there.
The reason is that
PATH will be set only in the context of the script shell, execute it as
source add_path to preserve the changes in variables (but only for current shell).
If you want the variable to be persistant in all shells - add it to
/.bashrc (since you're runnung as root).