Linux

在根目錄而不是 $HOME 中打開的終端

  • September 14, 2020

我最近將我的主目錄移到了另一個磁碟上,現在將其安裝在上面/home——這似乎奏效了。

然而,一個令人費解的事情是我打開的任何終端仿真器(不管程序、alacritty、rxvt、xterm 等)預設打開/目錄而不是我的主目錄/home/daniel

我不知道該怎麼做才能解決它,我可以設置--working-directory,但這似乎是一個創可貼,因為在我移動之前我的終端總是在 $HOME 中打開……

/|▶ echo $HOME
/home/daniel
/|▶ finger daniel
Login: daniel               Name: Daniel
Directory: /home/daniel         Shell: /bin/zsh
On since Sun Sep 13 12:49 (BST) on :0 from :0 (messages off)
/|▶ whoami
daniel
/|▶ cd ~
~|▶ 
~|▶ sudo mount | grep home
/dev/sda3 on /home type ext4 (rw,relatime,seclabel)
/|▶ getent passwd $USER
daniel:x:1000:1000:Daniel:/home/daniel:/bin/zsh
/|▶ ls -lZ $HOME
total 68
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 May 25 18:59 Desktop
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Aug  5 20:36 Documents
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Sep  5 11:35 Downloads
drwx------. 15 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Sep 13 13:37 Dropbox
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 May 25 18:59 Music
drwxr-xr-x.  2 daniel daniel system_u:object_r:fusefs_t:s0            0 Jan  1  1970 notes
drwxrwxr-x.  4 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Sep 13 14:39 org
-rw-rw-r--.  1 daniel daniel unconfined_u:object_r:unlabeled_t:s0 17311 Sep 13 13:10 out.out
drwxr-xr-x.  3 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Sep  1 17:58 Pictures
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 May 25 18:59 Public
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 May 25 18:59 Templates
drwxrwxr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Aug 29 21:03 tmp
drwxr-xr-x.  2 daniel daniel unconfined_u:object_r:unlabeled_t:s0  4096 Aug 29 18:40 Videos

我正在執行 Fedora Linux 32

任何幫助將不勝感激!

看起來當您創建新的 /home 目錄時,它沒有被標記為主目錄,因此當您登錄時,selinux 會禁止您的會話訪問它。登錄後,您可以 cd 進入它,但它的標籤錯誤。

以 root 身份執行restorecon以解決此問題:

# restorecon -r -v /home

引用自:https://unix.stackexchange.com/questions/609225