Open In App

Commands in Unix when things go wrong

Last Updated : 30 Jan, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads