歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux 初始化系統配置(CentOS 6)

Linux 初始化系統配置(CentOS 6)

日期:2017/2/28 15:45:43   编辑:Linux教程
Linux 初始化系統配置(CentOS 6) ,在配置服務器之前一般都需要根據自己的需要對系統進行初始化的一些工作,我自己在配置服務器之前都會做些初始化的配置 這裡主要包括5個設置:

1. 限制某些用戶使用su命令

2. 限制只能wheel組能使用sudo命令

3. 演示讓普通用戶使用root命令(自己玩的使用)

4. 配置服務 關閉一些你不需要的服務

5. 更新yum在線庫 尋找最快的軟件倉庫

6. 關閉SELINUX

7. 對linux的文件權限補充(對於服務器配置來說很重要的知識點)

1 控制cent用戶能使用su 命令 登入root用戶

[root@bogon ~]# useradd cent 添加用戶
[root@bogon ~]#
passwd cent 設置密碼一樣

[root@bogon ~]#
vi /etc/group 編輯cent為wheel組

wheel:x:10:root,cent

[root@bogon ~]#
vi /etc/pam.d/su 編輯只能wheel組的用戶能使用su命令

auth required pam_wheel.so use_uid

[root@bogon ~]#
vi /etc/aliases

root:cen


------------------------------------------

2 控制只能wheel組能使用sudo命令

[root@bogon ~]# vi /etc/sudoers


root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL 添加wheel組能使用sudo命令

# Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL

下面自定義一些權限控制 比如控制所有用戶除了root都不能執行 關機 重啟命令

Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, \
/sbin/poweroff, /sbin/reboot, /sbin/init
# add ( commands in aliase 'SHUTDOWN' are not allowed )

cent ALL=(ALL) ALL,!SHUTDOWN 不能執行關機命令

sudo是linux下常用的允許普通用戶使用超級用戶權限的工具。

它的主要配置文件是sudoers,linux下通常在/etc目錄下,如果是solaris,sudo都提供了一個編輯該文件的命令:visudo來對該文件進行修改。強烈推薦使用該命令修改sudoers,因為它會幫你校驗文件配置是否正確,如果不正確,在保存退出時就會提示你哪段配置出錯的。
言歸正傳,下面介紹如何配置sudoers

首先寫sudoers的缺省配置:

################################################# #
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
##################################################

Copyright © Linux教程網 All Rights Reserved