![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux
不会上树的猫+
Hello World!
展开
-
screen常用命令总结(支持关闭xshell窗口操作)
71824.pts-0.localhost --> id.sessionNamescreen -S dcx --> 新建一个叫dcx的session,并登录dcx sessionscreen -ls --> 列出当前所有的session以及当前状态---------------------------------------------------screen -d dcx --> dcx sess原创 2022-03-06 12:58:32 · 1245 阅读 · 0 评论 -
Shell解压文件或下载文件到指定路径
解压包到指定路径:tar xvf abc.tar.gz -C 下载文件到指定路径:wget http://xxx -P原创 2021-12-14 15:17:09 · 2192 阅读 · 0 评论 -
RHEL7利用iso镜像制作本地yum源
参考:https://blog.csdn.net/JackLiu16/article/details/80979089原创 2021-10-18 13:09:36 · 463 阅读 · 0 评论 -
Shell实现添加元素到数组并输出
参考小例:TJ0=()TJ0+=(hello)TJ0+=(world)TJ0+=(www)输出数组结果:echo ${TJ0[@]}hello world www注意点:"+="后面的元素需要用括号括起来,通过echo ${TJ0[@]}来输出数组内容。原创 2021-04-21 10:05:41 · 1203 阅读 · 0 评论 -
将目录下的所有Shell脚本转换成Unix格式
命令行find ./* -name *.sh | xargs dos2unix {}原创 2021-01-31 22:38:16 · 2521 阅读 · 0 评论 -
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
ssh-keygen -f “/home/hddl/.ssh/known_hosts” -R “10.10.10.10”hddl@hddl-ATX-Q370A:~/cron/logs$ ssh 10.10.10.10 "cd ~ && ls"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @@@@@@原创 2021-01-07 11:16:01 · 109 阅读 · 0 评论 -
sudo免密执行
如下图所示,首先打开普通用户的/etc/sudoers文件,命令“sudo vim /etc/sudoers”,然后添加下图中框住的一行,即:hddl ALL=(ALL:ALL) NOPASSWD: ALLhddl为实际用户名,Esc > :wq! 即可!再次使用sudo可免密执行命令...原创 2021-01-07 10:08:17 · 577 阅读 · 0 评论 -
Shell循环+数组+与python交互脚本测试
demo参考如下:aa=(hello world I am chinese)arr=()for i in ${aa[@]}do #echo "i= $i" arr[${#arr[@]}]=$i echo "+ $i "doneecho "print the array result: "echo "shell format output"for val in ${arr[@]}do echo -e "$val \c"doneecho ""e原创 2021-01-05 17:18:34 · 169 阅读 · 0 评论 -
Shell脚本中嵌入python脚本
一、通过EOF符号嵌入python3 << EOFimport res = 'hello123your78,_+8ui?direc...'ret = re.findall('\d+', s)print(ret)EOFecho 'OK'二、执行单行python命令python -c "import sys; print(sys.executable)"# 复杂命令要用[]括起来python3 -c "import os,time;[print(i) for i in os原创 2021-01-04 15:36:11 · 589 阅读 · 0 评论 -
paramiko远程执行命令的两种实现方式
SSH客户端实现方案一,执行远程命令这个方案直接使用SSHClient对象的exec_command()在服务端执行命令,下面是具体代码:# 实例化SSHClientclient = paramiko.SSHClient()# 自动添加策略,保存服务器的主机名和密钥信息client.set_missing_host_key_policy(paramiko.AutoAddPolicy())# 连接SSH服务端,以用户名和密码进行认证client.connect(ip,username=user,原创 2020-12-31 11:36:31 · 724 阅读 · 0 评论 -
expect在Shell脚本中的应用(一)
获取服务器ip的时间,再通过date -s 设置本地服务器时间set_local_time(){ echo "set time now" # get time from $USER@ip time=`ssh $USER@ip "date '+%Y-%m-%d %H:%M:%S'"` expect << EOF spawn sudo date -s "$time" expect { "*hddl*" { se原创 2020-12-30 10:19:43 · 189 阅读 · 0 评论 -
Config password-less login between two Linux machine
On the source machine, make sure you have an id_rsa.pub file$ ls ~/.ssh/id_rsa.pubIf you don’t, you can easily generate one with ssh-keygen (just hit enter 3 times after running it to accept all defaults)$ ssh-keygenGenerating public/private rsa key p原创 2020-12-21 09:47:23 · 156 阅读 · 0 评论 -
xargs 实现多文件过滤查找(xargs grep)
find . -type f -name ‘*’ | xargs grep -i ‘nr’find到多个文件,从文件中过滤’NR’关键字ls | xargs grep -i ‘Line’ls到多个文件,从文件中过滤’Line’关键字原创 2020-09-11 09:56:17 · 829 阅读 · 0 评论 -
Shell脚本实现自动检测/配置/开启/关闭redis后台服务
【参考小例】该脚本包含以下4点:检查redis的后台启动配置。检查当前redis运行状态。如果redis未启动,则启动redis后台服务。如果redis已经启动,则返回redis已经在运行。执行命令:bash myredis.sh start退出时关闭redis服务。执行命令:bash myredis.sh stop#!/bin/bashcmd=$1redisDir=/usr/local/redis# 检查redis.confcheckRedisConf(){ conf原创 2020-07-05 14:45:47 · 1144 阅读 · 0 评论