linux常用命令二

1.权限
    读:       r 4
    写:       w 2
    执行:   x 1  shell脚本
    无权限:-
    [root@hadoop001 ~]# ll
    total 104
    -rw-------. 1 root root  1382 Apr 21 00:20 anaconda-ks.cfg
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Desktop
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Documents
    drwxr-xr-x. 2 root root  4096 Apr 26 15:50 Downloads
    -rw-r--r--. 1 root root 49565 Apr 21 00:20 install.log
    -rw-r--r--. 1 root root 10033 Apr 21 00:19 install.log.syslog
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Music
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Pictures
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Public
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Templates
    drwxr-xr-x. 2 root root  4096 Apr 21 00:25 Videos
    [root@hadoop001 ~]# 
    第一列 drwxr-xr-x
            第一个: d文件夹 -文件  l连接 
    第二列:rwx r-x r-x: 三组
            第一组: rwx 7  代表root用户对这个文件或文件夹的权限 
            第二组: r-x 5  代表root用户组的所有用户对这个文件或文件夹的权限 
            第三组: r-x 5  代表其他组的所有用户对这个文件或文件夹的权限 
    第三列: 所属的用户root
    第四列:所属的组root
    注意:只要是错误信息里面有 Permission denied  这两个单词的,表示没有权限。

    修改文件和文件夹的权限
    chmod 777 xxx.log        修改文件 权限
    chmod -R 755 xxxdir      修改当前 文件夹权限
    chmod -R 755 xxxdir/*   修改当前文件夹及其子文件夹和文件 权限

    修改文件和文件夹的所属的用户和用户组
    chown hadoop:hadoop xxx.log          修改 文件 所属的用户和用户组
    chown -R hadoop:hadoopxxxdir        修改当前文件夹 所属的用户和用户组
    chown -R hadoop:hadoop xxxdir/*     修改当前文件夹及其子文件夹和文件 所属的用户和用户组
    例如:xxx服务 安装目录的 xxxuser:xxxuser

    可执行: 针对于shell脚本 
    chmod 764 date.sh 只对所属的用户
    chmod +x  date.sh 所有的用户


 2.yum 
    yum --help 命令帮助格式
    yum -y install httpd   安装 httpd 服务
    [root@hadoop001 sbin]# netstat -nlp|grep httpd
    tcp        0      0 :::80                       :::*                        LISTEN      5256/httpd 

    [root@hadoop001 ~]# yum install telnet   安装telnet 服务
    [root@hadoop001 ~]# which telnet        查看telnet的位置
    /usr/bin/telnet
    [root@hadoop001 ~]# telnet 192.168.90.163 80  telnet ip 端口
    Trying 192.168.90.163...
    Connected to 192.168.90.163.
    Escape character is '^]'.
    ^C
    Connection closed by foreign host.
    [root@hadoop001 ~]# 
    [root@hadoop001 ~]# telnet 192.168.90.163 808    telnet ip 端口
    Trying 192.168.90.163...
    telnet: connect to address 192.168.90.163: Connection refused
    [root@hadoop001 ~]# 


卸载:
    [root@hadoop001 ~]#  rpm -qa |grep http    列出所有被安装的 http
    httpd-2.2.15-60.el6.centos.6.x86_64
    httpd-tools-2.2.15-60.el6.centos.6.x86_64
    [root@hadoop001 ~]#

    [root@hadoop001 ~]#  rpm --nodeps -e httpd-2.2.15-60.el6.centos.6.x86_64  卸载  http   
    [root@hadoop001 ~]# 



3.找命令或者shell脚本
    [root@hadoop001 ~]# which java
    /usr/bin/java
    [root@hadoop001 ~]# 

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

    编辑模式: 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@hadoop001 ~]#    tar -czf 20180507.tar.gz   20180507/*  压缩
    [root@hadoop001 ~]# tar -xzvf 20180507.tar.gz       解压

8.压缩 zip
    zip -r  20180507.zip 20180507/*   压缩
    unzip 20180507.zip                     解压

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29609890/viewspace-2154018/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29609890/viewspace-2154018/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值