编辑全局配置文件
在终端中编辑 vim /etc/profile 文件,在配置文件中添加 export TIME_STYLE="+%Y-%m-%d %H:%M:%S" 语句,然后保存退出。
让配置立即生效
在终端中执行 source /etc/profile 命令,让配置文件立即生效。然后通过 ll 命令查看结果。
局部代码和效果
[root@ser cert]# vim /etc/profile
1 # /etc/profile
2
3 # System wide environment and startup programs, for login setup
4 # Functions and aliases go in /etc/bashrc
5
6 # It's NOT a good idea to change this file unless you know what you
7 # are doing. It's much better to create a custom.sh shell script in
8 # /etc/profile.d/ to make custom changes to your environment, as this
9 # will prevent the need for merging in future updates.
10 export TIME_STYLE="+%Y-%m-%d %H:%M:%S"
11 pathmunge () {
12 case ":${PATH}:" in
13 *:"$1":*)
14 ;;
15 *)
16 if [ "$2" = "after" ] ; then
17 PATH=$PATH:$1
18 else
19 PATH=$1:$PATH
20 fi
21 esac
22 }
[root@ser cert]#
[root@ser cert]# source /etc/profile
[root@ser cert]# pwd
/etc/nginx/cert
[root@ser cert]# ll
total 48
-rw-r--r-- 1 root root 3851 2021-12-03 12:25:12 confluence.vfire.cn_chain.crt
-rw-r--r-- 1 root root 1675 2021-12-03 12:25:12 confluence.vfire.cn_key.key
-rw-r--r-- 1 root root 3839 2021-12-03 12:39:35 docker.vfire.cn_chain.crt
-rw-r--r-- 1 root root 1679 2021-12-03 12:39:35 docker.vfire.cn_key.key
-rw-r--r-- 1 root root 3843 2021-12-03 12:36:20 jenkins.vfire.cn_chain.crt
-rw-r--r-- 1 root root 1679 2021-12-03 12:36:20 jenkins.vfire.cn_key.key
-rw-r--r-- 1 root root 3831 2021-12-03 12:39:48 mysql.vfire.cn_chain.crt
-rw-r--r-- 1 root root 1675 2021-12-03 12:39:48 mysql.vfire.cn_key.key
-rw-r--r-- 1 root root 3680 2021-11-15 14:03:06 x.51shuxiaohan.com_chain.crt
-rw-r--r-- 1 root root 1675 2021-11-15 14:03:06 x.51shuxiaohan.com_key.key
-rw-r--r-- 1 root root 3680 2021-11-15 14:02:50 x.vfire.cn_chain.crt
-rw-r--r-- 1 root root 1675 2021-11-15 14:02:50 x.vfire.cn_key.key
[root@ser cert]#