(Parts of) .profile not being recognised

Dell Latitude E5570 running Ubuntu 24.04

Following a re-installation of Ubuntu and all my files and odd bits of s/w, a remaining problem concerns the implementation of my scripts. I keep them in a directory called (for historical reasons) .bin in my home directory, and I have added it to my .profile file so that the system can find it when one of its scripts is called.
As an inveterate photographer of my garden flowers I wrote a script to download the photos from my camera into a directory for later manipulation. The script is called photos_get and the dialogue goes like this:

keith@E5570:~$ photos_get
bash: /home/keith/.bin/photos_get: Permission denied (why, I don’t know)
keith@E5570:~$ sudo photos_get
sudo: photos_get: command not found

.…so checked the PATH environment variable:
keith@E5570:~$ echo $PATH
/home/keith/.bin/Reminders:/home/keith/.bin:/usr/local/sbin:…etc etc…
keith@E5570:~$

So it knows where to find the script despite telling me it can’t be found.
Advice would be welcome.

bash: /home/keith/.bin/photos_get: Permission denied

It’s there, the permissions are just wrong.

chown -R keith /home/keith

My guess would be that after restoring your files you did;

chown -R keith /home/keith/*

… which doesn’t pick up files beginning with a dot (!)

Actually it didn’t even occur to me to do that - in fact I can’t remember having to do it in the past. Doing it now shows no change:

keith@E5570:~$ chown -R keith /home/keith
keith@E5570:~$ photos_get
bash: /home/keith/.bin/photos_get: Permission denied
keith@E5570:~$

but …

keith@E5570:~$ chown -Rv keith /home/keith/.bin | head -n 3
ownership of ‘/home/keith/.bin/backup_file_list’ retained as keith
ownership of ‘/home/keith/.bin/backup_reminder.png’ retained as keith
ownership of ‘/home/keith/.bin/.xdp_backup_v4.3.N4CO50’ retained as keith
…etc etc…
keith@E5570:~$
and…
keith@E5570:~$ chown -Rv keith /home/keith/.bin | grep “photos_get”
ownership of ‘/home/keith/.bin/photos_get_2’ retained as keith
ownership of ‘/home/keith/.bin/photos_get’ retained as keith
keith@E5570:~$

… does recognise the file although the photos_get command still isn’t recognised.
It looks like the .profile file is not being recognised:

$PATH contains /usr/games but Games are no longer listed in the Applications menu, so it begins to look like $PATH is not being recognised by the system, although this doesn’t seem likely.

In which case, is it possible you did a chmod on it, maybe set everything “rw”? Try;

ls -la bash: /home/keith/.bin/photos_get

In order to execute the permissions need to start;

-rwx*

Example;

$ ls -la test.sh 
-rw-r--r-- 1 gareth gareth 35 Feb 15 14:23 test.sh
gareth@rad:~ $ ./test.sh
bash: ./test.sh: Permission denied
gareth@rad:~ $ chmod +x test.sh
$ ls -la test.sh 
-rwxr-xr-x 1 gareth gareth 35 Feb 15 14:23 test.sh
gareth@rad:~ $ ./test.sh
Hello World

Before finding your post I had a sudden thought about permissions and the command ls -l showed that copying the .bin directory back to my PC from the backup had left the contents without execution permission!!!

No idea why that might be but I have solved the problem - as had you.
Many thanks for your advice - and I am sorry to have troubled you.

Keith

1 Like