Linux

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…

How to Maximize Your Linux Laptop’s Battery Life

Laptop manufacturers spend a lot of time tuning their device drivers for Windows battery life. Linux usually doesn’t get the same attention. Linux may perform just as well as Windows on the same hardware, but it won’t necessarily have as much battery life.

Linux’s battery usage has improved dramatically over the years. The Linux kernel has gotten better, and Linux distributions automatically adjust many settings when you’re using a laptop. But you can still do some things to improve your battery life.

Basic Battery-Saving Tips

Before you do anything too complex, adjust the same settings you would on a Windows laptop or MacBook to maximize battery life.

For example, tell your Linux laptop to suspend—this is what Linux calls sleep mode—more quickly when you’re not using it. You’ll find this option in your Linux desktop’s settings. For example, head to System Settings > Power on an Ubuntu desktop.

Screen brightness can affect battery life dramatically. The brighter your display backlight, the worse your battery life will be. If your laptop has hotkeys to change screen brightness, try them—they’ll hopefully work on Linux, too. If not, you’ll find this option somewhere in your Linux desktop’s settings. It’s available at System Settings > Brightness & Lock on Ubuntu.

You can also tell your Linux desktop to turn off the screen more quickly when it’s inactive. The laptop will use less power when its screen is off. Don’t use a screensaver, as those just waste power by making your computer do more work and leaving the display on.

You can also disable hardware radios you don’t use. For example, if you don’t use Bluetooth, you can disable it to gain some more battery life. Head to System Settings > Bluetooth to disable Bluetooth on an Ubuntu desktop.

If you’re not using Wi-Fi, you can save a bit of power by disabling that, too. On Ubuntu, head to System Settings > Network and enable “Airplane Mode” to disable Wi-Fi and other wireless radios.

Remember that what you do with the laptop is also important. Running heavier software and using more CPU resources will cause your laptop to use more battery power. For this reason, you may want to look at a more lightweight desktop environment, such as the Lxde-based Lubuntu instead of the Unity-based main Ubuntu desktop.

Install Proprietary Graphics Drivers (If You Need Them)

If your laptop has integrated Intel graphics, congratulations. You shouldn’t need to worry about power management issues with your graphics drivers. Intel graphics aren’t the fastest, but they have excellent open-source driver support and “just work” out of the box.

If your laptop has NVIDIA or AMD graphics, however, you may need to do some work to decrease power consumption.

The worst case scenario is a laptop with NVIDIA Optimus or AMD’s switchable graphics. Such laptops have two different GPUs. For example, an NVIDIA Optimus laptop will have both a more powerful, battery-draining NVIDIA GPU and a less powerful, battery-friendly Intel GPU. On…