Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the script for Shell automatic management account

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how to write the script of Shell automatic management account, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe you will gain something after reading this script of Shell automatic management account. Let's take a look.

The purpose of this script is to help administrators create accounts, delete accounts, lock accounts, and unlock accounts.

#! / bin/bash#filename:#author:#date:2018-6-6echo "user Manager" echo "1. Create the user "echo" 2. Delete the user "echo" 3. Lock user "echo" 4. Unlock user "echo" 5. To exit the script "read-p", please enter your operation selection (1-5): "sncase $sn in1) read-p" Please enter the creation user name: "nuuseradd $nuecho" 123456 "| passwd-- stdin $nuif ['$?'='0']; thenecho" user has been created successfully "exit fi;;2) read-p" enter the user name to delete: "nluserdel $nlecho" has deleted the $nl user "if [$?-ne 0]; thenecho" deleted "fi successfully 3) STAT=$ (passwd-S $use | awk'{print $2}') read-p "locked user" useif ['$STAT' = = "PS"]; thenpasswd-l $usefiif ['$STAT' = = "LK"]; thenecho "locked user" exitfi;;4) read-p "unlocked user" jieecho $jieif ['$STAT' = = "LK"]; thenpasswd-u $jiefiif ['$STAT' = "LK"]; thenecho "unlocked user" exitfi;;5) if [$sn = = 5] Thenread-p "yes or not" tuif [$tu = = yes]; this is the end of then exitfifiesac's article on "how to write scripts for Shell automated management accounts". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to write scripts for Shell automated management accounts". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report