Score:1

I want /ts to reference ~/.local/ts without root/admin privileges?

tr flag

Assumptions:

  • I am on linux machine ubuntu distro.
  • I don't have root/admin privileges-just a standard user.
  • I mostly use bash shell.
  • The directory /ts already exists. I only have read only access to this directory.

When I ssh into this linux machine, I want /ts to refer to ~/.local/ts. eg. Given the directory/file structure below:

/
├── ts
|    └── A.sh
├── home
     └── rtetteh
            └── .local
                   └── ts
                        └── B.sh

When I execute ls /ts I want to see B.sh. When I execute cd /ts I want to be in ~/.local/ts.

Not limited to only the examples above, I want /ts to reference ~/.local/ts in all scenerios. I only want this for myself. I dont want to change any behavior for other users on this linux server.

I did some research and got exposed to mount --bind but this requires root/admin privelages and I am sure this specific technique will affect other users too which is not what I want. I also saw something about bindfs but not totaly sure still researching.

ru flag
What you're trying to achieve will affect the system globally. There's no way to create the type of linking you're looking to achieve that *won't* have system-wide access ramifications.
muru avatar
us flag
You can use a private mount namespace - that will require admin access but won't affect other users, e.g., https://askubuntu.com/a/1074456/158442
Score:0
jp flag

What you want is possible by utilizing kernel namespaces capability and IMO if you recreate your filesystem namespace from scratch which requires some plumbing ... However, luckily, there is a tool from the package bubblewrap that can do that fairly easy:

bwrap is a privileged helper for container setup. You are unlikely to use it directly from the commandline, although that is possible.

It works by creating a new, completely empty, filesystem namespace where the root is on a tmpfs that is invisible from the host, and which will be automatically cleaned up when the last process exits. You can then use commandline options to construct the root filesystem and process environment for the command to run in the namespace.

Therefore:

bwrap --die-with-parent --bind / / --dev-bind /dev /dev --bind /home/rtetteh/.local/ts /ts -- /bin/bash

Is the minimum example(as I see it) to do what you want ... Read the manual and expand that example with more options as you need like for example --setenv VAR VALUE to set environment variables when needed.

If you need to add more bind mounts, then you can add them before the last -- in the form of --bind SRC DEST ... And you will always need --bind / / --dev-bind /dev /dev so don't remove or modify them.

Needless to say that you can't use system directories like /etc, /bin or /var ... etc. as target mount points for other directories or otherwise your newly created filesystem namespace will become unstable and probably unusable.

That wont affect other users or the system services and will only affect the newly created filesystem namespace.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.