1
我對SHELL腳本非常新鮮。我不知道是否有人可以解釋我,我怎樣才能將用戶轉換成願望組。我想什麼 腳本是這樣的:如何爲usermod製作shell腳本
$ ./sample_script
這將檢查/etc/passwd
並列出用戶名這樣
1. user1
2. user2
3. user3
4. user4
然後:
Enter the username : 1
然後,腳本會問
What do you want to do (Deny or Grant)? : deny
如果用戶選擇user1
或user2
,該腳本將使用 sudo usermod -G DENY_GROUP USER_NAME
或 sudo usermod -G ACCESS_GROUP USER_NAME
和 打印這樣的輸出:
"User1 is successfully denied or granted"
如果用戶選擇user3
或user4
,該腳本將打印輸出是這樣的:
"You don't have a permission to deny the user3 or user4. Please contact your
administrator."
初學者有許多shell教程。嘗試使用它們編寫代碼並返回到具有更具體問題的SO。 (堆棧溢出不是代碼編寫器服務。) – Tsyvarev