jump to navigation

How to kill an unresponsive console / terminal window on Linux February 15, 2011

Posted by Tournas Dimitrios in Linux.

My previous article made an extensive presentation how to kill any process from the terminal . Actually the same rules apply to kill a console / terminal  , because from the operating system perspective everything is a process . This article is targeted for newcomers to the Linux operating system, they will learn how to kill an unresponsive terminal .

Console and terminal both are interfaces to access the system resources , and are very powerful . It’s like riding a motorbike , you have the feeling of absolute freedom , but must be concentrated otherwise you can get troubles . A “delete all ” (rm -fR *) in the wrong directory can make your box unresponsive on the next reboot , so be concentrated🙂

Difference between a console and a virtual terminal :

Well really there is very little difference . You can pretty much do the same things with either terminal type without noticing the difference , they both run the same shell (probably BASH) based on you user settings. There are , of course , subtle differences which make them more suited for particular purposes – in X for instance , you can launch graphical apps from the command line. From the virtual console (text-mode) you can use your system without having X loaded and running (useful for resolving problems and maintenance ) , there are other differences too , but as an average user you will hardly need or notice any difference . Stick to using the X-based terminal if you have to use one – it’s more user-friendly (cut/select/paste , easy scrolling with the mouse , uses your desktop settings for input language , etc…) . The reason there are several terminals is ……. this is Linux . That means you are not tied to one tool for a job , and can exercise your own choice . You could even write your own if you want . xterm is probably used because it’s a very mature application and has seen many years trouble-free use .If you prefer to use another , then feel free to do so . Try them all out and make your own mind up . You’re free to do that ,…. welcome to Linux-land .

There are tree ways to get a terminal on a Linux box :

  1. CentOs provides six “virtual consoles” that are available to users physically at the computer .These consoles are accessed using the Ctrl-Alt-F1  through Ctrl-Alt-F6 key sequence .With one console mapped to each of the first 6 function keys . The sequense Ctrl-Alt-F7 will return you to the graphical environment where you was before trying to switch to a virtual console . You have the option to add four more consoles to you system through modifying the file /etc/inittab (later I ‘ll demonstrate how to do that ) .
  2. Terminal consoles are accessed from within the graphical environment Applications –> System tools –> Terminal . You can have as many terminal consoles as you want .
  3. Via the network (logging in ) as Rlogin or ssh-session . You can have as many as you want .

Using the who command to determine who’s on the system :

Users can use the who command to determine who is on the system , and how they logged on . From any terminal, users can type who and hit the ENTER key . This should return a similar to the following .

The who command in previous example returned the following results :

  1. “tty1”  up to “tty11” : these are 10 virtual consoles connections I made to demonstrate this functionality . In the list you will not see tty7 , because it is reserved by the graphical environment .
  2. :0 –> the graphical environment itself
  3. pts/1  : The terminal window by which we get an entry point to the virtual consoles with the sequence
    “Ctrl + Alt + Fx”
  4. pts/2 and pts/3  : Two terminals that were created by network access . In the brackets you see the IP address from which the terminals were created  . In our example both terminals were created by the same remote computer .
  5. pts/4  : Another locally created terminal

How to kill an unresponsive terminal :

My previous example demonstrated how to kill an unwanted network – terminal . Actually the same procedure can be applied to kill unresponsive terminals . An terminal can “freeze” some times  due unappropriated commands given from the user (trying to cat a binary file ) . The most obvious reaction is to “Ctrl + c ” or the command “reset” . If this key – sequence doesn’t resolve the problem then open another terminal with “Ctrl + shift + t ” ( xterminal)  or “Ctrl +Alt + F1 ….6 ” (virtual console)  and with the help of “ps  aux |grep  pts” locate the PID of the unresponsive terminal  to do the kill  ” kill -s KILL  xxxx”. Now returning to the graphical environment can be done with “Ctrl + Alt + F7 ” .

How to create extra virtual terminals :

By default each fresly installed CetntOs  has 6 virtual terminal , but if you really need more terminals ,  edit the /etc/inittab  file and restart you computer .As you see on my example I have added six more virtual consoles to the list , but Linux accepts only ten (10) . The remaining entries are just ignored .

As you explore the entries that where added in  the file /etc/inittab , for the new virtual consoles “tty x” , I skipped the the number 7 (tty7) , this because tty7 is user fro the graphical environment . The sequence Ctrl-Alt-F7 will return you to the graphical environment where you was before trying to switch to a virtual console .

Links :


No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s