主页 > 创业  > 

CentOs-服务器装机可用的基本操作

CentOs-服务器装机可用的基本操作

文章目录 用户操作添加用户组添加用户,指定用户组修改用户密码删除用户 文件权限操作添加文件夹更改所属组 chgrp更改文件的所属主 chown 防火墙配置关闭 selinux临时关闭生成 /etc/sysconfig/iptables 文件(如果没有)保存 /etc/sysconfig/iptables 文件修改配置文件在文件中添加新的配置 加载 iptables 已保存的配置查看当前防火墙状态 设置开机启动脚本可按账号配置启动脚本(因为某些命令需要root权限才能执行)root 账号下配置自定义账号(dpc)下配置 安装unzip命令下载rpm文件安装验证

用户操作 添加用户组 groupadd dpc 添加用户,指定用户组 useradd -g dpc dpc 修改用户密码 passwd dpc 删除用户 userdel dpc

添加 -r 参数可删除对应用户文件

文件权限操作 添加文件夹 mkdir /DATA 更改所属组 chgrp chgrp dpc /DATA/

对于文件夹可添加 -r 参数作用于文件夹及其子文件夹所有

更改文件的所属主 chown chown dpc /DATA/

对于文件夹可添加 -r 参数作用于文件夹及其子文件夹所有

防火墙配置 关闭 selinux $> vi /etc/selinux/config

把’SELINUX=enforcing’改成’SELINUX=disabled’,然后重启机器。临时关闭selinux的命令为

# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted 临时关闭 $> getenforce Enforcing $> setenforce 0 $> getenforce Permissive

getenforce命令可以得到selinux的状态,其中有两种(Enforcing|Permissive),前者表示开放,后者表示关闭,但是会发出警告。setenforce用来设置selinux的状态,后面跟0则设置成Permissive后面跟1设置成Enforcing。关闭selinux的命令为setenforce 0,但是这只是临时关闭,重启后恢复,想要永久生效,请更改配置文件/etc/selinux/config

生成 /etc/sysconfig/iptables 文件(如果没有) iptables -A INPUT -s 172.24.131.48/32 -j ACCEPT iptables -A OUTPUT -d 172.24.131.48/32 -j ACCEPT

以上代码执行后重启将失效,可通过 iptables-save 保存到文件

保存 /etc/sysconfig/iptables 文件 iptables-save > /etc/sysconfig/iptables 修改配置文件 vim /etc/sysconfig/iptables 在文件中添加新的配置 -A INPUT -s 172.24.131.48/32 -j ACCEPT -A OUTPUT -d 172.24.131.48/32 -j ACCEPT 加载 iptables 已保存的配置 iptables-restore < /etc/sysconfig/iptables 查看当前防火墙状态 iptables -L 设置开机启动脚本 crontab -e 可按账号配置启动脚本(因为某些命令需要root权限才能执行) root 账号下配置 @reboot /DATA/reboot_script_root.sh 自定义账号(dpc)下配置 @reboot /DATA/reboot_script_dpc.sh 安装unzip命令 下载rpm文件

到 .rpmfind.net/linux/rpm2html/search.php?query=unzip&submit=Search+…&system=centos&arch=下载对应发行版的对应 rpm 文件

安装 rpm -ivh unzip-6.0-22.el7_9.x86_64.rpm

这里使用 unzip-6.0-22.el7_9.x86_64.rpm (unzip 的 el7 版本进行安装),下载链接中查询可能找不到 el7 版本了,可通过其他渠道下载.

验证 unzip -v
标签:

CentOs-服务器装机可用的基本操作由讯客互联创业栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“CentOs-服务器装机可用的基本操作