Linux 常用命令大全

  1. 测试端口连通性的命令

    telnet ip port
    # 开放
    [appuser&dp-core-bat ~]$ telnet 10.172.123.253 28080
    Trying 10.172.123.253...
    Connected to 10.172.123.253
    
    # 未开放
    [appuser&dp-core-bat ~]$ telnet 10.172.123.253 28081
    Trying 10.172.123.253...
    telnet: connect to address 10.172.123.253: Connection refused
    ssh -v -p port ip
    # 说明:
       v 调试模式(会打印日志)
       p 指定端口
       username:远程主机的登录用户
       ip:远程主机
    
    # 开放的端口
    C:\WINDOWS\system32>ssh -v -p 28080 10.172.123.253
    OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
    debug1: Connecting to 10.172.123.253 [10.172.123.253] port 28080.
    debug1: Connection established
    
    # 未开放的端口
    C:\WINDOWS\system32>ssh -v -p 28080 10.172.123.253
    OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
    debug1: Connecting to 10.172.123.253 [10.172.123.253] port 28081.
    debug1: connect to address 10.172.123.253 port 28081: Connection refused
    ssh: connect to host 10.172.123.253 port 28081: Connection refused
    curl ip:port
    # 开放的端口
    [appuser&dp-core-bat ~]$ curl 10.172.123.253 28080
    <HTML>
    <HEAD>
    <TITLE>Error 404 - Not Found<TITLE>
    <BODY>
    </BODY>
    </HTML>
    
    # 未开放的端口
    [appuser&dp-core-bat ~]$ curl 10.172.123.253 28081
    curl: (7)Failed connect to 10.172.123.253:28081; Connection refused
    wget ip:port
    # 开放的端口
    wget 10.172.123.253:28080
    Connecting to 1.1.1.1:8000... connected.
    # 未开放的端口
    wget 10.172.123.253:28081 
    failed: Connection timed out. Retrying.
    tcping
    # 这是个第三方工具,下载地址 tcping.exe - ping over a tcp connection。这个工具还可以用来测试TCP的延迟。在官网下载下载 tcping.exe, 复制到 ‘C:\Windows\System32’ 就可以在cmd里面用了。
    
    # 用法
    tcping ip port

      

  2. 开放指定端口

    1、开启防火墙
    systemctl start firewalld
    
    2、开放指定端口
    # 暂时开放ftp服务
       firewall-cmd --zone=public --add-port=指定端口号/tcp 
       --zone :作用域 
       --add-port: 添加端口
    
    # 永久开放ftp服务
       firewall-cmd --zone=public --add-port=指定端口号/tcp --permanent 
    
    #永久关闭
       firewall-cmd --remove-service=ftp --permanent
    
    
    3、重新加载防火墙配置
    firewall-cmd --reload
    
    4、查看端口号
    netstat -ntlp  # 查看所有tcp端口
    netstat -ntulp | grep 8010  # 查看8010端口的使用情况
    
    # 补充:
      #查看防火墙运行状态
      firewall-cmd --state  
      # 关闭防火墙
      systemctl stop firewalld

        # 启用防火墙
         systemctl enable firewalld

         # 永久停用防火墙
         systemctl disable firewalld
     

  3. 查看Linux 系统型号、版本

    [postgres@ecs-22090803 .ssh]$ uname -a
    Linux ecs-22090803 3.10.0-1160.53.1.el7.x86_64 #1 SMP Fri Jan 14 13:59:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    [postgres@ecs-22090803 .ssh]$ cat /proc/version 
    Linux version 3.10.0-1160.53.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Fri Jan 14 13:59:45 UTC 2022
    
    [postgres@ecs-22090803 .ssh]$ cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core)
  4. 给文件夹或者文件 添加一个用户权限 

    chown -R alg /data   # -R 递归目录  alg 是用户名
  5. 修改文件夹或者文件的权限

    chmod -R 777 文件夹
  6. chmod无权限——八种解决办法

    直接运行加载程序,并将其传递给想要运行的命令
    [root@localhost ~]# /lib64/ld-linux-x86-64.so.2 /bin/chmod 755 /bin/chmod
    [root@localhost ~]# ll /bin/chmod
    -rwxr-xr-x. 1 root root 48712 Oct 15 2014 /bin/chmod

    加载程序路径可能不同,32位系统应该是/lib/ld-linux.so,我没有测试

    http://www.fblinux.com/?p=30

     





posted on 2022-09-09 17:09  闹不机米  阅读(49)  评论(0编辑  收藏  举报

导航