zoukankan      html  css  js  c++  java
  • .linux基础命令三

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

    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

     

     
  • 相关阅读:
    玩聚网和百度新闻的技术差异性
    拿下“[warn] (OS 64)指定的网络名不再可用”错误
    转型要回答的四个问题和一根筋变形Push法
    奇虎之奇酷改版为热点memeTracker之分析
    新媒体的运营之道【三】
    疑似BUG:Python SGMLParser处理html中的javascript失当
    智能语义参透股票 小公司不见得比输大公司
    新SNS的创立和运营之道[360圈座谈]
    在路上:语义和创业
    论Push!
  • 原文地址:https://www.cnblogs.com/thismyblogs/p/9608807.html
Copyright © 2011-2022 走看看