一、設(shè)置自動登錄圖形化操作界面
/etc/gdm/custom.conf
修改內(nèi)容:
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設(shè)置網(wǎng)卡開機(jī)啟動
/etc/sysconfig/network-scripts/ifcfg-ens*
修改內(nèi)容:
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
三迂求、修改系統(tǒng)語言編碼
/etc/sysconfig/i18n
修改內(nèi)容:
LANG="en_US.UTF-8"
LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
使生效:
source /etc/sysconfig/i18n
四鲫剿、設(shè)置登錄系統(tǒng)后提示信息
/etc/motd
修改內(nèi)容:
Hello world!
Hello world!
五司顿、永久修改命令提示符
/etc/profile.d/env.sh
默認(rèn)不存在偏化,需要手工創(chuàng)建。
該文件還可以寫入其他命令的環(huán)境變量參數(shù)舍肠。
修改內(nèi)容:
PS1="[\e[1;32m][\u@\h \w]\$[\e[0m]"
PS1="\[\e[1;32m\][\u@\h \w]\\$\[\e[0m\]"
六、永久定義命令別名
/home/USERNAME/.bashrc
/etc/bashrc
修改內(nèi)容:
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
七窘面、修改命令行歷史最多存儲數(shù)
/etc/profile
修改內(nèi)容:
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
八翠语、設(shè)置登錄系統(tǒng)前提示信息
/etc/issue
修改內(nèi)容:
Hostname is /n
CentOS release 6.9 (Final)
Kernel \r on an \m
Hostname is \n
九、修改用戶相關(guān)設(shè)置
用戶郵件文件路徑财边、密碼最長有效期肌括、密碼最短有效期、密碼長度酣难、密碼警告期谍夭、普通用戶ID起始、普通用戶ID結(jié)束憨募、系統(tǒng)用戶ID起始紧索、系統(tǒng)用戶ID結(jié)束、組ID起始菜谣、組ID結(jié)束珠漂、默認(rèn)創(chuàng)建家目錄、密碼加密算法
/etc/login.defs
修改內(nèi)容:
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
十葛菇、新用戶默認(rèn)設(shè)置
用戶默認(rèn)屬于的主組甘磨、密碼寬限期、用戶有效期眯停、新建用戶shell類型济舆、新建用戶家目錄模板目錄
/etc/default/useradd
修改內(nèi)容:
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
十一、永久修改文件默認(rèn)權(quán)限
/home/USERNAME/.bashrc
/etc/bashrc
修改內(nèi)容:
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è)置編輯.sh后綴的文件時忽略大小寫滋觉、光標(biāo)線、自動縮進(jìn)齐邦,自動填寫作者名椎侠、QQ號、日期措拇、文件名我纪、鏈接、備注、版權(quán)浅悉。
/USERNAME/.vimrc
修改內(nèi)容:
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