码迷,mamicode.com
首页 > 其他好文 > 详细

学习笔记二 : 系统环境配置

时间:2016-08-24 17:44:59      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:rhel7 yum

一 切换环境变量为中文的方法

1.查看当前环境变量信息 

localectl list-locales 


2.设置环境变量

vi /etc/locale.conf

LANG="zh_CN.utf8"


或者

[root@server ~]# localectl set-locale LANG="en_US.UTF-8"


3.重新加载环境变量

. /etc/profile



二 时间和日期设置


timedatectl

hwclock


[root@server ~]# timedatectl

      Local time: Tue 2016-08-23 18:13:05 CST

  Universal time: Tue 2016-08-23 10:13:05 UTC

        RTC time: Tue 2016-08-23 10:13:05

        Timezone: Asia/Chongqing (CST, +0800)

     NTP enabled: n/a

NTP synchronized: no

 RTC in local TZ: no

      DST active: n/a

[root@server ~]# 



2.2 更改日期

[root@server ~]# timedatectl set-time 2017-06-02

[root@server ~]# date

Fri Jun  2 00:00:01 CST 2017

[root@server ~]#



2.3 更改时间

root@server ~]# timedatectl set-time 10:15:15

[root@server ~]# date

Fri Jun  2 10:15:17 CST 2017

[root@server ~]# 



2.3 更改时区

显示时区

timedatectl list-timezones

更改时区


[root@server ~]# timedatectl set-timezone America/Inuvik

[root@server ~]# date

Thu Jun  1 20:18:00 MDT 2017

[root@server ~]# date

Thu Jun  1 20:18:02 MDT 2017

[root@server ~]# timedatectl

      Local time: Thu 2017-06-01 20:18:06 MDT

  Universal time: Fri 2017-06-02 02:18:06 UTC

        RTC time: Fri 2017-06-02 02:18:06

        Timezone: America/Inuvik (MDT, -0600)

     NTP enabled: n/a

NTP synchronized: no

 RTC in local TZ: no

      DST active: yes

 Last DST change: DST began at

                  Sun 2017-03-12 01:59:59 MST

                  Sun 2017-03-12 03:00:00 MDT

 Next DST change: DST ends (the clock jumps one hour backwards) at

                  Sun 2017-11-05 01:59:59 MDT

                  Sun 2017-11-05 01:00:00 MST

[root@server ~]# 


2.4 date命令


date --utc



date +"format"



date +"%Y-%m-%d %H:%M"



date更改日期命令

[root@server ~]# date +%F -s 2017-08-23

2017-08-23

[root@server ~]# date

Wed Aug 23 00:00:01 MDT 2017

[root@server ~]# date +"%Y-%m-%d %H:%M"

2017-08-23 00:00

[root@server ~]# 


2.5 hwclock更改系统时间


[root@server ~]# hwclock --localtime

Fri 02 Jun 2017 02:21:26 AM MDT  -0.226614 seconds

[root@server ~]# 



设置

hwclock --set --date "2016-08-23 10:22:00"


同步

[root@server ~]# hwclock --systohc --localtime

[root@server ~]# date

Wed Aug 23 00:02:49 MDT 2017

[root@server ~]# hwclock

Wed 23 Aug 2017 12:02:56 AM MDT  -0.615255 seconds

[root@server ~]#


2.6  配置和监控chronyd

/etc/chrony.conf


systemctl restart chronyd


chronyc sources -v


2.7 案例:调整系统时间



timedatectl list-timezones


chronyc sources


chronyd  /etc/chrony.conf


timedatectl


timedatectl set-timezone


restart the chronyd service.


2.8 案例: 分析日志系统

  • 配置日志文件

  • 显示所有systemd 最近30分钟的日志来自服务器serverX

  • 配置rsyslogd规则/etc/rsyslog.d/auth-errors.conf,根据优先级,输出到/var/log/auth-errors

    使用logger命令验证




 

三 包管理


1. 检查升级包

yum check-update


yum update rpm


2.搜索包

yum search meld kompare


3.列出包

yum list all

4.列出仓库

yum repolist

yum repoinfo


yum repolist -v



yum info abrt


yumdb info yum



yum install /usr/sbin/named


5. 列出组包

yum groups summary


yum groups  list bolb


yum group list ids


yum group install roupid


yum group install "GOME Desktop"



yum history list



6. 创建一个创库

 yum install createrepo


createrepo --database /mnt/local_repo



7. 安装图形界面

yum group install "GNOME Desktop"


配置自动启动:

ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target


四 用户管理

1 usermod

-c 

-g

-G

-a

-d

-m

-s

-L      lock a user account

-U      unlock a user account


2.userdel 

userdel -r username   removes the user and the user‘s home direcotry


3. passwd

change password


4. UID

uid 0 root

uid 1-200  a range of "system users"

uid 201-999 a range of "system users"


uid 1000+ 


5. change


change -d 0 username   will force a password update on next login.

change -l username    will list a username‘s current settings.

change -e YYYY-MM-DD  will expire an account on a specific day.



6.权限

r

w

x

chmod

chown


umask


umask案例实验




五 LOG

systemd-journald  daemon provides an improved log management service that collects messages from kernel

rsyslog  service then sorts the syslog messages by type and priority,and writes them to persistent files in the /var/log directory


syslog priorities:

emerg,alert,crit,err ,warning,notice,info,debug


vi /etc/rsyslog.conf


*.emerg         /var/log/messages


2. log循环使用

可以使用 logrotate


3.send调试信息logger

logger -p local7.notice "Log entry created on server"


案例:学习自定义日志



4. journalctl


journalctl -n 5  show the last 10 log entries


journalctl -p err 


journalctl -f



journalctl --since "2016-08-20" --until "2016-09-20"


journalctl --since 9:00 _SYSTEMD_UNIT="sshd.service"


6.配置文件

/etc/systemd/journald.conf






本文出自 “痞子厨子戏子” 博客,请务必保留此出处http://chenwei.blog.51cto.com/32183/1841959

学习笔记二 : 系统环境配置

标签:rhel7 yum

原文地址:http://chenwei.blog.51cto.com/32183/1841959

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!