liunx系统(centos)如何关闭指定端口

来源:互联网 发布:c语言void的应用 编辑:程序博客网 时间:2024/06/06 05:30
1.如何查看和关闭指定端口


  [root@izwz9do9adfsdfsdlqvmhe7m1werpz ~]# lsof -i:80
  COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  AliYunDun 1438  root   11u  IPv4  14853      0t0  TCP izwz9do9alqvmhe7m1werpz:60002->106.11.68.13:http (ESTABLISHED)
  nginx     7888  root    6u  IPv4  48078      0t0  TCP *:http (LISTEN)
  nginx     7889 nginx    6u  IPv4  48078      0t0  TCP *:http (LISTEN)
  [root@izwz9do9alqvmhe7m1werpz ~]# kill -9 pid 


  错误如下:[root@iZuf6dxmwcwsdfsdf964uszjjtk9Z ~]# lsof -i:80
             -bash: lsof: command not found
  解决方案 :yum install lsof 执行命令 即可  


     Loaded plugins: fastestmirror
     Setting up Install Process
     Determining fastest mirrors
     base                                                                                                                                                                    | 3.7 kB     00:00     
     base/primary_db                                                                                                                                                         | 4.7 MB     00:04     
     epel                                                                                                                                                                    | 4.3 kB     00:00     
     epel/primary_db                                                                                                                                                         | 5.9 MB     00:05     
     extras                                                                                                                                                                  | 3.4 kB     00:00     
     extras/primary_db                                                                                                                                                       |  29 kB     00:00     
     updates                                                                                                                                                                 | 3.4 kB     00:00     
     updates/primary_db                                                                                                                                                      | 1.4 MB     00:01     
     Resolving Dependencies
     --> Running transaction check
     ---> Package lsof.x86_64 0:4.82-5.el6 will be installed
     --> Finished Dependency Resolution


     Dependencies Resolved


     ===============================================================================================================================================================================================
     Package                                     Arch                                          Version                                           Repository                                   Size
     ===============================================================================================================================================================================================
     Installing:
     lsof                                        x86_64                                        4.82-5.el6                                        base                                        324 k


     Transaction Summary
     ===============================================================================================================================================================================================
     Install       1 Package(s)


     Total download size: 324 k
     Installed size: 900 k
     Is this ok [y/N]: y
     Downloading Packages:
     lsof-4.82-5.el6.x86_64.rpm                                                                                                                                              | 324 kB     00:00     
     Running rpm_check_debug
     Running Transaction Test
     Transaction Test Succeeded
     Running Transaction
     Installing : lsof-4.82-5.el6.x86_64                                                                                                                                                      1/1 
     Verifying  : lsof-4.82-5.el6.x86_64                                                                                                                                                      1/1 


     Installed:
     lsof.x86_64 0:4.82-5.el6                                                                                                                                                                     


     Complete!

原创粉丝点击