分类 Linux 下的文章

编辑/etc/sysctl.conf,添加或者编辑以下变量:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

最后sysctl -p即可。

方法1:
rc.local文件中添加自启动命令
执行命令: 编辑"/etc/rc.local",添加你想开机运行的命令
运行程序脚本:然后在文件最后一行添加要执行程序的全路径。
例如,每次开机时要执行一个hello.sh,这个脚本放在/usr下面,那就可以在"/etc/rc.local"中加一行"/usr/./hello.sh",或者" cd /opt && ./hello.sh "
注意,你的命令应该添加在:exit 0 之前

方法2:
在/etc/init.d目录下添加自启动脚本
linux在"/etc/rc.d/init.d"下有很多的文件,每个文件都是可以看到内容的,其实都是一些shell脚本或者可执行二进制文件
Linux开机的时候,会加载运行/etc/init.d目录下的程序,因此我们可以把想要自动运行的脚本放到这个目录下即可。
系统服务的启动就是通过这种方式实现的。

方法3:
systemctl命令
使某服务自动启动 systemctl enable httpd.service
使某服务不自动启动 systemctl disable httpd.service
检查服务状态 systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active)
显示所有已启动的服务 systemctl list-units --type=service
启动某服务 systemctl start httpd.service
停止某服务 systemctl stop httpd.service
重启某服务 systemctl restart httpd.service
例子:
启动nfs服务 systemctl start nfs-server.service
设置开机自启动 systemctl enable nfs-server.service
停止开机自启动 systemctl disable nfs-server.service
查看服务当前状态 systemctl status nfs-server.service
重新启动某服务 systemctl restart nfs-server.service
查看所有已启动的服务 systemctl list -units --type=service
开启防火墙22端口 iptables -I INPUT -p tcp --dport 22 -j accept
彻底关闭防火墙:
sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service

方法4:(接方法2)
安装sysv-rc-conf
apt-get update
apt-get install sysv-rc-conf
运行sysv-rc-conf可视化启动init.d目录下的脚本

参考链接:
https://m.php.cn/article/480523.html
https://blog.csdn.net/ieeso/article/details/110920105
https://blog.csdn.net/love_521_/article/details/123484257

编辑ssh配置文件
nano /etc/ssh/sshd_config

PermitRootLogin prohibit-password
改为
PermitRootLogin yes

PasswordAuthentication no
改为
PasswordAuthentication yes

保存后重启ssh服务
service sshd restart

获取root权限与修改root密码
sudo -i
passwd root

最后(离题),怼掉防火墙,你懂的

开放所有端口

sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F

Oracle自带的Ubuntu镜像默认设置了Iptable规则,关闭它

apt-get purge netfilter-persistent
reboot

强制删除

rm -rf /etc/iptables && reboot