So,
I guess it should be clear that your app isn’t in your $PATH?
Either add the location of your app or if you intend to make your app accessible by all including the system, you should install into one of the root directories and not a User directory.
So what did you change? did you change the location of the script?
Any how
/home/user/bin
is only available to the certain user and it will not be in the PATH of the other users in the system (root user included).
If you want the script to be available to everybody in the system you can put it in
/usr/local/bin
If you want it only to be accessible to the root user
/usr/local/sbin
The key word here is local since that script is made/created by the local administrator which happens to be you. Of course everyone can access the /usr/local/sbin if they use the absolute path, it is just not the default for everyone, at least not in openSUSE. Also you can put it anywhere else if you like say like in /bin and /usr/bin. So where will you put your script will depend on what your goal is.
If scanvirus is in /home/user/bin, and you run it as the root user, it indeed won’t start. You should then cd /home/usr/bin, and then invoke ./scanvirus
Opensuse leap 42.3 -->opensuse leap 15, full install, erasing all previous partitions. However, did that with the opensuse before ‘42.3’. 42.2 -->42.3 scanvirus worked.
Then → copy the script from backup → /home/user/bin/
(see previous message).
Anyhow
/home/user/bin
is only available to the certain user and it will not be in the PATH of the other users in the system (root user included)
If you want the script to be available to everybody in the system you can put it in
/usr/local/bin
If you want it only to be accessible to the root user
/usr/local/sbin
The key word here is local since that script is made/created by the local administrator which happens to be you. Of course everyone can access the /usr/local/sbin if they use the absolute path, it is just not the default for everyone, at least not in openSUSE. Also you can put it anywhere else if you like say like in /bin and /usr/bin. So where will you put your script will depend on what your goal is.
The goal was to create a fully functional command line virus scanner with all the features of GFX anti-virus scanner. With each version, it’s closer to that goal.
It can only be run in superuser mode. In my case, only one admin. However, more than one admin could run it. Both might try to run it at the same time. Another future to bug to fix.
At login, a user’s PATH variable is initially setup by the system file ‘/etc/profile’ – if this file is modified, then ** ALL ** users (including the ** SYSTEM ** users) on the system will be affected by the change …
After the login process has read the system-wide ‘/etc/profile’ file, if the Bash shell is involved, it then looks for a couple of user Bash files and then ‘~/.profile’ – even if Bash isn’t involved – the case for some GUI Desktop environments – IOW ‘~/.profile’ is always read …
Therefore, add the following lines to the user’s ‘~/.profile’ file:
PATH=${PATH}:"«The complete path to the user's specific directory to be included in the $PATH environment variable.»"
export PATH
Please note the :" … "
syntax in the ‘PATH=’ statement …
is the correct place to put an additional PATH value and you need to export that PATH, you will see a commented example in that file.
The only thing to note is the order of COMMAND EXECUTION from bash see.
PAGER='less +/^COMMAND\ EXECUTION' man bash
To make it short bash search for the exectuable in the PATH from left to right. Just in case you have two executable that has the same name. so instead of
export PATH="$PATH:/home/$USER/bin"
I suggest to do
export PATH="/home/$USER/bin:$PATH
In your ~/.profile, Im not sure if the root user has a ~/.profile by default though, just create one if needed.
Any user with the admin should be able to run it. I’v never run it as ‘root’ user. I think I understand now. I tried putting into the ‘usr/local/bin and usr/local/bin’. Those aren’t listed in the path below. So, I get ‘command not found’.
The default $PATH in opensuse leap 15
# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
‘usr/sbin’ linux default commands. usr/bin are the installed app commands. Right?
sbin= SystemBINarys
bin= installed BINArys
As an installed app, it should go into usr/bin
If I use the /local/ folders, I will need to add a permanent $PATH change. I need to keep the install simple.
/home/username/bin/scanvirus → usr/bin/scanvirus
That should be the correct folder placement ‘scanvirus’…