Linux/Raspbian's use of symlinks?

Confusion reigns supreme. . .

Given:
A folder path something like this:
/home/pi/Project_Files/GoPiGo3/[etc., etc.] that contains my working copy of the stuff I’m messing with.

Given:
A symlink to /home/pi/Project_Files on my desktop, such that the path to the symlink is /home/pi/Desktop[etc.] - which resolves to /home/pi/Project_Files.

Here’s a listing of the “pi” home directory:

pi@Charlie:~ $ ls -l
total 224
-rw-r--r-- 1 pi   pi   131355 May 18 16:41 2020-05-18-164114_1360x768_scrot.png
drwxr-xr-x 3 pi   pi     4096 May 18 17:51 Desktop
drwxr-xr-x 8 root root   4096 May 18 02:17 Dexter
-rw------- 1 pi   pi      753 Apr 15 02:52 DistanceSensorSingleShot.py
drwxr-xr-x 3 root root   4096 May 18 02:11 di_update
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Documents
drwxr-xr-x 2 pi   pi     4096 Apr 19 21:11 Downloads
-rw-r--r-- 1 pi   pi     5776 May 17 21:10 edid.txt
-rw-r--r-- 1 pi   pi        6 Mar 22 17:24 failedIP
-rw-r--r-- 1 pi   pi      256 May 17 21:07 filename.dat
-rw-r--r-- 1 pi   pi       52 Apr 15 20:58 gpg3_config.json
-rw-r--r-- 1 pi   pi        9 Mar 22 17:24 ipcount
-rw-r--r-- 1 pi   pi     1227 Dec 11 23:52 ip_feedback.sh
-rw-r--r-- 1 pi   pi        0 Mar 22 17:24 ip.number
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 MagPi
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Music
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Pictures
drwxr-xr-x 5 pi   pi     4096 May  2 20:29 Project_Files
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Public
-rw-r--r-- 1 pi   pi     2286 Apr 15 02:58 sensor_test.py
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Templates
drwxr-xr-x 2 pi   pi     4096 Sep 26  2019 Videos
-rw-r--r-- 1 pi   pi     4253 Apr 15 21:41 wxpaths.txt
pi@Charlie:~ $

Here’s the listing of my Desktop folder:

pi@Charlie:~ $ cd ./Desktop
pi@Charlie:~/Desktop $ ls -l
total 172
-rwxr-xr-x 1 pi   pi      307 May 18 02:14  advanced_comms_options.desktop
-rwxr-xr-x 1 root root    284 May 18 02:17  backup.desktop
-rwxr-xr-x 1 root root    414 May 18 02:17  desktop_shortcut_update.desktop
-rw-r--r-- 1 root root 122122 May 18 02:17  Dexter_Software_Update_log_2020_05_18__02_11_53.txt
lrwxrwxrwx 1 root root     23 May 18 17:33  GoPiGo3 -> /home/pi/Dexter/GoPiGo3
-rw-r--r-- 1 root root    370 May 18 17:33  gopigo3_control_panel.desktop
-rwxr-xr-x 1 root root    329 May 18 02:17  line_follower_calibration.desktop
drwxr-xr-x 2 pi   pi     4096 Apr 19 21:01 'Logs and Stuff'
-rwxr-xr-x 1 pi   pi      324 May 18 17:46 'NGoPiGo3 Control Panel'
-rw-r--r-- 1 pi   pi      111 Apr 15 22:30  piclone.desktop
lrwxrwxrwx 1 pi   pi       22 May 18 17:29  Project_Files -> /home/pi/Project_Files
-rwxr-xr-x 1 pi   pi      367 May 18 02:14  Scratch_Start.desktop
-rwxr-xr-x 1 root root    266 May 18 02:17  shutdown.desktop
-rwxr-xr-x 1 pi   pi      404 May 18 02:15  Troubleshooting_Start.desktop
-rwxr-xr-x 1 root root    226 May 18 02:17  version.desktop
pi@Charlie:~/Desktop $ 

Either I am going out of my mind, or something weird is going on here.

I remember in the past, (on other versions of Linux), that any reference to a symlink was substituted with the symlink’s target path in any path reference.

Viz.:
Clicking on the ./Desktop/Project_Files symlink opens up a file manager with the path set to /home/pi/Project_Files - as that’s the target of the symlink.

What actually happens is that the symlink, when opened, resolves to the path set through the location of the symlink, not the target path.

Viz.:
/home/pi/Desktop/Project_Files

When viewing in the file manager’s tree view, there are now two  apparent paths to what appear to be two  completely different directory trees.

IMHO, this should not happen as there are NOT  two different directory branches there, and it gives the impression that work done on one is totally separate and distinct from work done on the other.

Is this expected behavior?  IMHO, this is totally counter-intuitive.

1 Like

During 30 or so years of getting messed up by other people’s symlinks, my policy was to use shell aliases with pushd to get to common places. I was never surprised where “cd ..” took me, or what got deleted by an “rm”, or “where the heck is that file?”, or what is that doing “here?” Symlinks just never were safe or comfortable for me.

1 Like