Linux常见符号

查找
    find
        格式:
            find 开始查找路径 [选项] [条件]
        选项:
            -name

[root@master local]# find / -name test.txt
/usr/local/soft/test.txt
[root@master soft]# find /usr/local/soft/ -name s*
/usr/local/soft/show
[root@master soft]# find /usr/local/soft/ -name "*sho*"
/usr/local/soft/jdk1.8.0_171/jre/lib/ext/nashorn.jar
/usr/local/soft/show
/usr/local/soft/show/show.txt
/usr/local/soft/show/show1.txt
/usr/local/soft/show/show2.txt
[root@master soft]# useradd testshow
[root@master soft]# userdel testshow
[root@master soft]# find / -name "*testshow*"
/var/spool/mail/testshow
/home/testshow
[root@master soft]# rm /home/testshow/
rm: 无法删除"/home/testshow/": 是一个目录
[root@master soft]# rm /var/spool/mail/testshow
rm:是否删除普通空文件 "/var/spool/mail/testshow"?yes
[root@master soft]# userdel testshow
userdel:用户“testshow”不存在
[root@master soft]# find / -name "*testshow*"
/home/testshow
[root@master soft]# rm -rf /home/testshow/
[root@master soft]# find / -name "*testshow*"


                *表示匹配所有
                ?表示匹配一个
                例如:从/开始查找后缀为.txt
                    find / -name "*.txt"
            -type    
                d:表示目录
                f:表示文件
                例如:从/开始查找文件
                    find / -type f
            -size
                ll --block-size=单位 
                    例如:大小以k为单位进行显示
                        ll --block-size=k
                注意:条件需要给上单位
                    +表示大于
                    -表示小于
                    不给就是等于
                例如:从/开始查找文件大小大于2k
                    find / -size +2k

[root@master soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
drwxr-xr-x. 2 root root  56 2月  25 19:44 show
-rw-r--r--. 1 root root  10 2月  25 19:31 test.txt
[root@master soft]# ll --block-size=k
总用量 4K
drwxr-xr-x. 8   10  143 1K 3月  29 2018 jdk1.8.0_171
drwxr-xr-x. 2 root root 1K 2月  25 19:44 show
-rw-r--r--. 1 root root 1K 2月  25 19:31 test.txt
[root@master soft]# find /usr/local/soft/show/ -size -2k
/usr/local/soft/show/
/usr/local/soft/show/show.txt
/usr/local/soft/show/show1.txt
/usr/local/soft/show/show2.txt


            -user
            -group

查看文件:

    cat 查看文件中的所有内容

         格式:cat [选项] 文件的全路径或文件名称

          选项:

          -n:加行号进行显示

     more 分页查看(只能加载一部分)

          格式:more 文件的全路径或文件名称

          操作:

                 回车:显示下一行

                 s:显示下一页

                 q:直接退出

                 空格:显示下一页

                 b:返回上一页

     less:分页查看(加载完毕,只显示一部分)

          格式:less 文件的全路径或文件名称

            注意:可以在查看文件下,最后一行输入行号,向下显示多少行

          :q 退出

       head:查看文件头部

           格式:head [选项]  文件的全路径或文件名称

             选项:
                      -数字:从头开始显示多少行

                      默认显示10行

          tail:查看文件尾部

            格式:tail [选项] 文件的全路径或文件名称

              选项:

                     -数字:从尾开始显示多少行

                      默认显示10行

Linux常见符号
    |:管道,把前面一部分的内容交给后面去处理
    例如:
        cat /etc/profile | more

    grep:筛选
        格式:
            grep 筛选条件
    >>:追加,把命令1的结果写入到命令2
        格式:
            命令1 >> 命令2 
        例如:cat profile >> test.txt
    >:覆盖
        格式:
            命令1 > 命令2 
        例如:cat profile > test.txt

软件包管理
    rpm:查看 管理 删除软件
        格式:
            rpm [选项] [软件名称] [后缀]
        选项:
            -q:查询
            -a:所有
            -qa:查询所有
            -e:删除
        后缀:
            --nodeps:无视依赖关系
        注意:直接-e时,如果有依赖关系,不能直接删除
            需要加上--nodeps后缀

    tar:解压和压缩
        格式:
            tar [选项] [包] [路径]
        选项:
            -c:压缩
            -x:解压
            -v:显示
            -z:gzip
            -j:bzip
            -f:使用当前名称
            -t:查看

        解压:
            -C:指定解压路径
            例如:解压jdk
                tar -zxvf jdk.tar.gz -C /usr/local/soft/
        打包:
            例如:把jdk从新打包
                tar -cvf 包的所在位置加包的名称 所要打包的内容
安装包的位置/usr/local/module/
安装jdk的位置/usr/local/soft/
                
配置环境变量
    vim /etc/profile

    在最后的位置输入
        export JAVA_HOME=/usr/local/soft/jdk1.8.0_171
        export PATH=$PATH:$JAVA_HOME/bin
        :wq保存

export JAVA_HOME=/usr/local/soft/jdk1.8.0_171
export PATH=$PATH:$JAVA_HOME/bin


    刷新文件:source /etc/profile

克隆两台虚拟机加master 三台组成一个集群
    所克隆的虚拟机需要修改主机名,ip
    永久修改主机名
        hostnamectl set-hostname node1或node2
    ip
        方式1:
            通过可视化界面直接修改
        方式2:
            vim /etc/sysconfig/network-scripts/ifcfg-ens33
            然后重启网络:service network restart

加上映射关系
    windows下C:\Windows\System32\drivers\etc\hosts
        192.168.75.110 master
        192.168.75.120 node1
        192.168.75.130 node2

    linux下/etc/hosts
        192.168.75.110 master
        192.168.75.120 node1
        192.168.75.130 node2

ssh免密:只需要在master下执行

[root@master soft]# cd ~
[root@master ~]# pwd
/root
[root@master ~]# ll

后继续ll -a ,发现ssh后

[root@master ~]# cd .ssh/


    1.创建秘钥
        ssh-keygen -t rsa 一直回车

[root@master .ssh]# ssh-keygen -t rsa
Generating 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: 
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:qKymdcjAoZ1SRd1lOoN2KTOYFw8am4vhpXGy/xTlH8w root@master
The key's randomart image is:
+---[RSA 2048]----+
|   .+.o. .o      |
|   . B.=.+       |
| .= O B O        |
|o+.@ + O =       |
|+.B . o S E      |
| + + . . . .     |
|  + = .   .      |
| ..o o           |
|.o.   .          |
+----[SHA256]-----+


    2.秘钥分发
        ssh-copy-id 主机名或ip地址(分发三台)
    注意:如果执行出错,进入/root/.ssh删除里面所有内容,从新执行

[root@master .ssh]# ssh-copy-id -i node1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node1's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'node1'"
and check to make sure that only the key(s) you wanted were added.

[root@master .ssh]# ssh-copy-id -i node2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node2 (192.168.49.130)' can't be established.
ECDSA key fingerprint is SHA256:yypdVNIA5twUXhXseiP8dyOhKbMaC78B1kiPR0daLec.
ECDSA key fingerprint is MD5:e8:48:11:76:85:c0:aa:23:a1:a5:bc:0b:c2:b2:81:08.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node2's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'node2'"
and check to make sure that only the key(s) you wanted were added.

[root@master .ssh]# ssh-copy-id -i master
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'master (192.168.49.110)' can't be established.
ECDSA key fingerprint is SHA256:yypdVNIA5twUXhXseiP8dyOhKbMaC78B1kiPR0daLec.
ECDSA key fingerprint is MD5:e8:48:11:76:85:c0:aa:23:a1:a5:bc:0b:c2:b2:81:08.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@master's password: 
Permission denied, please try again.
root@master's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'master'"
and check to make sure that only the key(s) you wanted were added.

[root@master .ssh]# ll
总用量 16
-rw-------. 1 root root  393 2月  25 20:16 authorized_keys
-rw-------. 1 root root 1675 2月  25 20:05 id_rsa
-rw-r--r--. 1 root root  393 2月  25 20:05 id_rsa.pub
-rw-r--r--. 1 root root  547 2月  25 20:15 known_hosts
[root@master .ssh]# scp -r /usr/local/soft/test.txt node1:/usr/local/soft/
test.txt                  100%   10    16.9KB/s   00:00    
[root@master .ssh]# scp -r /usr/local/soft/test.txt node2:/usr/local/soft/
test.txt                  100%   10    10.3KB/s   00:00    

scp:文件分发
    格式:
        scp [选项] 文件路径 主机名:发送的位置
        选项:
            -r:分发目录    

1.

[root@master soft]# scp test.txt node1:/usr/local/soft
The authenticity of host 'node1 (192.168.49.120)' can't be established.
ECDSA key fingerprint is SHA256:yypdVNIA5twUXhXseiP8dyOhKbMaC78B1kiPR0daLec.
ECDSA key fingerprint is MD5:e8:48:11:76:85:c0:aa:23:a1:a5:bc:0b:c2:b2:81:08.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node1,192.168.49.120' (ECDSA) to the list of known hosts.
root@node1's password: 
test.txt                  100%   10    20.5KB/s   00:00    
[root@master soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
-rw-r--r--. 1 root root  10 2月  25 19:31 test.txt
[root@master soft]# scp test.txt node2:/usr/local/soft
[root@node1 ~]# cd /usr/local/soft
[root@node1 soft]# ll
总用量 0
drwxr-xr-x. 8 10 143 255 3月  29 2018 jdk1.8.0_171
[root@node1 soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
-rw-r--r--. 1 root root  10 2月  25 19:35 test.txt

[root@node2 soft]# ll
总用量 0
drwxr-xr-x. 8 10 143 255 3月  29 2018 jdk1.8.0_171
[root@node2 soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
-rw-r--r--. 1 root root  10 2月  25 19:35 test.txt

2.

[root@master show]# ll
总用量 0
-rw-r--r--. 1 root root 0 2月  25 19:43 show1.txt
-rw-r--r--. 1 root root 0 2月  25 19:44 show2.txt
-rw-r--r--. 1 root root 0 2月  25 19:43 show.txt
[root@master show]# cd ..
[root@master soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
drwxr-xr-x. 2 root root  56 2月  25 19:44 show
-rw-r--r--. 1 root root  10 2月  25 19:31 test.txt
[root@master soft]# scp show 192.168.49.120:/usr/local/soft
root@192.168.49.120's password: 
show: not a regular file
[root@master soft]# scp -r show 192.168.49.120:/usr/local/soft
root@192.168.49.120's password: 
show.txt                  100%    0     0.0KB/s   00:00    
show1.txt                 100%    0     0.0KB/s   00:00    
show2.txt                 100%    0     0.0KB/s   00:00   
[root@node1 soft]# ll
总用量 4
drwxr-xr-x. 8   10  143 255 3月  29 2018 jdk1.8.0_171
drwxr-xr-x. 2 root root  56 2月  25 19:46 show
-rw-r--r--. 1 root root  10 2月  25 19:42 test.txt


查看开机默认启动模式
    systemctl get-default
修改开机为命令行模式
    systemctl set-default multi-user.target

[root@node2 soft]# systemctl get-default 
multi-user.target
[root@node2 soft]# systemctl set-default multi-user.target

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值