Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
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. –  TAFKA 'goldilocks' Mar 12 '13 at 20:00
    
@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. –  Stephane Chazelas Mar 12 '13 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). –  TAFKA 'goldilocks' Mar 12 '13 at 20:38
    
You meant reduce the count of available tty? –  warl0ck Mar 13 '13 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 –  ngwdaniel Mar 13 '13 at 17:06
add comment

2 Answers

"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 getty@ttyX.service

  • Replace X with the tty number you would like to close
    • If [F4] was used to switch to the tty then the service is named getty@tty4.service.
  • 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
    • # systemctl stop getty@tty4.service
  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 getty@.service for tty4
    • systemctl status getty@tty4.service | 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)
share|improve this answer
    
thank you for your reply and helping me in the learning process! –  ngwdaniel Mar 13 '13 at 17:10
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.