Change home folder without root access #68

Open
opened 2025-02-25 11:42:41 +01:00 by Benjamin_Loison · 17 comments

~/.bashrc is a workaround.

Would help on the server:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdA0V2wqgRdPGSH+7Q9g6WsfrwRaVA78MLkXonasI00Fy4w
cyfJwnGE4lO4+wYpbXrl+tJDApYw8xxusYpemvWja4jn8h82lb27H5cKImGHSHwb
0kcBIPMs4EM7VlPkqPDo6anYT0GVVJ+CF17hZ7/yqeQcj5pTPatCY/MjPXu8lJ5m
ItlB4ckn4tPZUnh9nAKNVMmemK4guOJ50A==
=78Cv
-----END PGP MESSAGE-----

+20

`~/.bashrc` is a workaround. <details> <summary>Would help on the server:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdA0V2wqgRdPGSH+7Q9g6WsfrwRaVA78MLkXonasI00Fy4w cyfJwnGE4lO4+wYpbXrl+tJDApYw8xxusYpemvWja4jn8h82lb27H5cKImGHSHwb 0kcBIPMs4EM7VlPkqPDo6anYT0GVVJ+CF17hZ7/yqeQcj5pTPatCY/MjPXu8lJ5m ItlB4ckn4tPZUnh9nAKNVMmemK4guOJ50A== =78Cv -----END PGP MESSAGE----- ``` </details> +20
Author
Owner
[Benjamin_Loison/bash/issues/25](https://codeberg.org/Benjamin_Loison/bash/issues/25) would help.
Author
Owner

Being able to redefine ~ would be nice.

Being able to redefine `~` would be nice.
Author
Owner
echo ~
/mnt/homes/@CENSORED/CENSORED/loison_benjamin-1000004
~=test
~=test: command not found
```bash echo ~ ``` ``` /mnt/homes/@CENSORED/CENSORED/loison_benjamin-1000004 ``` ``` ~=test ``` ``` ~=test: command not found ```
Author
Owner

https://wiki.lineageos.org/devices/FP4/build/#install-the-platform-tools

loison_benjamin@CENSORED-srv-02:~$ HOME=/scratch/loison_benjamin/
loison_benjamin@CENSORED-srv-02:/mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004$ cd ~
loison_benjamin@CENSORED-srv-02:/scratch/loison_benjamin$
https://wiki.lineageos.org/devices/FP4/build/#install-the-platform-tools ``` loison_benjamin@CENSORED-srv-02:~$ HOME=/scratch/loison_benjamin/ loison_benjamin@CENSORED-srv-02:/mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004$ cd ~ loison_benjamin@CENSORED-srv-02:/scratch/loison_benjamin$ ```
Author
Owner
~/.bashrc:
HOME=/scratch/`whoami`
cd $HOME

On SSH login:

loison_benjamin@CENSORED-srv-02:/scratch/loison_benjamin$ echo $HOME
/scratch/loison_benjamin

No trailing slash to avoid:

source ~/.profile
-bash: /scratch/loison_benjamin//.profile: No such file or directory
<details> <summary><code>~/.bashrc</code>:</summary> ```bash HOME=/scratch/`whoami` cd $HOME ``` </details> On SSH login: ```bash loison_benjamin@CENSORED-srv-02:/scratch/loison_benjamin$ echo $HOME ``` ``` /scratch/loison_benjamin ``` No trailing slash to avoid: ```bash source ~/.profile ``` ``` -bash: /scratch/loison_benjamin//.profile: No such file or directory ```
Author
Owner

Can we actually change the home folder without changing HOME variable?

Can we actually change the home folder without changing `HOME` variable?
Author
Owner
I asked the server administrator if he is fine me sharing this tip to other users of this server:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAmDVTpojQduO28X5SEgj96y3XzigFiamwL9zSO5S3Pgkw
B9qibl6sgoa3sCbQ2VmW8HpiKVlNQ67FoBEXVnIQ9K1GuvmayNzC23xFnkvuvqlk
1LQBCQIQAoqRbrT8EXENcAOuN/mzALkYZZaCDdt0332rygy4M0O1aeTV7cqbcmbu
zKMxbjWApYIA1/ENiUqk4tCgO2tgxZDJQ9U+1JMGG1PayrnXuNH6UFzOtjTqEtqV
y5QKz/5khpxUXqIFsfKKCJd8Xhz16cEuR0Q7lDL+hjpGOIR/xMPYlLoxngPtyIvM
PgqjX+QQ/7F1rro2Hsl50JzyLh0B+iqnBIu1EY1Enxn9yT5YqRI=
=LQIK
-----END PGP MESSAGE-----
<details> <summary>I asked the server administrator if he is fine me sharing this tip to other users of this server:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdAmDVTpojQduO28X5SEgj96y3XzigFiamwL9zSO5S3Pgkw B9qibl6sgoa3sCbQ2VmW8HpiKVlNQ67FoBEXVnIQ9K1GuvmayNzC23xFnkvuvqlk 1LQBCQIQAoqRbrT8EXENcAOuN/mzALkYZZaCDdt0332rygy4M0O1aeTV7cqbcmbu zKMxbjWApYIA1/ENiUqk4tCgO2tgxZDJQ9U+1JMGG1PayrnXuNH6UFzOtjTqEtqV y5QKz/5khpxUXqIFsfKKCJd8Xhz16cEuR0Q7lDL+hjpGOIR/xMPYlLoxngPtyIvM PgqjX+QQ/7F1rro2Hsl50JzyLh0B+iqnBIu1EY1Enxn9yT5YqRI= =LQIK -----END PGP MESSAGE----- ``` </details>
Author
Owner
scp CENSORED_other_network:android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk .
scp: android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk: No such file or directory
scp CENSORED_other_network:/scratch/loison_benjamin/android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk .
Settings.apk                                                                                                                                                                     100%   77MB  18.9MB/s   00:04

Context: Benjamin-Loison/android/issues/91#issuecomment-2907843771

```bash scp CENSORED_other_network:android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk . ``` ``` scp: android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk: No such file or directory ``` ```bash scp CENSORED_other_network:/scratch/loison_benjamin/android/lineage/out/target/product/virtio_x86_64/system_ext/priv-app/Settings/Settings.apk . ``` ``` Settings.apk 100% 77MB 18.9MB/s 00:04 ``` Context: [Benjamin-Loison/android/issues/91#issuecomment-2907843771](https://github.com/Benjamin-Loison/android/issues/91#issuecomment-2907843771)
Author
Owner

After login can use cd - to move to old home folder.

After login can use `cd -` to move to old home folder.
Author
Owner

DuckDuckGo search Linux get user home folder.

The Super User answer 484280:

eval echo ~$USER
/mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004
DuckDuckGo search *Linux get user home folder*. [The Super User answer 484280](https://superuser.com/a/484280): ```bash eval echo ~$USER ``` ``` /mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004 ```
Author
Owner

Benjamin-Loison/cpython/issues/72 helps get new home folder.

[Benjamin-Loison/cpython/issues/72](https://github.com/Benjamin-Loison/cpython/issues/72) helps get new home folder.
Author
Owner

DuckDuckGo search Python get user home folder.

DuckDuckGo search *Python get user home folder*.
Author
Owner

The Stack Overflow question 2668909:

os.environ['HOME']
'/scratch/loison_benjamin'
os.exp
Output:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'os' has no attribute 'exp'
[The Stack Overflow question 2668909](https://stackoverflow.com/q/2668909): ```python os.environ['HOME'] ``` ``` '/scratch/loison_benjamin' ``` ```python os.exp ``` <details> <summary>Output:</summary> ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'os' has no attribute 'exp' ``` </details>
Author
Owner

The Stack Overflow answer 2668952:

os.path.expanduser('~user')
'~user'
os.path.expanduser('~USER')
'~USER'
os.path.expanduser('~$USER')
'~$USER'
[The Stack Overflow answer 2668952](https://stackoverflow.com/a/2668952): ```python os.path.expanduser('~user') ``` ``` '~user' ``` ```python os.path.expanduser('~USER') ``` ``` '~USER' ``` ```python os.path.expanduser('~$USER') ``` ``` '~$USER' ```
Author
Owner
from pathlib import Path
str(Path.home())
'/scratch/loison_benjamin'

Source: the Stack Overflow answer 41915516

```python from pathlib import Path str(Path.home()) ``` ``` '/scratch/loison_benjamin' ``` Source: [the Stack Overflow answer 41915516](https://stackoverflow.com/a/41915516)
Author
Owner
import os, pwd

pwd.getpwuid(os.getuid()).pw_dir
'/mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004'

Source: the Stack Overflow answer 3085545

```python import os, pwd pwd.getpwuid(os.getuid()).pw_dir ``` ``` '/mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004' ``` Source: [the Stack Overflow answer 3085545](https://stackoverflow.com/a/3085545)
Author
Owner
xeyes
Output:
X11 connection rejected because of wrong authentication.
Error: Can't open display: localhost:10.0
echo $XAUTHORITY

does not return anything.

export XAUTHORITY=`eval echo ~$USER`/.Xauthority

Source: the Stack Overflow answer 56661420

solves the issue.

ls -lh `eval echo ~$USER`/.Xauthority
-rw------- 1 loison_benjamin users 58 Jun 15 00:44 /mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004/.Xauthority
~/.bashrc:
export XAUTHORITY=`eval echo ~$USER`/.Xauthority
ssh -X CENSORED xeyes
Warning: locale not supported by C library, locale unchanged

works fine.

``` xeyes ``` <details> <summary>Output:</summary> ``` X11 connection rejected because of wrong authentication. Error: Can't open display: localhost:10.0 ``` </details> ```bash echo $XAUTHORITY ``` does not return anything. ```bash export XAUTHORITY=`eval echo ~$USER`/.Xauthority ``` Source: [the Stack Overflow answer 56661420](https://stackoverflow.com/a/56661420) solves the issue. ```bash ls -lh `eval echo ~$USER`/.Xauthority ``` ``` -rw------- 1 loison_benjamin users 58 Jun 15 00:44 /mnt/homes/@LH-CENSORED/61/loison_benjamin-1000004/.Xauthority ``` <details> <summary><code>~/.bashrc</code>:</summary> ```bash export XAUTHORITY=`eval echo ~$USER`/.Xauthority ``` </details> ``` ssh -X CENSORED xeyes ``` ``` Warning: locale not supported by C library, locale unchanged ``` works fine.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#68
No description provided.