20

I've opened several ttys and I don't know the key combination to use to close a tty. I'm using Arch Linux.

5
  • 2
    You didn't open them, they're open. You just changed VT. If you want to log out from one of them, use exit. If you are not logged in, don't worry. It was there before, just you weren't looking at it.
    – goldilocks
    Commented Mar 12, 2013 at 20:00
  • 1
    @goldilocks, VTs can be dynamically allocated and closed. The first one is always allocated when the console is on it, init and X generally allocate the next ones, but you can allocate more. Opening the /dev/ttyx device is enough to allocate it. Commented Mar 12, 2013 at 20:31
  • @StephaneChazelas : Fair enough. I was just inferring from "using key combinations" that ngwdaniel actually did not start anything that init hadn't spawned already. If so, there's no need to close those (and as you point out in your answer, that's not so easily done anyway).
    – goldilocks
    Commented Mar 12, 2013 at 20:38
  • You meant reduce the count of available tty?
    – daisy
    Commented Mar 13, 2013 at 1:49
  • @goldilocks thank you, this is the answer I was looking for. I'm a silly beginner and I thought it was me who opened the ttys by <Alt> + <F2> etc
    – daniel
    Commented Mar 13, 2013 at 17:06

2 Answers 2

15

"Closing" a TTY

  • If systemd is not the init 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 the tty number you would like to close
  • This procedure will also close all applications/clients ran from the specified tty.

Test

  1. Switch to tty4 and enter your username and password.
    • <CTRL>+<ALT>+[F4]
  2. Launch your favorite text editor
    • vim foo.bar
  3. Switch back to tty1 or whichever tty you were originally in
    • <CTRL>+<ALT>+[F1]
  4. Open a terminal window and check if vim is running
    • pgrep 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)
  5. As root stop the getty service for tty4
  6. Recheck if vim is still active on tty4 where it was opened and editing foo.bar
    • pgrep vim (if there is no output/less output than in step 4, then there is no process)
  7. Double check the status of the [email protected] for tty4
    • 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 the getty has been disabled
        • Active: inactive (dead)
1
  • u can use who command to list currently logged users and tty numbers.
    – Djordje
    Commented Feb 15, 2019 at 11:30
7

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .