美文网首页
04-Linux常用命令四&五

04-Linux常用命令四&五

作者: CrUelAnGElPG | 来源:发表于2018-05-12 12:04 被阅读0次

    1.权限

    [root@hadoop000 ~]# ll

    total 108

    -rw-r--r--. 1 root root    0 May  2 21:12 20180502.log

    -rw-------. 1 root root  1382 Apr 28 05:21 anaconda-ks.cfg

    drwxr-xr-x. 3 root root  4096 Apr 27 22:37 Desktop

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Documents

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Downloads

    -rw-r--r--. 1 root root 49565 Apr 28 05:20 install.log

    -rw-r--r--. 1 root root 10033 Apr 28 05:16 install.log.syslog

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Music

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Pictures

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Public

    drwxr-xr-x. 3 root root  4096 May  2 22:20 ruoze

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Templates

    drwxr-xr-x. 2 root root  4096 Apr 27 21:40 Videos

    [root@hadoop000 ~]#

    读:    r 4

    写:    w 2

    执行:  x 1  shell脚本

    无权限:-

    第一列 drwxr-xr-x

    第一个: d文件夹 -文件  l连接

    rwx r-x r-x: 三组

              第一组: rwx 7  代表root用户对这个文件或文件夹的权限

      第二组: r-x 5  代表root用户组的所有用户对这个文件或文件夹的权限

              第三组: r-x 5  代表其他组的所有用户对这个文件或文件夹的权限

    第三列: 所属的用户root

    第四列:所属的组root

    Permission denied  hadoop

    修改文件和文件夹的权限

    chmod 777 xxx.log 

    chmod -R 755 xxxdir

    chmod -R 755 xxxdir/*

    修改文件和文件夹的所属的用户和用户组

    chown jepson:jepson xxx.log

    chown -R jepson:jepson xxxdir

    chown -R jepson:jepson xxxdir/*

    xxx服务 安装目录的 xxxuser:xxxuser

    可执行: 针对于shell脚本

    chmod 764 date.sh 只对所属的用户

    chmod +x  date.sh 所有的用户

    2.yum

    yum --help 命令帮助格式

    yum -y install httpd

    [root@hadoop000 ~]# netstat -nlp|grep 2525

    tcp        0      0 :::80                :::*                        LISTEN      2525/httpd 

    :::80 

    127.0.0.1:80

    0.0.0.0:80

    192.168.137.251:80

    timeout 去查看服务的端口号对应的ip

    ping 192.168.137.251

    [root@hadoop000 ~]# yum install telnet

    https://jingyan.baidu.com/article/95c9d20d96ba4aec4f756154.html

    [root@hadoop000 ~]# which telnet

    /usr/bin/telnet

    [root@hadoop000 ~]# telnet 192.168.137.251 80

    Trying 192.168.137.251...

    Connected to 192.168.137.251.

    Escape character is '^]'.

    ^Z^X^C^Z

    Connection closed by foreign host.

    [root@hadoop000 ~]#

    [root@hadoop000 ~]#

    [root@hadoop000 ~]#

    [root@hadoop000 ~]# telnet 192.168.137.251 808

    Trying 192.168.137.251...

    telnet: connect to address 192.168.137.251: Connection refused

    [root@hadoop000 ~]#

    卸载:

    [root@hadoop000 ~]# rpm -qa |grep http

    httpd-tools-2.2.15-60.el6.centos.6.x86_64

    httpd-2.2.15-60.el6.centos.6.x86_64

    [root@hadoop000 ~]# rpm --nodeps -e httpd-2.2.15-60.el6.centos.6.x86_64

    [root@hadoop000 ~]#

    拓展: CentOS6.x使用163和epel yum源的选择

    http://blog.itpub.net/30089851/viewspace-2130239/

    3.找命令或者shell脚本

    [root@hadoop000 ~]# which java

    /usr/bin/java

    [root@hadoop000 ~]# locate java

    [root@hadoop000 ~]#

    4.搜索

    find / -name '*abc*'      全文

    find /tmp -name '*abc*'  指定目录

    find ./ -name '*hadoop*'  当前目录

    5.vi

    命令模式: i键进入编辑 或者 shift+: 进入尾行模式

    gg 第一行的第一个字符

    G  最后一行的第一个字符

    shift +$ 行尾

    dd 删除当前行

    dG 删除光标以下的所有行

    ndd 删除光标以下的n行

    场景: 清空一个文件

          echo '' > xxx.log

          cat /dev/null > xxx.log

          vi:  1.gg 

              2.dG

    编辑模式: esc退出到命令模式

    尾行模式:

        :q  退出

        :q! 强制退出

        :wq 保存退出

        :wq! 强制保持退出

        :/内容  n向下 N向上

        行号

        :set nu

        :set nonu

        跳转第N行

        :n

    6.查看硬盘 内存 系统情况

    df -h

    free -m

    top

    7.压缩 tar

    Examples:

      tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.

      tar -tvf archive.tar        # List all files in archive.tar verbosely.

      tar -xf archive.tar          # Extract all files from archive.tar.

      [root@hadoop000 ~]#    tar -czf ruoze.tar.gz  ruoze/*  压缩

      [root@hadoop000 test]# tar -xzvf ruoze.tar.gz      解压

    8.压缩 zip

    zip -r ruoze.zip ruoze/*

    unzip ruoze.zip

    相关文章

      网友评论

          本文标题:04-Linux常用命令四&五

          本文链接:https://www.haomeiwen.com/subject/cswcdftx.html