随笔分类 -  Linux

摘要:1、使用如下命令测试ssh连接主机需要多长时间 time ssh root@192.168.23.154 exit 2、修改sshd_config文件 vi /etc/ssh/sshd_config 1)将UseDNS yes(默认是yes)改为UseDNS no 该配置是默认开启了SSH的反向DN 阅读全文
posted @ 2024-05-23 10:47 雷雨客 阅读(29) 评论(0) 推荐(0) 编辑
摘要:1、#!/bin/sh 复杂的程序必须写 #!/bin/sh 表示这是一个脚本,简单的可以不写。 2、单引号、双引号 单引号 即使包含特殊字符,也会原样输出 双引号 特殊字符有特殊含义 echo "hello world!" 报错,因为!有特殊含义 echo 'hello world!' 正常输出 阅读全文
posted @ 2024-05-23 10:42 雷雨客 阅读(22) 评论(0) 推荐(0) 编辑
摘要:centos磁盘扩容 https://blog.csdn.net/weixin_45648789/article/details/131536293 阅读全文
posted @ 2023-09-19 10:10 雷雨客 阅读(8) 评论(0) 推荐(0) 编辑
摘要:错误原因:脚本在window下编辑过,window下每一行结尾是\n\r,linux 下每一行结尾是\n 解决方法:使用指令sed把xxxxx.sh中的\r替换成空白,sed -i 's/\r$//' xxxxx.sh 阅读全文
posted @ 2023-06-11 10:44 雷雨客 阅读(379) 评论(0) 推荐(0) 编辑
摘要:grep 筛选行 awk 截取列 [root@localhost tmp]# cat student.txt ID Name gender mark 1 sl M 89 2 hus M 90 3 sd M 99 [root@localhost tmp]# awk '{printf $2 "\t" $ 阅读全文
posted @ 2022-04-27 16:12 雷雨客 阅读(11) 评论(0) 推荐(0) 编辑
摘要:1、获取文件类型 [root@localhost ~]# filename="/root/data/aa.gz" [root@localhost ~]# echo ${filename##*.} gz [root@localhost ~]# filename="/root/data/aa.dat" 阅读全文
posted @ 2022-04-27 15:59 雷雨客 阅读(5) 评论(0) 推荐(0) 编辑
摘要:1、执行查询命令 yum search ifconfig 2、根据查询结果,执行安装命令 yum install net-tools.x86_64 如下图所示: 阅读全文
posted @ 2020-08-30 18:33 雷雨客 阅读(1051) 评论(0) 推荐(0) 编辑
摘要:1、创建挂载点 mkdir /mnt/cdrom/ 2、挂载光盘 mount -t iso9660 /dev/cdrom /mnt/cdrom/ 3、进入目录 cd /mnt/cdrom/Packages 4、查看yum相关包 5、安装 rpm -ivh yum-metadata-parser-1. 阅读全文
posted @ 2020-08-27 15:05 雷雨客 阅读(1135) 评论(0) 推荐(0) 编辑
摘要:1、演示每隔一分钟,向/tmp/aa.txt中输入字符串“hhhhhh” 命令如下: */1 * * * * echo 'hhhhhh' >> /tmp/aa.txt 2、演示每隔一分钟,向/tmp/bb.txt中输入当前时间 1)脚本 #!bin/bash time=$(date "+%Y-%m- 阅读全文
posted @ 2020-06-08 17:51 雷雨客 阅读(283) 评论(0) 推荐(0) 编辑
摘要:1、iptables 1)查看是否安装iptables rpm -qa | grep iptables 2)查看是否启动iptables systemctl status iptables.service 3)启动iptables systemctl start iptables.service 4 阅读全文
posted @ 2020-05-12 17:46 雷雨客 阅读(724) 评论(0) 推荐(0) 编辑
摘要:历史命令 historyhistory -c 清除历史命名history -w 把缓存中的命令写入历史命令保存文件 ~/.bash_history 默认历史命令保存1000条,如果超过了条数,会删除前面的,保存后面的 可以修改:/etc/profile 中:HISTSIZE=1000,重新登录才会生 阅读全文
posted @ 2020-02-15 18:05 雷雨客 阅读(289) 评论(0) 推荐(0) 编辑
摘要:服务器: 192.168.23.151、192.168.23.152、192.168.23.153、192.168.23.154、192.168.23.155、192.168.23.156 从151到其他服务器免密码登录,在151上执行下面的语句,一直回车即可 ssh-keygen -t rsa 在 阅读全文
posted @ 2020-01-04 14:51 雷雨客 阅读(362) 评论(0) 推荐(0) 编辑
摘要:1、安装 yum -y install vsftpd 2、配置文件详解 安装后配置文件位于/etc/vsftpd vsftpd.ftpusers:该文件中用户账户不能访问FTP服务器,例如root等。 vsftpd.user_list:该文件中用户账户在默认情况下也不能访问FTP服务器,仅当vsft 阅读全文
posted @ 2019-12-29 19:10 雷雨客 阅读(623) 评论(0) 推荐(0) 编辑
摘要:复制命令cp总提示是否覆盖的解决方法,在cp前加\ 一些服务器会默认增加别名 alias cp=’cp -i’,当你执行cp时,其实执行的是cp –i。在cp前加\可以解决,如: \cp /etc/aa.txt /tmp 1、复制文件夹及其里面的内容到指定文件夹 cp -r /usr/local/ 阅读全文
posted @ 2019-12-15 18:28 雷雨客 阅读(590) 评论(0) 推荐(0) 编辑
摘要:curl www.baidu.com 访问一个网页 curl -o tt.html www.baidu.com 将访问www.baidu.com返回的内容写入tt.html curl -i www.baidu.com 显示响应的头信息 curl -v www.baidu.com 显示一次http请求 阅读全文
posted @ 2019-08-18 02:12 雷雨客 阅读(9363) 评论(2) 推荐(1) 编辑
摘要:命令查询某应用启动的端口号,举例: netstat -nap | grep mongo 查询 mongodb 的端口号 mongodb 启动的端口号是27017 查询正在启动的进程 阅读全文
posted @ 2019-08-03 08:25 雷雨客 阅读(1859) 评论(0) 推荐(0) 编辑
摘要:1、将日志同时输出到控制台和文件中,文件中的日志累加 echo "脚本执行有误,请检查参数" 2>&1|tee -a /usr/local/myroom/script/log/mylog.log 阅读全文
posted @ 2019-07-28 21:42 雷雨客 阅读(3711) 评论(0) 推荐(0) 编辑
摘要:#!/bin/sh read -p "Please input user name: " -t 30 name read -p "Please input user pass: " -t 30 pass echo $name $pass 阅读全文
posted @ 2019-07-15 18:10 雷雨客 阅读(273) 评论(0) 推荐(0) 编辑
摘要:一、for循环 1、in 后面是常量,空格分隔 #!/bin/sh for str in aa bb cc dd do echo "str is "$str done 2、in 后面是变量,空格分隔 #!/bin/sh strlist="aa bb cc dd ee" for str in $str 阅读全文
posted @ 2019-07-15 18:09 雷雨客 阅读(658) 评论(0) 推荐(0) 编辑
摘要:1、单分支 if #!/bin/sh input=$1 if [ $input == "a" ] then echo "输入是a" fi echo "结束!" #!/bin/sh input=$1 if [ $input == "a" ];then echo "输入是a" fi echo "结束!" 阅读全文
posted @ 2019-07-09 08:24 雷雨客 阅读(308) 评论(0) 推荐(0) 编辑