一、设置自动登录图形化操作界面
/etc/gdm/custom.conf
修改内容:
AutomaticLoginEnable=true
AutomaticLogin=root
# GDM configuration storage
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=root
[security]
[xdmcp]
[chooser]
[debug]
# Uncomment the line below to turn on debugging
#Enable=true
二、CentOS7设置网卡开机启动
/etc/sysconfig/network-scripts/ifcfg-ens*
修改内容:
ONBOOT=yes
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=e45d27e9-3a33-4519-9017-ea203a722571
DEVICE=ens33
ONBOOT=yes
使生效:
systemctl restart network
三、修改系统语言编码
/etc/sysconfig/i18n
修改内容:
LANG="en_US.UTF-8"
LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
使生效:
source /etc/sysconfig/i18n
四、设置登录系统后提示信息
/etc/motd
修改内容:
Hello world!
Hello world!
五、永久修改命令提示符
/etc/profile.d/env.sh
默认不存在,需要手工创建。
该文件还可以写入其他命令的环境变量参数。
修改内容:
PS1="[\e[1;32m][\u@\h \w]\$[\e[0m]"
PS1="\[\e[1;32m\][\u@\h \w]\\$\[\e[0m\]"
六、永久定义命令别名
/home/USERNAME/.bashrc
/etc/bashrc
修改内容:
alias rm='rm -i'
alias cp='cp -i --backup=numbered'
alias mv='mv -i'
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias rm='mv -t /recycle/'
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i --backup=numbered'
alias mv='mv -i'
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias rm='mv -t /recycle/'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
使生效:
source .bashrc
七、修改命令行历史最多存储数
/etc/profile
修改内容:
HISTSIZE=1000
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
八、设置登录系统前提示信息
/etc/issue
修改内容:
Hostname is /n
CentOS release 6.9 (Final)
Kernel \r on an \m
Hostname is \n
九、修改用户相关设置
用户邮件文件路径、密码最长有效期、密码最短有效期、密码长度、密码警告期、普通用户ID起始、普通用户ID结束、系统用户ID起始、系统用户ID结束、组ID起始、组ID结束、默认创建家目录、密码加密算法
/etc/login.defs
修改内容:
MAIL_DIR /var/spool/mail
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
GID_MIN 1000
GID_MAX 60000
SYS_UID_MIN 201
SYS_UID_MAX 999
GID_MIN 1000
GID_MAX 60000
CREATE_HOME yes
ENCRYPT_METHOD SHA512
#
# Please note that the parameters in this configuration file control the
# behavior of the tools from the shadow-utils component. None of these
# tools uses the PAM mechanism, and the utilities that use PAM (such as the
# passwd command) should therefore be configured elsewhere. Refer to
# /etc/pam.d/system-auth for more information.
#
# *REQUIRED*
# Directory where mailboxes reside, _or_ name of file, relative to the
# home directory. If you _do_ define both, MAIL_DIR takes precedence.
# QMAIL_DIR is for Qmail
#
#QMAIL_DIR Maildir
MAIL_DIR /var/spool/mail
#MAIL_FILE .mail
# Password aging controls:
#
# PASS_MAX_DAYS Maximum number of days a password may be used.
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a password expires.
#
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
#
# Min/max values for automatic uid selection in useradd
#
UID_MIN 1000
UID_MAX 60000
# System accounts
SYS_UID_MIN 201
SYS_UID_MAX 999
#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN 1000
GID_MAX 60000
# System accounts
SYS_GID_MIN 201
SYS_GID_MAX 999
#
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
#
#USERDEL_CMD /usr/sbin/userdel_local
#
# If useradd should create home directories for users by default
# On RH systems, we do. This option is overridden with the -m flag on
# useradd command line.
#
CREATE_HOME yes
# The permission mask is initialized to this value. If not specified,
# the permission mask will be initialized to 022.
UMASK 077
# This enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes
# Use SHA512 to encrypt password.
ENCRYPT_METHOD SHA512
十、新用户默认设置
用户默认属于的主组、密码宽限期、用户有效期、新建用户shell类型、新建用户家目录模板目录
/etc/default/useradd
修改内容:
GROUP=100
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
十一、永久修改文件默认权限
/home/USERNAME/.bashrc
/etc/bashrc
修改内容:
umask 251
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i --backup=numbered'
alias mv='mv -i'
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias rm='mv -t /recycle/'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
umask 251
使生效:
source .bashrc
十二、vim配置文件
设置编辑.sh后缀的文件时忽略大小写、光标线、自动缩进,自动填写作者名、QQ号、日期、文件名、链接、备注、版权。
/USERNAME/.vimrc
修改内容:
set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: KKK")
call setline(5,"#QQ: 123456789")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#URL: http://www.kkk.com")
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G
set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: KKK")
call setline(5,"#QQ: 123456789")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#URL: http://www.kkk.com")
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G