Commands in Unix when things go wrong
Last Updated :
30 Jan, 2019
Terminals and keyboards has no uniform behavioral pattern. There are some commands to wriggle out of some common traps. You must know which keys you need to press when things don't quite work as expected.
1. Backspacing doesn't work: Consider you misspelled command
stty as
ssty and when you press
backspace to erase the command, an unexpected symbol(^?) are printed:
$ stty^?^?^?^?^?^?^?
Backspacing is not working here, that's why
^? is printed whenever we pressed backspace. To get rid of this unexpected behavior, we can use any of the following keys:
[Ctrl-c] OR [Delete]
2. Killing a line: If a command line contains many mistakes, a person will prefer to kill or erase the line instead of executing it. For this we have to press:
[Ctrl-u]
Above command kills everything in a line and returns the cursor to the beginning of the line.
3. Interrupt command: Sometimes a program goes into infinite loop. We can interrupt the program and bring back the prompt by using either of the following keys:
[Ctrl-c] OR [Delete]
This a important command and always recommended to use this in case of anything goes wrong.
NOTE: If delete works as a erase character on your machine then it doesn't work as interrupt key at the same time.
4. Terminating command's input: As we know that
cat command require at least one filename as an argument. What will happen if we doesn't give any file name as an argument and simply press enter:
$ cat
..
Nothing happens, terminal waits for us to enter something. To bring back the prompt, in case of commands that expect user input, either of the following keys are used:
[Ctrl-d] OR [Ctrl-c]
5. Lock Keyboard: For locking the keyboard,
[Ctrl-s] command is used. After this you wouldn't able to insert anything on the terminal. For restoring keyboard normal operation,
[Ctrl-q] command is used.
6. When [Enter] key doesn't work: Enter key is used to complete the command line or to run the command. If this doesn't work, we can use any of the following commands:
[Ctrl-j] OR [Ctrl-m]
These keys generate the linefeed and carriage return characters respectively.

Don't surprised if some of the commands behaves differently in your system. Much of the Unix is configurable by the user, you can use
stty command to change these settings.
References: Unix Concepts And Applications - Das, Sumitabha
Similar Reads
Sed Command in Linux/Unix With Examples The SED command (short for Stream Editor) is one of the most powerful tools for text processing in Linux and Unix systems. It's commonly used for tasks like search and replace, text transformation, and stream editing.With SED, you can manipulate text files without opening them in an editor. This mak
8 min read
while Command in Linux with Example The "while" command is a powerful tool in the Linux shell that allows you to execute a series of commands repeatedly based on a given condition. It is commonly used in shell scripts to create loops, where a block of code is executed as long as a particular condition remains true. Basic Syntax of Whi
6 min read
Fun Commands in Linux Linux isn't just for coding and administrationâit can also be a lot of fun. With a variety of terminal commands, you can add some entertainment to your Linux experience. Below is a list of some cool and fun commands you can use in Linux to enhance your terminal experience. Weâll also cover how to in
3 min read
Essential Unix Commands Unix commands are a set of commands that are used to interact with the Unix operating system. Unix is a powerful, multi-user, multi-tasking operating system that was developed in the 1960s by Bell Labs. Unix commands are entered at the command prompt in a terminal window, and they allow users to per
7 min read
if command in linux with examples if command in Linux is used for conditional execution in shell scripts.The if command is essential for writing scripts that perform different actions based on different conditions.if COMMANDS list is executed, if its status is true, then the then COMMANDS list is executed. Otherwise, each elif COMMA
4 min read
Linux command in DevOps DevOps engineers use Linux every day because itâs free, fast, and easy to customize. More importantly, most DevOps tools like Docker, Kubernetes, Ansible, Terraform, and Jenkins are built to run best on Linux.In DevOps, you often work on cloud servers (like AWS, Azure, or Google Cloud), and most of
9 min read
fc Command in Linux with Examples As we all know that LINUX is command friendly and while working on LINUX, you may deal with very long commands that may include long paths or really difficult syntax, and imagine what if working with such commands you do a minor mistake which will require re-writing of the entire command synopsis an
3 min read
ls Command in Linux The ls command is one of the most used commands in the Linux terminal to display the files and directories or path in the terminal. So, using the ls command is a basic skill for navigating the Linux file system, handling files, and managing directories.What is the ls Command in LinuxThe ls command i
10 min read
help Command in Linux with examples If youâre new to the Linux operating system and struggling with command-line utilities, the help command is one of the first tools you should learn. As its name suggests, the 'help' command provides detailed information about built-in shell commands, making it an essential resource for beginners and
5 min read