Linux Terminal Control Sequences
By Bernard Peh
Linux terminals share alot in common with their primitive ancestors such as vt100 like consoles. These early devices is capable of sending sequences that signaled events outside of the normal flow of typed characters, such as escape, tab, linefeed…etc. Linux uses CTRL key to send out these out of band signals. This article summarises many of the commonly used control sequences that are used in all Linux terminals.
CTRL-C
This is the most commonly used sequence. In the bash shell, CTRL-C will terminate any currently running process and return you to the bash prompt. For example, if you accidentally run a command that does not stop, use CTRL-C to cancel the command.
CTRL-D
Many Unix commands read their input directly from the keyboard. An example is the WC command. WC counts the number of lines, words and characters that a user types in from the keyboard. So if you tpye WC at the command prompt, the command will wait for your input till you use CTRL-D to signal the end of transmission.
CTRL-Z
CTRL-Z means to suspend a program. For example, you are working with a command and you want to stop it temporary as it is taking too long. To do that, you can use CTRL-Z. You can later restore back the command using the fg command.
CTRL-U
If you have messed up a certain command and you want to start all over, instead of using backspace, you can use CTRL-U. CTRL-U resets the current line.
CTRL-H
Instead of using the backspace key, you can use CTRL-H to function the same way. Unless the backspace key is malfunctioned or mapped wrongly, this sequence serves very little purpose.
CTRL-L
If your screen is too cluttered with unwanted information, you can clear the screen using CTRL-L.
CTRL-S
Freeze your screen. This is a good command to use if you decide to go for a coffee break and do not want any process to run till you are back.
CTRL-Q
This sequence is exactly the opposite to CTRL-S. If you have freezed the screen before, you use this command to unfreeze it.
CTRL-J
Functions the same way as the RETURN key.
CTRL-G
Makes a terminal beep sound for fun and entertainment.
Control Sequences are important to all Linux / Unix users. Some sequences are important while some are useless today. It is worth memorising the first few sequences as described in this article.
Bernard Peh is a great passioner of web technologies and one of the co-founders of Sitecritic.net internet articles. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP work.
Related posts:





4 Comments to 'Linux Terminal Control Sequences'
November 15, 2009
Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.14) Gecko/2009091010 Iceweasel/3.0.14 (Debian-3.0.14-1)
Thanks for CTRL-J, I didn’t know that. When I want use keyboard without arrow buttons, I was always pissed that enter button is so far away.
Little mistake, CTRL+U delete all text from left side of the cursor.
Cheers
November 15, 2009
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.6pre) Gecko/20091112 Ubuntu/8.04 (hardy) Firefox/3.5.4
Thanks for this post. One problem I frequently have is that when I type “exit” to leave and close out a terminal session after I have used either CTRL-C or CTRL-Z (I don’t recall which), I get the error message, “There are stopped jobs.” I then type exit again and it exits / closes out my terminal session. This tells me that I am improperly cancelling / terminating / stopping processes. I want to correct this and end / exit processes properly but do not know what to do differently. Any advice, recommendations, or suggestions would be appreciated.
Thanks.
November 16, 2009
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Don’t forget Ctrl+K, which deletes all text to the right of the cursor.
November 27, 2009
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5
@stlouisubntu – use the ‘jobs’ command to list suspended jobs. Then you can either resume jobs (‘fg’ or ‘bg’), or kill them. E.g. to kill the first job do ‘kill %1′.
Leave a comment