服务器需要提供给大家一人一个账号进行教学.
忙了了天,才算初步完成了系统管理的第一步.
首先声明,GOOGLE我已经几乎搜遍相关问题,不过真正能解决问题的少得可以忽略!!
创建账号脚本:
删除账号脚本
计算账号个数脚本
至于name文件,就是存放账号名的,一行一个
在创建好账号后,出现了问题
普通用户不能自己修改密码.
查了太多资料,虽然没帮我解决问题,但还是慢慢启发了我
解决方法很简单.
脚本都很简单,我就不详细解释了.
如果需要做到帐号之间的隔离,即 互相没有读写权限。
可以每个帐号就为一组。
把useradd 的-g users删除就可以实现了。
忙了了天,才算初步完成了系统管理的第一步.
首先声明,GOOGLE我已经几乎搜遍相关问题,不过真正能解决问题的少得可以忽略!!
创建账号脚本:
CODE:
#!/bin/bash
#This is gnuser's first Bash Shell program
#Today the BOSS tell me to manage the server PC
#First ,I must remove all of the previous accounts
#Second ,I must create all of the classmates' accounts use of their names
pswd=`perl -e ' { printf crypt("123456","ab") . "/n" }'`
for i in `cat name`
do
useradd -m -g users -s /bin/bash -p $pswd "$i"
sleep 1
done
#This is gnuser's first Bash Shell program
#Today the BOSS tell me to manage the server PC
#First ,I must remove all of the previous accounts
#Second ,I must create all of the classmates' accounts use of their names
pswd=`perl -e ' { printf crypt("123456","ab") . "/n" }'`
for i in `cat name`
do
useradd -m -g users -s /bin/bash -p $pswd "$i"
sleep 1
done
删除账号脚本
CODE:
#!/bin/bash
#This is gnuser's first Bash Shell program
#Today the BOSS tell me to manage the server PC
#First ,I must remove all of the previous accounts
#Second ,I must create all of the classmates' accounts use of their names
for i in `cat name`
do
userdel -r "$i"
sleep 1
done
#This is gnuser's first Bash Shell program
#Today the BOSS tell me to manage the server PC
#First ,I must remove all of the previous accounts
#Second ,I must create all of the classmates' accounts use of their names
for i in `cat name`
do
userdel -r "$i"
sleep 1
done
计算账号个数脚本
CODE:
#! /bin/sh
for i in `cat name`
do
let j=j+1
done
echo $j
for i in `cat name`
do
let j=j+1
done
echo $j
至于name文件,就是存放账号名的,一行一个
在创建好账号后,出现了问题
普通用户不能自己修改密码.
查了太多资料,虽然没帮我解决问题,但还是慢慢启发了我
解决方法很简单.
CODE:
chmod u+s /usr/bin/passwd
脚本都很简单,我就不详细解释了.
如果需要做到帐号之间的隔离,即 互相没有读写权限。
可以每个帐号就为一组。
把useradd 的-g users删除就可以实现了。