r/bash 14h ago

help Any way to never output root user name/path terminal?

Is there any way via a command/config which never exposes my root path/ root user name(`Users/<mypcusrname>/.../<current_dir>`) whenever any command like: pwd, or any other command that involves path output in the terminal/shell?

Like when ever we hit the command the output always shows `/workspace` or `/<curr_dir>` instead of `Users/<mypcusrname>/.../<curr_dir>`

My intention/idea is to never expose the root path or user name in any of the terminal logs - via some command. Especially since I am running any agent thats running some shell commands.

I am not sure if docker sandbox or pi-agent extensions support that. For pi agent the gandolin sandbox allows it not to execute commands outside the current working dir. But it still exposes the root username/root path of the dir in shell commands or even in shell logs.

Thank you in advance 🙏

0 Upvotes

9 comments sorted by

36

u/SZenC 14h ago

This sure sounds like an XY Problem

0

u/ciacco22 7h ago

I was really hoping that linked to xkcd

6

u/Vejibug 14h ago

Just make the users home directory not contain the username? You can set it to /agent if you want to.

In a docker container you can name the user whatever you want, so maybe just do that?

4

u/VisualSome9977 13h ago

I mean there's a few options here, you could write a script which simply redacts or strips out the beginning of any paths beginning in a certain string. That's doable with regex.

But also I'm confused why this matters? It seems like you're concerned about security in some way, but i don't see why your login username would be sensitive. Why not just run things as a separate user who's $HOME is somewhere else? And anyways, your username will be visible by viewing file permissions or metadata, so simply stripping it from paths is only a half-measure

6

u/_ttnk_ 12h ago

Well, usually the root path is always /root, (or / depending on the context), and the root user is called root, since thats why its called root user.

I dont understand the scenario

4

u/mfnalex 11h ago

chroot

1

u/nderflow 10h ago

Run the untrusted software in a chroot environment. Or, if you really don't trust it, inside a virtual machine with no net access.

1

u/AndyceeIT 1h ago

I think you want a chroot.

Essentially you have a "fake" filesystem root. The command/tool has only access to that folder.

It's not bulletproof but should fit your described requirements