shell
linux shell的相关知识
marc_chen
这个作者很懒,什么都没留下…
展开
-
linux java安装
1,下载Linux版本的jre版本2,上传下载的版本至系统3,解压jre文件4,export JRE_HOME,并将其加入到PATH中5,检查JAVA版本1,下载Linux版本的jre版本https://java.com/en/download/linux_manual.jsp2,上传下载的版本至系统[root@node5 java]# pwd/usr/local/java[root@node5 java]# lsjre-8u311-linux-x64.tar.gz[root@nod原创 2021-10-22 23:15:36 · 118 阅读 · 0 评论 -
history命令中显示命令执行的时间
[root@node5 ~]# history #默认的history显示的命令是不带时间的 1 hostnamectl set-hostname node5 2 exit[root@node5 ~]# echo 'export HISTTIMEFORMAT="%F %T "'>>/etc/profile #添加一行[root@node5 ~]# source /etc/profile #让文件生效[root@node5 ~]# history原创 2021-10-22 21:59:35 · 418 阅读 · 0 评论 -
expect带变量参数实现ssh登录
[root@node5 ~]# cat sshlogin2.exp#!/bin/bashset ip [lrange $argv 0 0] #第一个变量赋值ipset password [lrange KaTeX parse error: Expected 'EOF', got '#' at position 14: argv 1 1] #̲第二个变量赋值给passwor…ip -pKaTeX parse error: Undefined control sequ原创 2021-10-17 09:49:26 · 245 阅读 · 0 评论 -
shell 免秘钥自动创建
使用方法: ./sshlogin IP 密码[root@node5 ~]# cat sshlogin#!/bin/baship=$1passwd=$2port=22autologin(){expect -c "set timeout 5spawn ssh-copy-id -f root@$1 -p$3expect {“yes/no” {send “yes”\n;exp_continue}“password:" {send “$2”\n}}expect eof"}#sh cr原创 2021-10-17 00:31:49 · 71 阅读 · 0 评论 -
shell ssh免秘钥制作
[root@node2 ~]# ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Yo原创 2021-10-16 23:16:42 · 144 阅读 · 0 评论 -
shell脚本+用户名+密码 ssh自动登录(expect spawn)
[root@node5 ~]# cat sshlogin #使用1条命令登录远程主机,并停留在登录交互页面#!/bin/baship=$1password=$2autologin(){expect -c "set timeout 5spawn ssh root@$1 -p22expect {“yes/no” {send “yes”\r;exp_continue}“password” {send $2\r}}interact"}autologin $ip $passwor原创 2021-10-16 22:59:18 · 1745 阅读 · 0 评论 -
shell spawn expect ssh自动登录
#第一次[root@node2 ~]# ssh root@192.168.0.129The authenticity of host ‘192.168.0.129 (192.168.0.129)’ can’t be established.ECDSA key fingerprint is SHA256:843LW+DwjjBNWQjNlv4MNcJ4+jkEA6n/PnuOqrbS5Fo.ECDSA key fingerprint is MD5:ac:1b:e2:f1:7a:a8:e9:6f:37:原创 2021-10-16 22:56:08 · 558 阅读 · 0 评论 -
shell basename dirname readlink使用
[root@localhost home]# ./checkpath.shthis is full file name:checkpath.shthis is file name:checkpaththis is file full path:/home/checkpath.shthis is file path:/home[root@localhost home]# cat checkpath.sh#!/bin/bashfullfile=basename $0file=basename $原创 2021-10-15 14:26:54 · 245 阅读 · 0 评论 -
shell 命令 cat rev tac
[root@localhost home]# cat test.txt #从左到右,从上到下打印hello wordtest file[root@localhost home]# rev test.txt #行级 反向打印drow ollehelif tset[root@localhost home]# tac test.txt #从下到上反向打印test filehello word...原创 2021-10-12 15:19:20 · 79 阅读 · 0 评论 -
Linux random还是生成随机数
#RANDOM在linux下是一个自带的系统变量,取值范围是0-32767#如下方式为取RANDOM值取模60,则可以得到0-60之间的一个随机整数[root@node5 ~]# num=$((RANDOM%60))[root@node5 ~]# echo $num56#如下方式为取RANDOM值取模120,则可以得到0-120之间的一个随机整数[root@node5 ~]# num=$((RANDOM%120))[root@node5 ~]# echo $num115...原创 2021-08-29 22:53:55 · 336 阅读 · 0 评论 -
yum 安装 appache php
1,安装httpd,php,php-fpm //php-fpm实际整合的是mod_php,从配置文件中可以看到2,启动httpd3,验证(增php测试页,测试)1,安装httpd,php,php-fpm[root@node2 ~]# yum install httpd php php-fpm -y..................................Dependencies Resolved==============================...原创 2020-10-20 11:49:49 · 123 阅读 · 0 评论 -
查看配置文件,去掉以“#|空格#|tab #|空行”的行
1,去掉行首的空格或者tab2,去掉行首是“#|空行”1,去掉行首的空格或者tabsed 's/^[ \t]*//g' /etc/httpd/conf/httpd.conf将行首空格|tab去掉2,去掉行首是“#|空行”sed 's/^[ \t]//g' /etc/httpd/conf/httpd.conf | grep ^[^#]...原创 2020-10-20 11:44:34 · 465 阅读 · 0 评论