一、 两台服务器免密登录:

1. 生成密钥

  ssh-keygen的命令手册,通过”man ssh-keygen“命令查看指令:

  通过命令”ssh-keygen -t rsa“创建一对密匙,包括公匙和私匙,生成之后会在用户的根目录生成一个 “.ssh”的文件夹

  进入“.ssh”,查看生成的文件

 authorized_keys:存放远程免密登录的公钥,主要通过这个文件记录多台机器的公钥

  id_rsa : 生成的私钥文件

  id_rsa.pub : 生成的公钥文件

  know_hosts : 已知的主机公钥清单

    如果希望ssh公钥生效需满足至少下面两个条件:

      1) .ssh目录的权限必须是700

      2) .ssh/authorized_keys文件权限必须是600

常用以下几种方法:

    2.1 通过ssh-copy-id的方式

      命令: ssh-copy-id -i ~/.ssh/id_rsa.put <romte_ip>

      举例:

        [root@test .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub 132.232.138.29 

        [root@test .ssh]# ssh root@ 132.232.138.29   直接连接另一台服务器就行了

    2.2 通过scp将内容写到对方的文件中

      命令:scp -p ~/.ssh/id_rsa.pub root@<remote_ip>:/root/.ssh/authorized_keys  

        scp: 即,ssh-copy-id

      举例:

          1.  scp -p ~/.ssh/id_rsa.pub root@132.232.138.29 :/root/.ssh/authorized_keys

          2.  ssh root@192.168.91.135  直接连接另一台服务器就行了

原文参考地址:http://www.cnblogs.com/LuisYang/archive/2016/10/12/5952871.html

        

ntpdate ntp1.aliyun.com   根据阿里云服务器矫正时间

  ntp:Network time Protocol,网络时间协议

# 测试sed命令
测试通过sed实现过滤匹配文本行之间的内容
匹配行后添加内容,并引用匹配模式。
##测试环境,文本内容如下:

```
[root@test sed_test]# cat test.txt1
this is a test1.
this is a test2.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```

##测试p
###打印1行

```
[root@test sed_test]# sed '/test2/p' test.txt1
this is a test1.
this is a test2.
this is a test2.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```

###打印多行

```
[root@test sed_test]# sed '2,3p' test.txt1
this is a test1.
this is a test2.
this is a test2.
this is a test3.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```

##测试d删除
###删除单行

```
[root@test sed_test]# sed '/test2/d' test.txt1
this is a test1.
this is a test3.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#
```

###删除多行

```
[root@test sed_test]# sed '2,3d' test.txt1
this is a test1.
this is a test4.
this is a test5.
this is a test6.
[root@test sed_test]#

[root@test sed_test]# sed '2,4d' test.txt1
this is a test1.
this is a test5.
this is a test6.
[root@test sed_test]#
```

 

awk:

 1、求和
cat data|awk '{sum+=$1} END {print "Sum = ", sum}'

2、求平均值
cat data|awk '{sum+=$1} END {print "Average = ", sum/NR}'

3、求最大值
cat data|awk 'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}'

4、求最小值(min的初始值设置一个超大数即可)
cat data | awk 'BEGIN {min = 1999999} {if ($1<min) min=$1 fi} END {print "Min=", min}' 

 
 
 [root@dplinux-node1 sed_awk]# awk '{s[$2]++}END{for (i in s) print i,s[i]}' time.txt 
haha 100
cost 100
[root@dplinux-node1 sed_awk]#  
 
awk各种操作<===戳这里
 
 

VMWare虚拟机IP为127.0.0.1的问题

dhclient -v

 

 

.linux基础命令三的更多相关文章

  1. Linux基础命令(三)

    作业一:1) 将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖) cat /etc/passwd /etc/group >/1.txt 2) 将用户信息数据库文件和用户 ...

  2. 【Python之路】第一篇--Linux基础命令

    pwd 命令 查看”当前工作目录“的完整路径 pwd -P # 显示出实际路径,而非使用连接(link)路径:pwd显示的是连接路径 .   表示当前目录 ..  表示上级目录 /  表示根目录 ls ...

  3. Linux基础命令-文件与目录

    Linux基础命令-文件与目录 参考:<鸟哥linux私房菜>五-七章,17/12/5复习,18/01/15复习 文件权限 rwx421:用户,用户组,其他 umask查看默认权限:000 ...

  4. Linux基础命令和文件权限

    Linux命令与文件权限 Linux基础命令   reboot  重启   cd         切换目录   cd ..     回到上一级目录   cd ~      回到主目录   cd /  ...

  5. Linux基础命令-查看基本硬件信息

    Linux基础命令-查看基本硬件信息 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.查看CPU信息 [root@node101.yinzhengjie.org.cn ~]# l ...

  6. Linux基础命令小结(超全!!)

    Linux目录结构 1.bin 存放经常使用的指令比如ll,cp 2.sbin 系统管理员使用的系统管理指令 3.home 存放普通用户的住目录 4.root 系统管理员的用户主目录 5.boot 存 ...

  7. Linux 基础命令及基本目录

    Linux 基础命令及基本目录 一.网卡 1.网卡配置文件路径 ​ /etc/sysconfig/network-scripts/ifcfg-eth0 配置文件: TYPE=Ethernet # 以太 ...

  8. Linux——基础命令用法(上)

    一.Linux基础命令 1.Linux命令行的格式 命令行的格式为:用户名+主机名+当前工作目录 输入内容的命令格式为:命令 [-短选项/--长选项] [参数] [root@localhost ~]# ...

  9. day04 Linux基础命令

    day04 Linux基础命令 查看帮助信息命令 1.man命令:man命令的功能是查看指定命令的详细解释. 格式:man [具体需要被查看的命令] [root@localhost ~]# man r ...

随机推荐

  1. 寻找的常用webstorm快捷键

    1. 必备快捷键 Ctrl+/:注释当前行 Ctrl+Shift+/:当前位置插入注释 Ctrl+Alt+/:块注释,并Focus到首行,写注释说明用的 Ctrl+Shift+A:选择当前标签前后,修 ...

  2. Navicat 出现的[Err] 1146 - Table 'performance_schema.session_status' doesn't exist已解决

    [Err] 1146 - Table 'performance_schema.session_status' doesn't exist已解决   刚刚接触MySQL,就往数据库添加数据,就遇到这个问 ...

  3. Element ui 中的表格数据格式转换

  4. HDU 6616 Divide the Stones

    目录 题面 中文题意 比赛惨状 我的走不通的思路 \(m\)是偶数的情况 \(m\)是奇数的情况 题解的思路 另一些思路 源代码 题面 Time limit 3000 ms Memory limit ...

  5. Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes

    B. Obtain Two Zeroes time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. sql server 高版本数据还原到低版本sql server的注意事项

    生成的sql脚本不能大于100m,否则会报错(System.OutOfMemory) 所以要将较大的sql脚本文件进行分割

  7. Linux_FTP服务器

    目录 目录 FTP FTP Server FTP configuration Global config Anonymous user FTP Config Virtual user FTP Loca ...

  8. 深入理解webpack基本配置(一)

    1. 安装webpack到全局 在学习构建之前,我们来在本地文件新建一个存放项目的文件夹,比如叫demo1这个项目,然后进入demo1该项目的根目录后,执行命令 npm init运行下,一路回车(先简 ...

  9. jmeter之三种参数化

    前言:总结并记录几种jmeter比较有用的元件 1.接口文档 2.参数化 3.断言 1.接口文档 a.拿到接口文档 接口地址:http://localhost:8080/jpress/admin/lo ...

  10. 基于nginx实现二维码下载安装apk文件

    将apk文件置于nginx目录下 <!--进入nginx安装路径--> /usr/local/nginx <!--新建放apk的目录--> mkdir -p resources ...