Bash (Unix shell)

The Best Keyboard Shortcuts for Bash (aka the Linux and macOS Terminal)

Bash is the default command-line shell on most Linux distributions, from Ubuntu and Debian to Red Hat and Fedora. Bash is also the default shell included with macOS, and you can install a Linux-based bash environment on Windows 10.

The bash shell features a wide variety of keyboard shortcuts you can use. These will work in bash on any operating system. Some of them may not work if you’re accessing bash remotely through an SSH or telnet session, depending on how you have your keys mapped.

Want to Learn More? Get Linux Training from the Linux Foundation

Learn everything you could want to know about Linux with comprehensive online Linux courses and certification tests that include the real-world experience and first-hand knowledge of what it takes to be a successful Linux developer or system administration professional, all from a web browser in the comfort of your home.

The Linux Foundation is the nonprofit consortium dedicated to fostering the growth of Linux. Founded in 2000, they are supported by the leading technology companies and developers from around the world.

Working With Processes

Use the following shortcuts to manage running processes.

  • Ctrl+C: Interrupt (kill) the current foreground process running in in the terminal. This sends the SIGINT signal to the process, which is technically just a request—most processes will honor it, but some may ignore it.
  • Ctrl+Z: Suspend the current foreground process running in bash. This sends the SIGTSTP signal to the process. To return the process to the foreground later, use the fg process_name command.
  • Ctrl+D: Close the bash shell. This sends an EOF (End-of-file) marker to bash, and bash exits when it receives this marker. This is similar to running the exit command.

Controlling the Screen

The following shortcuts allow you to control what appears on the screen.

  • Ctrl+L: Clear the screen. This is similar to running the “clear” command.
  • Ctrl+S: Stop all output to the screen. This is particularly useful when running commands with a lot of long, verbose output, but you don’t want to stop the command itself with Ctrl+C.
  • Ctrl+Q: Resume output to the screen after stopping it with Ctrl+S.

Moving the Cursor

Use the following shortcuts to quickly move the cursor around the current line while typing a command.

  • Ctrl+A or Home: Go to the beginning of the line.
  • Ctrl+E or End: Go to the end of the line.
  • Alt+B: Go left (back) one word.
  • Ctrl+B: Go left (back) one character.
  • Alt+F: Go right (forward) one word.
  • Ctrl+F: Go right (forward) one character.
  • Ctrl+XX: Move between the beginning of the line and the current…

What’s the Difference Between Bash, Zsh, and Other Linux Shells?

Most Linux distributions include the bash shell by default, but you could also switch to another shell environment. Zsh is a particularly popular alternative, and there are other shells, like ash, dash, fish, and tcsh. But what’s the difference, and why are there so many?

What Do Shells Do?

When you sign in at the command line or launch a terminal window on Linux, the system launches the shell program. Shells offer a standard way of extending the command line environment. You can swap out the default shell for another one, if you like.

The first shell environment was the Thompson Shell, developed at Bell Labs and released in 1971. Shell environments have been building on the concept ever since, adding a variety of new features, functionality, and speed improvements.

For example, Bash offers command and file name completion, advanced scripting features, a command history, configurable colors, command aliases, and a variety of other features that weren’t available back in 1971 when the first shell was released.

The shell is also used in the background by various system services. Linux distributions include many functions written as shell scripts. These scripts are commands and other advanced shell scripting functions run through the shell environment.

Shells Leading Up to Bash: sh, csh, tsh, and ksh

The most prominent progenitor of modern shells is the Bourne shell—also known as “sh”—which was named after its creator Stephen Bourne who worked at AT&T’s Bell Labs. Released in 1979, it became the default command-interpreter in Unix because of its support for command substitution, piping, variables, condition testing, and looping, along with other features. It did not offer much customization for users, and didn’t support such modern niceties as aliases, command completion, and shell functions (though this last one was eventually added).

The C shell, or “csh”, was developed in the late 1970s by Bill Joy at University of California, Berkley. It added a lot of interactive elements with which users could control their systems, like aliases (shortcuts for long commands), job management abilities, command history, and more. It was modeled off the C programming language, which the Unix operating system itself was written in. This also meant that users of the Bourne shell had to learn C so they could enter commands in it. In addition, csh had quite a few bugs that had to be hammered out by users and creators alike over a large period of time. People ended up using the Bourne shell for scripts because it handled non-interactive commands better, but stuck with the C shell for normal use.

Over time, lots of people fixed bugs in and added features to the C shell, culminating in an improved version of csh known as “tcsh”. But csh was still the default in Unix-based computers, and had added some non-standard features. David Korn from Bell Labs worked on the KornShell, or “ksh”, which tried to improve the situation by being backwards-compatible with the Bourne shell’s language but adding many features from the csh shell. It was released in 1983, but under a proprietary license. It wasn’t free software until the 2000s, when it was released under various open-source licenses.

The Birth of bash

The Portable Operating System Interface for Unix, or POSIX, was another response to the hectic proprietary csh implementations. It successfully created a standard for command interpretation (among other things) and eventually mirrored a lot of the features in the KornShell. At the same time, the GNU Project was attempting to create a free, Unix-compatible operating system. The GNU Project developed a free software shell to be part of its free operating system and named it the “Bourne Again Shell”,…

What Is “Developer Mode” in Windows 10?

If you dig through Windows 10’s settings, you may come across something called “Developer Mode”. When put into Developer Mode, Windows allows you to more easily test apps you’re developing, use the Ubuntu Bash shell environment, change a variety of developer-focused settings, and do other such things.

How to Enable Developer Mode

This setting is available in the Settings app. To access it, head to Settings > Update & Security > For Developers and select “Developer mode”.

Your Windows 10 PC will be put into Developer Mode. This works on all editions of Windows 10, including Windows 10 Home.

Sideload Unsigned Apps (and Debug Them in Visual Studio)

This option is located below “Windows Store apps” and “Sideload apps“. Select “Windows Store apps” and Windows will only allow you to install UWP apps from the Windows Store. Select “Sideload apps”, the default setting, and Windows will also allow you to install apps from outside the Windows Store, as long as they’re signed with a valid certificate.

But if you select “Developer mode”, you can install UWP apps from outside of the Windows Store, even if they’re not signed. This is a crucial option for UWP app developers, who will want to test their apps on their own PCs while developing them. This option replaces the need for a “developer license” on Windows 8.1.

Developer Mode also allows you to debug UWP apps in Visual Studio. In fact, if you open a UWP application project in Visual Studio without Developer Mode enabled, you’ll see an “Enable Developer Mode for Windows 10” prompt message that instructs you to enable Developer Mode. You’ll then be able to run an app in debug mode directly from Visual Studio, testing it on your PC before uploading it to the Windows Store.

Bash on Ubuntu on Windows 10

If you want to use Ubuntu’s Bash shell on Windows 10, you must first put your device into “Developer Mode”. Only once your device is in developer mode can you enable the “Windows Subsystem for Linux” and install the Ubuntu environment in Bash.

If you disable Developer Mode, the Windows Subsystem for Linux will…