Linux中的常用命令

 常用命令

[root@localhost /]# ls             #列出文件
[root@localhost /]# cp             #复制文件
[root@localhost /]# cp name /home/tomcat   #cp+文件名+复制地点
[root@localhost /]# mv               #移动和重命名
[root@localhost /]# mv name /tmp         #将name文件移动到tmp文件夹下
[root@localhost /]# mv name age          #将name文件改名为age
[root@localhost /]# rm name            #删除文件name
[root@localhost /]# rm *             #删除当前文件下的所有文件
[root@localhost /]# rm -rf tomcat              #删除tomcat目录以及目录下的所有东西
[root@localhost /]# cd                 #切换目录
[root@localhost /]# mkdir              #创建文件夹
[root@localhost /]# tar -zxvf file.tar.gz      #解压tar.gz文件
[root@localhost /]# tar -xvf  file.tar       #解压tar包
[root@localhost /]# unzip file.zip         #解压zip包
[root@localhost /]# ps -ef|grep java            #查看java进程
[root@localhost /]# kill -9  端口号     #杀死进程
[root@localhost /]# ./startup.sh       #启动tomcat
[root@localhost /]# ./shutdown.sh      #关闭tomcat
[root@localhost /]# netstat -ntlp      #查看所有端口号
[root@localhost /]# lsof -i:端口号      #查看某一端口号
[root@localhost /]# ls -al             #查看隐藏目录
[root@localhost /]# systemctl start/stop/restart nginx
[root@localhost /]# nohup java -jar xxxx.jar &    #启动Jar包

[root@localhost /]# zip all.zip *.jpg    #将所有.jpg的文件压缩成一个zip包
[root@localhost /]# unzip all.zip    #将all.zip中的所有文件解压到当前目录中
[root@localhost /]# unzip all.zip -d all #将all.zip 中的所有文件解压到当前目录中的all文件夹中
[root@localhost /]# zip -r hy.zip hy  #将当前目录下的hy文件夹压缩为hy.zip
[root@localhost /]# zip -r hy.zip hy 123.txt  #将当前目录下的hy文件夹和123.txt压缩为hy.zip

 

curl命令

[root@localhost /]# curl -H "Content-type: application/json" -X POST -d '[{"a":"","b":1,"c":"","d":2,"e":1658717119,"f":100}]' http://ip:8080/demo/test  #服务器上POST请求接口测试

 

防火墙

centos7默认的防火墙是firewalld防火墙,不是使用iptables,因此需要先关闭firewalld服务,或者干脆使用默认的firewalld防火墙。

1.关闭firewalld:

  • systemctl stop firewalld
  • systemctl mask firewalld

2.使用iptables服务:

  • 开放443端口(HTTPS):iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  • 保存上述规则:service iptables save
  • 开启服务:systemctl restart iptables.service

3.上面操作完成后使用下面命令:

  • 查看到iptables服务的当前状态状态:service iptables status
  • 重启后生效 :
  1. 开启: chkconfig iptables on
  2. 关闭: chkconfig iptables off
  • 即时生效,重启后失效:
  1. 开启: service iptables start
  2. 关闭: service iptables stop

 

posted @ 2019-04-17 16:48  21karat  阅读(154)  评论(0)    收藏  举报