1、使用ansible安装httpd、mysql、php服务
方法一:命令 ansible web -a "yum install -y httpd mysql php*" 方法二:使用模块 ansible web -m yum -a "name=httpd" ansible web -m yum -a "name=mysql" ansible web -m yum -a "name=php*" 方法三:playbook vi lamp.yml
- hosts: web
remote_user: root
tasks:
- name: install lamp yum: name={{ item }} with_items:
- httpd
- mysql
- php*
2、使用sed命令,将/etc/passwd的/bin/bash替换为/sbin/nologin
sed -ne -i "s//bin/bash//sbin/nologin/g" passwd
3、查看/etc/passwd文件有多少行(三种)
cat -n /etc/passwd grep -n "" /etc/passwd sed -n "=" /etc/passwd
4、写一个脚本,实现判断192.168.80.0/24网络里,当前在线的IP有哪些,能ping通则认为在线
vi shell.sh #!/bin/bash for ip in 192.168.80.{1..254} do ping -c3 -w0.1 $ip &> /dev/null if [ $? -eq 0 ];then echo "$ip 存活" else echo "$ip 不存活" fi done
5、压缩、解压、查看源码包的内容
tar cjvf/czvf 自定义压缩包名称 要压缩的内容 tar xf 压缩包 -C 目的目录 tar tjvf/tzvf 压缩包