1 創建用戶且指定該用戶的根路徑和密碼
useradd -d /home/mydir -m username
這種方式創建的用戶可以使用ssh登錄,但只有只讀權限可以瀏覽下載部分文件無法寫和修改。
建議通過將用戶加入一個組來獲得指定路徑的權限。
2 設置密碼
passwd username
3 用戶授權
chown -R username: username /home/ mydir
chmod 755 /home/mydir
4 將用戶加入到組
將一個用戶添加到用戶組中,儘量不要直接用(除非確實是只屬於一個組):
usermod -G groupA username
這樣做會使你離開其他用戶組,僅僅做爲這個用戶組 groupA 的成員。
應該用 加上 -a 選項:
usermod -a -G groupA username
查看用戶所屬的組使用命令
groups username