23
« Last post by nick65go on September 05, 2025, 02:53:13 PM »
Here a demo. with two fictive users (John and Smith), each with different shell prompter ❯ ls -l home/
drwxr-xr-x - abc 5 Sep 19:52 John
drwxr-xr-x - abc 5 Sep 19:53 Smith
❯ cat home/John/.profile
PS1='\u@GREEN:\w\$ '
export PS1
❯ cat home/Smith/.profile
PS1='\u@RED:\w\$ '
export PS1
If you use a LOGIN SHELL, sh -l, or login, you get the user specific prompter.
But if you just SU/SUDO (switch user) , the shell prompter stays as former user: ~/Desktop/TinyCore/demo
❯ sudo chroot . /bin/login -f John
John@GREEN:~$ cd /
John@GREEN:/$ su Smith
Smith@GREEN:/$ <==same GREEN prompter as for John, former user
Smith@GREEN:/$ sudo login -f Smith
Smith@RED:~$ exit <==now the new user prompter RED
Smith@GREEN:/$ ^C
The way to change the shell prompter even for a non-login shell is to have, BEFORE summon the su or sudo, the ENV (environment variable) set to a personal script somewhere, as ENV=full-path-to-that-executable-script-to-change-PS1. So every time you change user, the new sh shell will SOURCE that script.