shell-h # 帮助信息 --help # 帮助信息 man # 命令手册
shellgroupadd tester # 创建用户组 useradd -g tester tester # 创建用户 passwd tester # 设置密码 useradd -g apache -s /sbin/nologin apache # 创建apache用户,并且不允许登录 usermod -s /bin/bash apache # 恢复apache用户的登录权限
shellusermod -g tester tester # 将用户加入组 userdel tester # 删除用户 groupdel tester # 删除用户组
shellsu tester
shellvi test.txt # 创建并编辑文件 mkdir /var/www # 创建目录 mkdir -p /var/www/website # 创建父目录 rm test.txt # 删除文件 rm -fr /var/www # 强制删除目录
shellmv test.txt test.sh # 重命名文件 mv /var/www /var/wwwroot # 重命名目录
shellcp test.txt test.sh # 复制文件 cp -r /var/www /var/wwwroot # 复制目录 scp test.txt root@192.168.1.2:/var/www/ # 远程复制文件 scp -r root@192.168.1.2:/var/www /var/wwwroot # 远程复制目录 \scp -fr root@192.168.1.2:/var/www /var/wwwroot # 远程复制目录,用重复则覆盖
shellcat text.txt # 输出全部内容
tail -n text.txt # 输出文件尾部几行
head -n text.txt # 输出文件头部几行
sed -n '200,300p' text.txt # 输出文件200行-300行
echo 'test' >> text.txt # 替换文件内容
echo 'test' > test.txt # 行尾追加
# sed命令可以重点学习
sed -e 4a\newline text.txt # 第四行后面添加一行
sed -e 4i\newline text.txt # 第四行前面添加一行
sed -e '2,3d' text.txt # 删除第二行和第三行
sed -e '2,$d' text.txt # 删除第二行和以后的所有行
sed -e '2,3c\hello' text.txt # 替换第二行和第三行为hello,\不是必须的
sed -n '2,3p' text.txt # 显示第二行和第三行
sed -n '/line2/p' text.txt # 搜索line2
sed -e 's/line/ln/g' text.txt # 将line替换为ln
sed -r 's/l\w{3}/ln/g' text.txt # 将l开头后面跟三个字母的字符串替换为ln
sed -i 's/line/ln/g' text.txt # 使修改生效
shellwhereis text.txt # 搜索文件 find -name 'text.txt' # 当前目录搜索 find . -name 't*' -exec sed -n '2,3p' {} \; # 查找以t开头的文件并输出第二行和第三行 find / -type f -size 0 -exec ls -l {} \; # 查找所有大小为0的文件并输出 find . -name "*.pyc" | xargs rm –f # 查找当前目录所有后缀是pyc的文件并删除 find . -type f -name '*.xy'|xargs -i mv {} {}.ab # 将当前目录所有后缀为xy的文件后缀改为ab
service docker start|stop|restart # 操作docker服务 systemctl start|stop|restart docker # 操作docker服务 systemctl enable docker # 设置开机启动服务
yum install php7-common # centos apt-get/apt install php7-common # debian YaST # openSUSE Pacman # ArchLinux apk add php7-common # alpine yum remove php7-common yum purge php7-common
cd /var/www ./confugure make && make install
本文作者:谭三皮
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!