
运维服务
docker离线安装
一、准备工作:确认架构并下载安装包 1.1 确认目标服务器架构 在目标服务器上执行以下命令,确认系统架构: 输出 x8664:对应 amd64 架构(Intel/AMD 64位服务
[root@localhost wulaoer]# echo $RANDOM 7301 [root@localhost wulaoer]# echo $RANDOM 28663如果想使用$RANDOM变量随机范围,例如:$(($RANDOM%27))表示0到26的范围数,是对27取模,最少是0,最大是26. 如果想获取十以内的整数,可以取模10,最大9,最少0,也就是一位数。
[root@localhost wulaoer]# echo $(($RANDOM%10)) 2如果想取两位数的随机数,只需要把10变成100即可
[root@localhost wulaoer]# echo $(($RANDOM%100)) 89取一段随机范围,先看下面的例子:
[root@localhost wulaoer]# echo $(($RANDOM%40+1))这里要分开解释,首先是$(($RANDOM%40))取值范围是0到39,我们加1取的最大值就是40,最小值就是1。取值范围是1到40之间。再看下面的例子:
[root@localhost wulaoer]# echo $(($RANDOM%40+8))这个首先是取值范围是0到39,加8后取最大值是47,最小值是8. 这是使用$RANDOM变量取的整数,如果想获取四位数的整数可以参考上面的方法:
[root@localhost wulaoer]# echo $(($RANDOM%9000+1000)) 4444给文件进行排序,然后查看最大的整数
[root@localhost wulaoer]# sort -n a.txt .................... 9999 9999 9999 9999
[root@localhost wulaoer]# tr -dc "0-9" < /dev/urandom | head -c 10 5015464913[root@localhost wulaoer]# [root@localhost wulaoer]# head /dev/urandom | tr -dc 0-9 | head -c 10 6074787303[root@localhost wulaoer]#tr -dc "0-9"中"0-9"表示随机生成的数,head -c 10中的10表示随机生成数的长度。
[root@localhost wulaoer]# head /dev/urandom | cksum 1750151684 3829 [root@localhost wulaoer]# head /dev/urandom | cksum | cut -c 1-10 #截取指定长度的数字 3396223911
[root@localhost wulaoer]# yum -y install openssl [root@localhost wulaoer]# yum -y install openssl-devel安装之后我们使用openssl获取随机数字
[root@localhost wulaoer]# openssl rand -base64 12 | md5sum | tr [a-z] [0-9] 12010481315217752390273300548115 - [root@localhost wulaoer]# openssl rand -base64 12 | md5sum | tr [a-z] [0-9] | cut -c 1-10 #截取指定长度的数字 5863131743 [root@localhost wulaoer]# openssl rand -base64 12 | md5sum | tr [a-z] [A-Z] | cksum |cut -f1 -d" " 1661552658 [root@localhost wulaoer]# openssl rand -base64 12 | md5sum | cksum |cut -c 1-10 2750913654
[root@localhost wulaoer]# date +%s |cksum |cut -d " " -f 1 2373423463
[root@localhost wulaoer]# cat /proc/sys/kernel/random/uuid c047c004-5bf3-401d-9889-1104121c11f0我们使用cksum |cut -f1 -d" "处理一下就只有数字没有其他符合和字母了
[root@localhost wulaoer]# cat /proc/sys/kernel/random/uuid| cksum |cut -f1 -d" " 655970218
[root@localhost wulaoer]# yum install expect -y安装成功之后,我们就可以使用mkpasswd命令了,不过mkpasswd命令需要参数,5个参数都不能少
-l 指定密码长度 -d 指定密码中数字的数量 -c 指定密码中小写字母的数量 -C 指定密码中大写字母的数量 -s 指定密码中特殊字符的数量举例说明一下:
[root@localhost wulaoer]# mkpasswd -l 10 -d 10 -c 0 -C 0 -s 0 #数字的数量必须和长度一致 0083600057 [root@localhost wulaoer]# mkpasswd -l 10 -d 10 -c 0 -C 0 -s 0 3063494459注:mkpasswd的五个参数必须同时使用,少一个参数就会报错
[root@localhost wulaoer]# mkpasswd -l 10 -d 4 -c 2 -C 2 -s 0 #没有特殊字符 Ci46o3qG1g [root@localhost wulaoer]# mkpasswd -l 10 -d 4 -c 2 -C 0 -s 2 #没有大写 o0#x7^me99 [root@localhost wulaoer]# mkpasswd -l 10 -d 4 -c 0 -C 2 -s 2 #没有小写 U!m94y2Z;9
[root@localhost wulaoer]# tr -dc "a-z0-9" < /dev/urandom | head -c 10 2sylhng0tb[root@localhost wulaoer]# [root@localhost wulaoer]# [root@localhost wulaoer]# tr -dc "A-Z0-9" < /dev/urandom | head -c 10 SMCC172HLR[root@localhost wulaoer]# tr -dc "A-Za-z0-9" < /dev/urandom | head -c 10 OvUFPTV7Ev [root@localhost wulaoer]# tr -dc "A-Za-z0-9#@" < /dev/urandom | head -c 10 #FKTf0Lbyw
[root@localhost wulaoer]# openssl rand -hex 10 5ab5974411a74d316701 [root@localhost wulaoer]# openssl rand -base64 12 | md5sum | tr [a-z] [A-Z] | cut -c 1-10 #截取指定长度的数字 0318E45622这里没有看到支持特殊字符的方法,后期找到在补上。
[root@localhost wulaoer]# yum install -y epel-release [root@localhost wulaoer]# yum -y install pwgen参数:
-c或–capitalize密码中至少包含一个大写字母 -A或–no-capitalize密码中不包含大写字母 -n或–numerals密码中至少包含一个数字 -0或–no-numerals密码中不包含数字 -y或–symbols密码中至少包含一个特殊符号 -s或–secure生成完全随机密码 -B或–ambiguous密码中不包含歧义字符(例如1,l,O,0) -H或–sha1 =路径/到/文件[#seed]使用SHA1哈希给定的文件作为一个随机种子 -C在列中打印生成的密码 -1不要在列 打印生成的密码,即一行一个密码 -v或-no元音不要使用任何元音,以避免偶然的脏话看下例子:
[root@localhost wulaoer]# pwgen 14 1 -n 14 bieN0oocei9Ish [root@localhost wulaoer]# pwgen 14 1 -n 4 -A 3 paqu0heek7veic [root@localhost wulaoer]# pwgen 14 1 -n 4 -c aithu9eiHe3ohv
[root@localhost wulaoer]# cat /proc/sys/kernel/random/uuid 7d9d00fa-e00f-48e1-9ede-e4afa679aaff [root@localhost wulaoer]# cat /proc/sys/kernel/random/uuid 584db186-5cc6-4a35-8a80-6b070a3379f0方法六:使用/dev/urandom
[root@localhost wulaoer]# tr -dc "a-z" < /dev/urandom | head -c 10 #小写字符 npowcyeipp[root@localhost wulaoer]# tr -dc "A-Z" < /dev/urandom | head -c 10 #大写字符 VBAIMBKLBO[root@localhost wulaoer]# tr -dc "A-Za-z0-9" < /dev/urandom | head -c 10 #生成大小写和数字的字符串 [root@localhost wulaoer]# tr -dc "A-Za-z0-9#@" < /dev/urandom | head -c 10 #生成大小写和数字以及特殊字符的字符串 SO5OPLy#rT
[root@localhost wulaoer]# date +%s| md5sum | tr -dc "a-z" |head -c 10 #小写字符 bacbaccabb [root@localhost wulaoer]# date +%s| md5sum | head -c 10 #数字和字母组合字符串 12925185d4 [root@localhost wulaoer]# date +%s| md5sum | tr -dc "a-z0-9" |head -c 10 #小写和数字组合 dc6b4aa924因date就是打印字符串的,所以没有大写组合。
评论 0