On Sun, Aug 29, 2021 at 04:59:35PM -0700, Gary L. Roach wrote: > I don't have occasion to use links very often and tend to get confused as to > which direction the link is pointing. Specifically, I am trying to redirect > backuppc files from the normal /var/lib/backuppc directory to another disk > mounted at /media/Backup, a 1TB disk that is not being used. I wrote "ln -s > /var/lib/backuppc /media/Backup". This produced "backuppc -> > /var/lib/backuppc" on the 1TB disk.
The syntax is: ln -s TARGET LINKNAME I.e. you specify the existing thing first, and the name of the link that you want to create last. > The problem is that I now have duplicate > files in both places. Specifically the cpool, log, pc, and pool directories > appear on both drives. Well, there are two things here. First, if you screwed up the ln -s command the first time, you might also have accidentally created the link in a different place than you thought. In particular, if the final argument is an existing directory, a link will be created *inside* that directory. Second, what you see depends on how you're viewing the two directories. To begin with, note that the ls command has a -d option which suppresses the normal ls behavior of showing the contents of a directory, and instead shows you the directory itself. unicorn:~$ ls -ld /bin drwxr-xr-x 2 root root 4096 Aug 5 07:09 /bin/ If you've been doing commands like "ls -l /media/Back<TAB>" then you might be seeing the contents of a directory, rather than the actual symlink or the directory that it points to. unicorn:~$ ln -s /bin link unicorn:~$ ls -ld link lrwxrwxrwx 1 greg greg 4 Aug 29 20:07 link -> /bin/ Right? There's my symlink which points to a directory. Now, if I forget to use the -d option: unicorn:~$ ls -l link lrwxrwxrwx 1 greg greg 4 Aug 29 20:07 link -> /bin/ Still OK, right? But if I use tab completion, then I get a trailing slash on the argument, and then... unicorn:~$ ls -l link/ total 13980 -rwxr-xr-x 1 root root 1234376 Aug 4 16:25 bash* -rwxr-xr-x 3 root root 38984 Jul 20 2020 bunzip2* -rwxr-xr-x 1 root root 715480 Jul 25 14:44 busybox* [...] So I have a guess that you might have done that. Including the trailing slash changes the behavior of ls (and many other commands).