Linux基础命令---htpasswd

简介: htpasswd htpasswd指令用来创建和更新用于基本认证的用户认证密码文件。htpasswd指令必须对密码文件有读写权限,否则会返回错误码。 此命令的适用范围:RedHat、RHEL、Ubuntu、CentOS、Fedora。

htpasswd

   htpasswd指令用来创建和更新用于基本认证的用户认证密码文件。htpasswd指令必须对密码文件有读写权限,否则会返回错误码。
   此命令的适用范围:RedHat、RHEL、Ubuntu、CentOS、Fedora。

1、语法

   htpasswd  [ -c ]  [ -m ]  [ -D ]  passwdfile username
   htpasswd  -b  [ -c ]  [ -m | -d | -p | -s ] [ -D ]  passwdfile  username  password
   htpasswd  -n  [ -m | -d | -s | -p ]  username
   htpasswd  -nb  [ -m | -d | -s | -p ]  username  password

2、参数列表

   -b
          使用批处理方式,直接从命令行获取密码,不提示用户输入
   -c
          创建密码文件,如果文件存在,那么内容被清空重写
   -n
          将结果送到标准输出
   -m
          使用MD5加密
   -s
          使用crypt()加密
   -p
          使用文本密码
   -D
          从认证文件中删除用户记录

3、实例
1)创建基本认证文件

   [root@localhost ~]# htpasswd -cm htpfile1 weijie        //创建认证文件,使用md5加密
   New password: 
   Re-type new password: 
   Adding password for user weijie 
   You have new mail in /var/spool/mail/root
   [root@localhost ~]# cat htpfile1                           //显示认证文件
   weijie:$apr1$/RxQ5LT9$L1WJPkxknMizG5DwGVGv4.

2)创建基本认证文件,使用文本密码

   [root@localhost ~]# htpasswd -cp htpfile2 weijie       //创建认证文件,使用文本密码
   Warning: storing passwords as plain text might just not work on this platform.
   New password: 
   Re-type new password: 
   Adding password for user weijie
   [root@localhost ~]# cat htpfile2                           //查看认证文件,可以看到密码
   weijie:123456
  做了一个Linux学习的平台,目前出来一个雏形,各位可以参考使用
  链接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密码:n7bk 
相关文章
|
5天前
|
机器学习/深度学习 缓存 监控
linux查看CPU、内存、网络、磁盘IO命令
`Linux`系统中,使用`top`命令查看CPU状态,要查看CPU详细信息,可利用`cat /proc/cpuinfo`相关命令。`free`命令用于查看内存使用情况。网络相关命令包括`ifconfig`(查看网卡状态)、`ifdown/ifup`(禁用/启用网卡)、`netstat`(列出网络连接,如`-tuln`组合)以及`nslookup`、`ping`、`telnet`、`traceroute`等。磁盘IO方面,`iostat`(如`-k -p ALL`)显示磁盘IO统计,`iotop`(如`-o -d 1`)则用于查看磁盘IO瓶颈。
|
1天前
|
监控 Linux Windows
50个必知的Linux命令技巧,你都掌握了吗?(下)
50个必知的Linux命令技巧,你都掌握了吗?(下)
|
2天前
|
Linux Shell Windows
Linux 常用基本命令
Linux 常用基本命令
|
2天前
|
Ubuntu Linux Shell
linux免交互登陆远程主机并执行命令(密钥对和Expect)
linux免交互登陆远程主机并执行命令(密钥对和Expect)
|
2天前
|
Linux
【Linux】常用命令
【Linux】常用命令
22 0
|
2天前
|
安全 Ubuntu Linux
Linux 网络操作命令Telnet
Linux 网络操作命令Telnet
16 0
Linux 网络操作命令Telnet
|
4天前
|
Linux 数据安全/隐私保护
Linux常用命令实例带注释
Linux常用命令实例带注释
30 0
|
4天前
|
Linux 开发工具 数据安全/隐私保护
Linux(19)常用解压命令记录
Linux(19)常用解压命令记录
9 0
|
5天前
|
Linux Perl
Linux系统替换字符串常用命令
请注意,`sed`命令可以非常强大,可以根据不同的需求使用不同的选项和正则表达式来进行更复杂的字符串替换操作。
17 0
|
8天前
|
安全 Linux 开发工具
Linux中可引起文件时间戳改变的相关命令
【4月更文挑战第12天】Linux中可引起文件时间戳改变的相关命令
18 0