这节描述你需要知道有些程式在安装时就已经有 Shadow Suite。大部分的资讯在操作手册可以找到。

7.1 新增、修改和删除使用者

Shadow Suite 新增下列指令用来新增、修改和删除使用者。 这也是可以安装 adduser 程式。

useradd

useradd 使令可用在系统中新增使用者。 你也可以采用此指令来改变预设字串。

你应该做的第一件事是检查预设值设定和针对你的系统进行改变:

useradd -D

GROUP=1

HOME=/home

INACTIVE=0

EXPIRE=0

SHELL=

SKEL=/etc/skel

预设值不全是你要的,所以如果你开始新增使用者,你必须详阅每个使用者资讯。而且,我们可能和应该改变设定值。

在我的系统上:

我要预设群组是 100

我要密码每到 60 天就到期

我不要锁住帐号因为密码会到期

我要预设 shell 是 /bin/bash

为了这些改变,我要使用:

useradd -D -g100 -e60 -f0 -s/bin/bash

现在执行 useradd -D 将得到:

GROUP=100

HOME=/home

INACTIVE=0

EXPIRE=60

SHELL=/bin/bash

SKEL=/etc/skel

尽管依照你需要修改,预设值将存在 /etc/default/useradd.

先在你可以使用 useradd 来新增系统使用者。举例说明,新增一使用者 fred 使用预设值方式如下:

useradd -m -c "Fred Flintstone" fred

这将在 /etc/passwd 档中的一行建立如下:

fred:*:505:100:Fred Flintstone:/home/fred:/bin/bash

且在 /etc/shadow 档中的一行建立如下;

fred:!:0:0:60:0:0:0:0

fred的根目录将被建立且 /etc/skel 的内容将被复制因为指令句中有 -m 设定。

因为我们并未详述 UID,系统会直接寻找下一个可获得的编号。

fred的帐号被建立罗,但是 fred 仍然不能签入直到我们不再锁住(unlock)这个帐号。透过更改密码完成 unlock 帐号,方法如下:

passwd fred

Changing password for fred□Enter the new password (minimum of 5 characters)

Please use a combination of upper and lower case letters and numbers.

New Password: *******

Re-enter new password: *******

现在 /etc/shadow 档将包含:

fred:J0C.WDR1amIt6:9559:0:60:0:0:0:0

且 fred 将可以签入和使用该系统。 useradd 和其他附带 Shadow Suite 比较好的地方是可以自动改变 /etc/passwd 和 /etc/shadow 。 所以如果你正在新增一个使用者,且另一个使用者正在更改密码,这两个操作都可以正确的执行。

你使用提供的指令比直接存取 /etc/passwd 和 /etc/shadow 档还好。 如果你正编辑 /etc/shadow 档,且有个使用者在你编辑时要改变他的密码,然後你储存编辑结果,这个使用者的密码将会遗失掉。

这里是使用 useradd 和 passwd 新增使用者的一些 interactive script :

#!/bin/bash

#

# /sbin/newuser - A script to add users to the system using the Shadow

# Suite's useradd and passwd commands.

#

# Written my Mike Jackson as an example for the Linux

# Shadow Password Howto. Permission to use and modify is expressly granted.

#

# This could be modified to show the defaults and allow modification similar

# to the Slackware Adduser program. It could also be modified to disallow

# stupid entries. (i.e. better error checking).

#

##

# Defaults for the useradd command

##

GROUP=100 # Default Group

HOME=/home # Home directory location (/home/username)

SKEL=/etc/skel # Skeleton Directory

INACTIVE=0 # Days after password expires to disable account (0=never)

EXPIRE=60 # Days that a passwords lasts

SHELL=/bin/bash # Default Shell (full path)

##

# Defaults for the passwd command

##

PASSMIN=0 # Days between password changes

PASSWARN=14 # Days before password expires that a warning is given

##

# Ensure that root is running the script.

##

WHOAMI=`/usr/bin/whoami`

if [ $WHOAMI != "root" ]; then

echo "You must be root to add news users!"

exit 1

fi

##

# Ask for username and fullname.

##

echo ""

echo -n "Username: "

read USERNAME

echo -n "Full name: "

read FULLNAME

#

echo "Adding user: $USERNAME."

#

# Note that the "" around $FULLNAME is required because this field is

# almost always going to contain at least on space, and without the "'s

# the useradd command would think that you we moving on to the next

# parameter when it reached the SPACE character.

#

/usr/sbin/useradd -c"$FULLNAME" -d$HOME/$USERNAME -e$EXPIRE \

-f$INACTIVE -g$GROUP -m -k$SKEL -s$SHELL $USERNAME

##

# Set password defaults

##

/bin/passwd -n $PASSMIN -w $PASSWARN $USERNAME >/dev/null 2>&1

##

# Let the passwd command actually ask for password (twice)

##

/bin/passwd $USERNAME

##

# Show what was done.

##

echo ""

echo "Entry from /etc/passwd:"

echo -n " "

grep "$USERNAME:" /etc/passwd

echo "Entry from /etc/shadow:"

echo -n " "

grep "$USERNAME:" /etc/shadow

echo "Summary output of the passwd command:"

echo -n " "

passwd -S $USERNAME

echo ""

【责编:admin】

--------------------next---------------------

阅读(195) | 评论(0) | 转发(0) |

linux shadow 时间,Linux Shadow-Password-HOWTO - 7. 将 Shadow Suite 放进来使用(1)相关推荐

  1. linux '$^t' 时间,Linux C时间函数 time_t struct tm

    Linux C时间函数 time_t struct tm #include 关于时间的类型: time_t long型,表示从1970年1月1日到现在经过的秒数. struct tm { int tm ...

  2. 怎么查看linux自动校验时间,linux校验时间

    一. 基本方法: date -s "2018-09-02 04:23:45" clock -w 把时间写入cmos(一个RAM芯片) hwclock 查看硬件时间 hwclock ...

  3. linux real时间,Linux Realtime

    Linux Realtime 何谓实时系统: POSIX 1003.b 定义:系统能够在限定的响应时间内提供所需的服务 Donald Gillies 的定义: 计算的正确性不仅取决于程序的逻辑正确性, ...

  4. 使用命令修改linux的时间,Linux使用date命令修改日期时间详解

    Linux 时间修改 不重启修改时区 一.修改linux的时间 root使用date指令:date -s 1.只修改日期,不修改时间,输入: Linux代码 date -s 2007-08-03 2. ...

  5. linux est 时间,Linux 时间标准简介

    系统如何设置时间 开机时根据硬件时钟来设置系统时钟. 如果开启了 NTP 服务, 会根据网络时间来校正系统时钟,确保时间准确. 关机时会根据系统时钟来设置硬件时钟(localtime 标准除外). 时 ...

  6. linux superblock 时间,Linux命令(八)

    1.文件系统:windows的FAT,win2000以后的NTFS文件系统,Linux的正规文件系统为EXT2(Linux second extended file system,Ext2fs)传统方 ...

  7. linux est 时间,Linux中的时区设置

    我通过将zoneinfo文件复制到/ etc / localtime,在我的Linux机器上将时区设置为GMT 6,但是date命令仍然将时间显示为UTCtime-6.任何人都可以向我解释这种行为吗? ...

  8. linux cfs时间,Linux调度的实现(CFS)——虚拟时间计算

    公平调度(CFS)基本概念与性质 公平调度:每个进程能获得1/n的处理器时间,n指可运行的进程的数量: (允许每个进程运行一段时间,循环轮转,选择运行最少的进程作为下一个运行进程.) 每个进程都按照它 ...

  9. linux timewait 时间,linux下释放TIME_WAIT方法

    今天服务网站明显过慢查年了一下服务器联接数,纠结于怎么搞定TIME_WAIT # netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c 68 CLOSE_WA ...

最新文章

  1. Pytest - 使用介绍
  2. Python实训day09pm【Python处理Excel实际应用】
  3. 使用@Configuration注解来代替Spring的bean配置
  4. java 面试心得总结-BAT、网易
  5. oracle EBS grant 您不具有执行当前操作的足够权限。请与您的系统管理员联系。...
  6. C++ STL 容器 string
  7. SpaceVim 1.1.0 发布,模块化 Vim IDE
  8. 去除报错_转录组分析 | 使用trimgalore去除低质量的reads和adaptor
  9. 非常实用的,使用SQL查询连续号码段。(做计费系统或SP的兄弟经常会用到)...
  10. Linux C编程Makefile编写初步-转
  11. excel文件修复工具_OFFICE文件图标空白的修复方法(亲测有效)
  12. 《人生哲理》二.人生苦短,别懂得太晚了...
  13. 计算机win10下常用命令验证性实验
  14. 通过主成分分析实现三维模型对齐【Principal Component Analysis】
  15. 迪士尼机器人芭蕾舞_两个自由度实现惊艳后空翻 迪士尼杂技机器人献拿手好戏...
  16. 树莓派4b常用资料汇总
  17. DirectShow入门
  18. 淘宝爬虫实战(附代码和数据集)——今天你脱发了吗?
  19. MVG(0)——wt is MVG
  20. hoj 2715 (费用流 拆点)

热门文章

  1. C语言scanf函数奇遇记
  2. ASP.NET使用数据库存储、读取并修改图片
  3. 普通电阻触摸屏多点触摸低成本解决方 转载
  4. 深入理解C# 3.x的新特性(2):Extension Method[下篇]
  5. 计算机视觉——简介以及人脸数目检测
  6. Leetcode--1014. 最佳观光组合(java)
  7. Spring AOP解析
  8. mysql不同的类的个数_Mysql数据库-SQL优化-统计某种类型的个数
  9. shell for循环1到100_浅谈Linux下shell 编程的for循环常用的6种结构
  10. python利用自动识别写模块_教你用Python 实现自动导入缺失的库