错误代码
-bash: /dev/null: Permission denied
解决方法
# rm -f /dev/null;mknod /dev/null c 1 3;chmod 666 /dev/null
-bash: /dev/null: Permission denied
# rm -f /dev/null;mknod /dev/null c 1 3;chmod 666 /dev/null
作者:朱明宇
名称:批量修改多个远程服务器某个用户的密码
作用:批量修改多个远程服务器某个用户的密码
1. 将此脚本和清单 $list 文件放在同一目录下
2. 清单 $list 里每服务器名占用 1 行
3. 给脚本分割线里的变量赋值
4. 给此脚本添加执行权限
5. 执行此脚本
1. list=”list.txt” #指定清单的目录和名称
2. user=eternalcenter #指定要修改密码的用户
3. password=eternalcenter #指定要修改的密码
此脚本执行前必须要先保证执行本脚本的用户能无密码 ssh 远程这些远程服务器,并且可以通过 sudo 获得 su 的 root 权限
#!/bin/bash
####################### Separator ########################
list="list.txt"
user=eternalcenter
password=eternalcenter
####################### Separator ########################
num=1
cat $list
for i in `cat $list`
do
echo $num
echo $i
ssh -t $i "type lsb_release" &> /dev/null
if [ $? -ne 0 ]; then
distribution=`ssh -t $i "cat /etc/*release | grep '^NAME'"`
if [ $? -ne 0 ];then
distribution=`ssh -t $i "cat /etc/*release"`
fi
else
distribution=`ssh -t $i "lsb_release -i | grep 'ID' | grep -v 'n/a'"`
fi;
echo $distribution
case $distribution in
*"RedHat"* | *"Red Hat"*)
ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
if [ $? -eq 0 ];then
echo -e "\033[32m$i is success\033[0m"
else
echo -e "\033[31m$i is fail\033[0m"
fi
;;
*"CentOS"*)
ssh -t $i "sudo -u root su - root -c \"echo $password | passwd --stdin $user\""
if [ $? -eq 0 ];then
echo -e "\033[32m$i is success\033[0m"
else
echo -e "\033[31m$i is fail\033[0m"
fi
;;
*"SUSE"* | *"SLES"*)
ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
if [ $? -eq 0 ];then
echo -e "\033[32m$i is success\033[0m"
else
echo -e "\033[31m$i is fail\033[0m"
fi
;;
*"openSUSE"*)
ssh -t $i "sudo -u root su - root -c \"echo $user:$password | chpasswd\""
if [ $? -eq 0 ];then
echo -e "\033[32m$i is success\033[0m"
else
echo -e "\033[31m$i is fail\033[0m"
fi
;;
*)
echo -e "\033[31m$i is fail \033[0m"
;;
esac
let num++
echo
done
1) -b 排序时忽略每行前面的空格
2) -c 检查是否已排序
3) -f 排序时忽略大小写字母
4) -n 按照数值到大小进行排序
5) -o 将排序结果导入到指定文件
6) -r 以相反的顺序进行排序
7) -t 指定排序的分隔符
8) -k 以指定的列进行排序
# cat test.txt
3
5
4
2
1
# sort -c test.txt
sort: test.txt:3: disorder: 4
(补充:这里以检查 test.txt 文件里的排列为例)
# cat test.txt
3
5
4
2
20
1
# sort -n test.txt
1
2
3
4
5
20
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
c
e
d
b
a
# sort test.txt
a
b
c
d
e
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
c
e
d
b
a
# sort -r test.txt
e
d
c
b
a
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
3 d
5 c
4 a
2 e
1 b
# sort test.txt
1 b
2 e
3 d
4 a
5 c
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
3 d
5 c
4 a
2 e
1 b
# sort -k2 test.txt
4 a
1 b
5 c
3 d
2 e
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
10.0.200.10
172.16.50.10
192.168.100.1
192.168.100.10
172.16.50.1
10.0.200.1
# sort test.txt
10.0.200.1
10.0.200.10
172.16.50.1
172.16.50.10
192.168.100.1
192.168.100.10
(补充:这里以排列 test.txt 文件里的列为例)
# cat test.txt
10.0.200.10
172.16.50.10
192.168.100.1
192.168.100.10
172.16.50.1
10.0.200.1
# sort -t'.' -k3n test.txt
172.16.50.1
172.16.50.10
192.168.100.1
192.168.100.10
10.0.200.1
10.0.200.10
(补充:这里以排列 test.txt 文件里的列为例)
<command> &> <file>
或者:
<command> >& <file>
<command> 1> <file>
或者:
<command> > <file>
<command> 2> <file>
<command> &>> <file>
或者:
<command> >>& <file>
<command> 1>> <file>
或者:
<command> >> <file>
<command> 2>> <file>
<command> 2&>1
或者:
<command> 2>&1
<command> 1&>2
或者:
<command> 1>&2
<command> &> /dev/null
或者:
<command> &>> /dev/null
或者:
<command> >& /dev/null
或者:
<command> >>& /dev/null
或者:
<command> 1> /dev/null 2>&1
或者:
<command> 1>> /dev/null 2>&1
或者:
<command> 1> /dev/null 2>>&1
或者:
<command> 1>> /dev/null 2>>&1
或者:
<command> 2> /dev/null 1>&2
或者:
<command> 2>> /dev/null 1>&2
或者:
<command> 2> /dev/null 1>>&2
或者:
<command> 2>> /dev/null 1>>&2
(补充:通过此种方法输出信息就既不会显示出来也不会被重定向到一个文件里)
30 年前的今天,Linux 诞生了。
作为一款可免费使用和自由传播的开源操作系统,自由、平等、博爱、公开、共享、人人皆可参与、属于每一个人的开源精神和理念,让全世界各地的非盈利性机构、爱好者、从业人员、公司和政府部门都能够参与进来,共同促进它的进步。
随着时间的推移,由美国国家航天局 (NASA) 创建的 OpenStack 云计算平台、由 Docker 公司创建的容器技术等,一个个极具革命性的创新基于 Linux 诞生。这些创新空前提高了互联网行业的创新效率和生产效率,并附带提高了其他几乎所有行业的生产力,让地球上所有的人类都离贫困更远,生活也变得更加丰富多彩。
Linux 如今已成为了无国界操作系统的代名词,同时也是当今互联网行业的基础。