There are a lot of control sequences available on Linux systems -- maybe even some you've never used. Credit: Ben Patterson / IDG There are quite a few control sequences available on Linux systems— many I use routinely, and some I’ve only just recently discovered— and they can be surprisingly useful. In today’s post, we’re going to run through a series of them and take a look at what they do and how they might be useful. To start, unless you’re brand spanking new to the command line, you are undoubtedly familiar with the ctrl-c sequence that is used to terminate a running command. In print, this same sequence might be expressed as ^c or control-c and sometimes the “c” will be capitalized, but the expression always means “hold the control key and press the key specified — with no shift key or hyphen involved. The ctrl-d sequence closes the terminal window or end terminal line input. $ cat > file yadda yadda yadda yadda ^d $ cat file yadda yadda yadda yadda You may have never tried ctrl-u. This control sequence and its “partner in crime” ctrl-y work together in an interesting way. The ctrl-u sequence removes the text you’ve just typed from command line and places it in something of a clipboard while ctrl-y puts in back. So, when you’ve just typed a complicated command, but not yet hit return, and then realize that you need to run some other commands first, you can save the command you’ve typed, take care of whatever other commands you need to run and then yank the command you saved back into place. $ gensched 07-2018 IT summary^u ^y The ctrl-s and ctrl-q sequences also have a working relationship. Where ctrl-s freezes your screen, ctrl-q allows the display to continue rolling again. $ bin/loop sleeping sleeping ^s ^q sleeping sleeping The ctrl-z sequence suspends the current process. You can bring it back to life with the fg (foreground) command or have the suspended process run in the background by using the bg command. If you then want to stop the process, you'll then have to list your background processes with the jobs command and use kill (e.g., kill %1). Don't forget the % that specifies the process by job number rather than its PID. $ bin/loop sleeping ^Z [1]+ Stopped bin/loop $ bg [1]+ bin/loop & $ sleeping jobs [1]+ Running bin/loop & $ sleeping $ kill %1 The ctrl-h, ctrl-w and ctrl-u sequences erase (i.e., back over) the last letter you just typed, the last word that you just typed, or the entire line. The ctrl-a and ctrl-e will move your cursor to the beginning or end of the text you have just typed. The ctrl-r sequence allows you to easily rerun recently entered commands. Type ctrl-r followed by the beginning of the command that you want to rerun. The command run will be the most recent one that began with the letters you enter. Control sequences can be handy if you can keep them straight. Here's a quick rundown of the control sequences just covered: ctrl-c interrupts the running program ctrl-d sends an EOF (end of file) to close the terminal ctrl-z suspends the running program ctrl-s freezes the screen, stopping the display ctrl-q thaws out the screen and allows the screen display to continue ctrl-h deletes the last character typed ctrl-w deletes the last word typed ctrl-u deletes the last line typed ctrl-r retrieves previously run commands so you can run them again ctrl-u removes text from the command line and places it in the clipboard ctrl-y grabs text from the clipboard and runs it ctrl-l clears the screen ctrl-a moves cursor to the beginning of the line ctrl-e moves cursor to the end of the line You can take control of control sequences that aren't behaving as expected with a command like this one that reasserts ctrl-h as the erase sequence. stty erase ^h Note that the stty -a command will list your control sequences: $ stty -a | grep eof intr = ^C; quit = ^; erase = ^H; kill = ^U; eof = ^D; eol = ; More on the stty command is available at Using stty to your advantage. The only difficult part of using control sequences is remembering which does what. For some, the letter suggests the control sequence function. For others ... well, not so much. But they can all be very useful. Related content news analysis What is SONiC and how can enterprises try the open-source NOS? Software for Open Networking in the Cloud (SONiC) is an open-source networking operating system that has the potential to become 'the Linux of networking,' experts say. By Michael Cooney Jul 17, 2024 12 mins Open Source Networking news analysis OpenELA group pushes for bug compatibility with RHEL The world of enterprise Linux developers has been roiled of late by a dispute between Red Hat and several companies that sell support for similar distributions. By Jon Gold Aug 24, 2023 4 mins Red Hat Linux Open Source news Red Hat rivals form Open Enterprise Linux Association Oracle, SUSE and CIQ will form the Open Enterprise Linux Association, in response to changes at Red Hat that have upset the enterprise Linux ecosystem. By Jon Gold Aug 11, 2023 3 mins Linux Open Source news analysis SONiC test lab gains industry support Open Network Experience Center (ONE Center) for SONiC is being run by Aviz Networks with support from Cisco, Nvidia, Open Compute project, Supermicro, and others. By Michael Cooney Apr 19, 2023 3 mins Cisco Systems Linux Open Source PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe