常用linux命令总结

Linux 版本 centos

1、查看Linux版本

uname -a

  

2、查看 ip 地址

ip addr

  

3、查看端口应用程序

netstat  -lanp

    如果输入上述命令,显示“-bash: netstat: command not found” 没有发现这条命令,就用 'yum' 安装

yum install net-tools

  

4、查看8080 端口占用程序

netstat -ntulp |grep 8080

  

5、查看防火墙状态

service iptable status

  输出结果, 显示已经防火墙已经关闭

Redirecting to /bin/systemctl status iptable.service
iptable.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)  -

 

6、安装 iptables-services

yum install iptables-services

  

7、查看已经开放的端口

firewall-cmd --list-ports

      如果显示

FirewallD is not running

   使用 ‘systemctl start firewalld’, 启动防火墙, 后续的 firwall 的操作才能使用

systemctl start firewalld

  

8、开启 80 端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

 

9、重启防火墙

firewall-cmd --reload

  

10、开放80端口

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

 

11、拷贝文件

      1)拷贝压缩文件

scp /opt/hadoop-2.4.0.tar.gz root@192.168.121.148:/opt/

  2)拷贝文件(已经解压缩过的)

scp -r  /opt/hadoop-2.4.0 root@192.168.121.148:/opt/

  

12、通过PID号查看对于进程和端口号

netstat -antup|grep 52481

  

13、查看其他IP的端口是否可以Ping通

telnet 192.168.121.131 8088

   如果 “telnet command not found”, 使用yum先安装

yum install telnet.*

  

 14、查看程序对应应用的端口

1、

netstat -antple | grep svn

2、

ps -ef | grep nginx

 15、查看端口是否有监听

netstat -an | grep 10020

  

 16、查看对应进程

ps命令将某个进程显示出来

grep命令是查找

中间的|是管道命令 是指ps命令与grep同时执行

PS是LINUX下最常用的也是非常强大的进程查看命令

grep命令是查找,是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来

ps -f|grep java