2020年10月21日 星期三

在Linux, BSD用newgrp切換使用者群組

UNIX-like系統的使用者會有一個名稱,預設還會屬於登入名稱相同的群組。除此以外,同個使用者還可以隸屬於不同的群組。要確認並選用不同的群組請用下面指令:

  • groups
    顯示目前使用者可用的所有群組,列在前面的就是目前使用的群組
  • id
    顯示目前使用者的uid與可用群組的gid
    uid開頭的代表目前的使用者id,gid開頭的代表目前使用者的群組id,其他groups開頭的代表可用的群組
  • newgrp groupA
    切換到groupA這個群組。要離開的話使用exit指令
  • newgrp
    跳回原本預設的群組,但其實是開個新shell回去

newgrp這個指令切換群組的方式為在目前運行的shell上面再開一個新的shell,而不僅僅只是切換預設群組,故要回到原本預設狀態的做法應該是使用exit指令跳回去。因為這個特性,故若將newgrp指令用在啟動shell的設定檔如.profile, .bashrc等等,可能會造成登入後環境跑掉沒辦法用的狀況,這點要特別注意。


參考資料

_EOF_

A ultradetailed beautiful concept art of the crystal formation of the prismatic crystal of hope is filled with the wonderful colors of the emotion around it in a forgotten cave lighten by the moon light and reflecting on the surface of a quiet lake, concept art, high resolution, 4k, by Artgerm

Steps: 23, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 231202, Size: 512x256, Model hash: fc2511737a, Model: chilloutmix_NiPrunedFp32Fix, Version: v1.6.1

Time taken: 1 min. 24.9 sec. on Nvidia MX550
A: 1.70 GB, R: 2.26 GB, Sys: 2.0/2 GB (100.0%)

沒有留言:

張貼留言