I've opened several ttys and I don't know the key combination to use to close a tty. I'm using Arch Linux.
2 Answers
"Closing" a TTY
- If
systemd
is not theinit
being used then this will not help you. sysvinit
is no longer supported by Arch Linux
systemd
's systemctl
is used to control all the service units
on the system. To learn more about it reference man systemd.unit
. Stopping the getty
service on the desired tty
will perform the task in question. Below is the command to perform this action and I've also added a test so you can comfirm the results.
# systemctl stop [email protected]
- Replace
X
with thetty
number you would like to close- If [F4] was used to switch to the
tty
then the service is named[email protected]
.
- If [F4] was used to switch to the
- This procedure will also close all applications/clients ran from the specified
tty
.
Test
- Switch to
tty4
and enter yourusername
andpassword
.<CTRL>+<ALT>+[F4]
- Launch your favorite text editor
vim foo.bar
- Switch back to
tty1
or whichevertty
you were originally in<CTRL>+<ALT>+[F1]
- Open a terminal window and check if
vim
is runningpgrep vim
pgrep
returns the signal process number of the specified application. Multiple numbers will be returned if there are multiple instances of the same application- (if there are four terminal windows open then
pgrep
will output four process numbers)
- (if there are four terminal windows open then
- As root stop the
getty
service fortty4
# systemctl stop [email protected]
- Recheck if
vim
is still active ontty4
where it was opened and editingfoo.bar
pgrep vim
(if there is no output/less output than in step 4, then there is no process)
- Double check the status of the
[email protected]
fortty4
systemctl status [email protected] | grep -i "Active"
- Piping the output to
grep -i "Active"
will only output the required line that you'll need to observe to confirm thegetty
has been disabledActive: inactive (dead)
- Piping the output to
-
u can use
who
command to list currently logged users and tty numbers.– DjordjeCommented Feb 15, 2019 at 11:30
I believe it's the deallocvt
command you're looking for.
First make sure the VT is no longer used. For instance, if there's a getty
started with respawning by init
on that console, there's no point trying to deallocate it, you'd need to remove that tty from the inittab
first and tell init
to reload its config. If there's a shell, exit the shell, etc.
exit
. If you are not logged in, don't worry. It was there before, just you weren't looking at it.init
and X generally allocate the next ones, but you can allocate more. Opening the/dev/ttyx
device is enough to allocate it.