[root@study ~]#
systemctl show getty.target
#
show
的指令可以
½
getty.target
的默
认设
定值也取出
来显
示!
Names=getty.target
Wants=getty@tty1.service
WantedBy=multi
-
user.target
Conflicts=shutdown.target
Before=multi
-
user.target
After=
getty@tty1.service getty@tty2.service getty@tty3.service getty@tty4.service
getty@tty6.service getty@tty5.service
.....(
后面省略
).....
你会发现,咦!怎么会多出六个怪异的
service
呢?我们拿
getty@tty1.service
来说明一下好了!当
我们执行完
getty.target
之后,
他会持续要求
getty@tty1.service
等六个服务继续启动。那我们的
systemd
就会这么作:
.
先看
/usr/lib/systemd/system/, /etc/systemd/system/
有没有
getty@tty1.service
的设定,若有就执行,若没有
则执行下一步;
.
getty@.service
的设定,若有则½
@
后面的数据带入成
%I
的变量,½入
getty@.service
执行!
这也就是说,其实
getty@tty1.service
实际上是不存在的!他主要是透过
getty@.service
来执行~也
就是说,
getty@.service
的目的是为了要简化多个执行的启动设定,
他的命名方式是这样的:
源文件:
行服
@.service
文件
行服
@
范例名
.service
因此当有范例名称带入时,则会有一个新的服务名称产生出来!你再回头看看
getty@.service
的启动
½本:
ExecStart=
-
/sbin/agetty
--
noclear %I $TERM
上表中那个
%I
指的就是『范例名称』!根据
getty.target
的信息输出来看,
getty@tty1.service
%I
就是
tty1
啰!因此执行½本就会变成『
/sbin/agetty --noclear tty1
』!
所以我们才有办法以一个配
置文件来启动多个
tty1
给用户登入啰!
.
½
tty
的数量由
6
个½低到
4
现在你应该要感到困扰的是,那么『
6
tty
是谁规定的』为什么不是
5
个还是
7
个?这是因为
systemd
的登入配置文件
/etc/systemd/logind.conf
里面规范的啦!
假如你想要让
tty
数量½低到剩
4
个的话,那么可以这样实验看看:
# 1.
修改
预设
logind.conf
容,
½
原本
6
个虚拟终
端机改成
4
[root@study ~]#
vim /etc/systemd/logind.conf
[Login]