1、开放端口号:
直接编辑/etc/sysconfig/iptables文件
1.编辑/etc/sysconfig/iptables文件:vi /etc/sysconfig/iptables
加入内容并保存:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
2.重启服务:/etc/init.d/iptables restart
3.查看端口是否开放:/sbin/iptables -L -n
但是我用方法一一直保存不上,查阅网上发现直接修改文件不需要iptables save,重启下iptables 重新加载下配置。iptables save 是将当前的iptables写入到/etc/sysconfig/iptables。我不save直接restart也不行,所以还是方法二吧
查询端口是否有进程守护用如下命令grep对应端口,如80为端口号
例:netstat -nalp|grep 80
2、端口号占用命令查询:
netstat -ntupl|grep processname (processname :进程名称。)
netstat -anop | grep pid (pid:进程id。)
3、批量删除进程
ps -ef|grep client|grep -v grep|cut -c 9-15|xargs kill -9 (批量删除进程)
4、ubuntu下使用root用户登录
vi /etc/ssh/sshd_config文件
找到:PermitRootLogin prohibit-password 注释掉
添加:PermitRootLogin yes
sudo service ssh restart 重启ssh
5、su: Authentication failure
su命令不能切换root,提示su: Authentication failure,只要你sudo passwd root过一次之后,下次再su的时候只要输入密码就可以成功登录了。
6、解决Ubuntu中Unable to acquire the dpkg
重启 系统
sudo systemctl --force --force reboot
这个会重新启动系统,所以使用前先保存一下需要保存的文件,这个方法是可行的
7、ubuntu下buff/cache占用过大处理
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches