3

Help! Backspace Doesn't Work in the Linux Terminal

 2 years ago
source link: https://www.makeuseof.com/backspace-not-working-in-linux-terminal/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Help! Backspace Doesn't Work in the Linux Terminal

By David Delony

Published 5 hours ago

Backspace and Tab keys might not work properly when you're logged in remotely to a Linux system. Here's how you can easily remediate this issue.

The Backspace key isn't something you normally think about too much, but sometimes you might find it doesn't work correctly in the terminal, especially when logged in to a remote machine, echoing "^H" instead of erasing what you've typed.

Fortunately, this is easy to fix with a simple command.

What Are These Weird Characters?

You may notice this problem when you log in to remote machines over SSH, ones that run non-Linux Unix operating systems, particularly proprietary systems like Oracle's Solaris. A lot of older computer terminals used a different control character for Backspace than today, using "Ctrl + H."

Modern terminals use "Ctrl + ?" for Backspace. Most systems will recognize the latter as Backspace these days as physical terminals have largely been replaced by terminal emulators on PCs, but you may still run into systems that haven't been upgraded and still expect "Ctrl + H."

This is one reason you'll see old Unix hands jokingly use "^H" in messages in the same way people use ironic strikethroughs to indicate "Oops, you weren't supposed to see that!" They might say something like "I love Linux system mangling^H^H^H^H^H^H^Hadministration."

Checking Terminal Settings with stty

Linux stty -a output in terminal

You can check what control characters the system uses with the stty command. The -a flag will give a human-readable output of the control characters.

stty -a

Look for the "erase" character. If it says "^H," then it uses the older Backspace character. Fortunately, you can also fix this with the stty command.

Setting the Erase Character

Setting erase character with stty

You can set the erase character to the one your computer uses with this simple command:

stty erase '^?'

Try this and see if the Backspace key works correctly. You can put this in the shell's startup file, such as .bashrc for Bash and .zshrc for Zsh to have this set automatically when you log into the system.

Related: What Does Bash Mean in Linux?

Similar to the Backspace key, you can fix the issue using the stty command if Tab doesn't work in the terminal.

Now Your Backspace Key Works in the Linux Terminal

Now that you've sorted out the Backspace key issue in the Linux terminal, you can really get to work.

If you're using the terminal to log in to remote systems, you can be even more productive with the combination of tmux and Mosh, letting you create sessions that can keep you connected forever.

About The Author

6053bdfb33ee5-David_Delony_Headshot.jpg?fit=crop&w=100&h=100

David Delony (87 Articles Published)

David is a freelance writer based in the Pacific Northwest, but originally hailing from the Bay Area. He has been a technology enthusiast since childhood. David's interests include reading, watching quality TV shows and movies, retro gaming, and record collecting.

More From David Delony

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

Click here to subscribe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK