Skip to Content

Bash Shortcuts Every Linux User Needs to Know

If you’re a Linux user, you know that the bash shell is a powerful tool. With shortcuts, you can speed up your work and be more productive. In this blog post, we will discuss some of the most useful bash shortcuts that every Linux user should know. These shortcuts will help you save time and make your work easier!

what is bash in Linux

Bash is a shell and command language that is typically used for system administration. It can also be used for programming and general scripting. Bash is available on most Linux and UNIX-based systems.

Bash provides a rich set of features, including command line editing, history, job control, shell functions and aliases, among others. The bash shell also has a powerful programming language built into it. With all these features, bash can be used for both interactive use and scripting.

Linux bash shortcut – tab key

The first shortcut we will discuss is the Tab key. The Tab key is used for one main purpose in bash: completion.

Completion is a feature that allows you to type in the first few letters of a command, filename, or directory name and then hit the Tab key to automatically complete the rest. This can be a huge time saver, especially when you are working with long filenames or complex directory structures.

When you are typing a command, you can hit the Tab key to automatically complete the command or show a list of possible commands that start with the letters you have typed so far. This can be very useful when you forget the exact name of a command or when you want to see a list of all the available commands that start with a certain letter.

Linux bash shortcut – ctrl + r

The next shortcut we will discuss is Ctrl + r. This shortcut allows you to search through your command history. To use this shortcut, simply type in Ctrl + R and then start typing the letters of the command you are looking for. This is a great way to find a command you have used in the past but can’t remember exactly what it was.

Linux bash shortcut – ctrl + e

The next shortcut we will discuss is Ctrl + e. This shortcut allows you to move the cursor to the end of the line. This can be very useful when you want to add something to the end of a long command or filename.

Linux bash shortcut – ctrl + u

The next shortcut we will discuss is Ctrl + u. This shortcut allows you to delete everything from the cursor position to the beginning of the line. This can be very useful when you want to erase a mistake you made in a command or filename.

Linux bash shortcut – ctrl + b

The next shortcut we will discuss is Ctrl + b. This shortcut allows you to move the cursor back one character. This can be very useful when you want to make a change in the middle of a long command or filename.

Linux bash shortcut – ctrl + f

The next shortcut we will discuss is Ctrl + f. This shortcut allows you to move the cursor forward one character. This can be very useful when you want to make a change in the middle of a long command or filename.

Linuxbash shortcut – ctrl + w

The next shortcut we will discuss is Ctrl + w. This shortcut allows you to delete the word before the cursor. This can be very useful when you want to delete a mistake you made in a command or filename.

Linux bash shortcut – ctrl + a

The next shortcut we will discuss is Ctrl + a. This shortcut allows you to move the cursor to the beginning of the current line. This can be very useful when you are typing a long command and want to go back and edit something at the beginning.

Linux bash shortcut – ctrl + c

The last shortcut we will discuss is Ctrl + c. This shortcut is used to cancel the currently running command. This can be very useful if you accidentally start a long-running command or if you want to stop a command that is taking too long to run.

Bash shortcut – Navigation

  • Ctrl + a Go to the beginning of the line.
  • Ctrl + e Go to the end of the line.
  • Alt + f Move the cursor forward one word.
  • Alt + b Move the cursor back one word.
  • Ctrl + f Move the cursor forward one character.
  • Ctrl + b Move the cursor back one character.
  • Ctrl + x, x Toggle between the current cursor position and the beginning of the line.

 

Bash shortcut – Editing

 

  • Ctrl + _ Undo! (And, yes, that’s an underscore, so you’ll probably need to use Shift as well.)
  • Ctrl + x, Ctrl + e Edit the current command in your $EDITOR.
  • Alt + d Delete the word after the cursor.
  • Alt + Delete Delete the word before the cursor.
  • Ctrl + d Delete the character beneath the cursor.
  • Ctrl + h Delete the character before the cursor (like backspace).
  • Ctrl + k Cut the line after the cursor to the clipboard.
  • Ctrl + u Cut the line before the cursor to the clipboard.
  • Ctrl + d Cut the word after the cursor to the clipboard.
  • Ctrl + w Cut the word before the cursor to the clipboard.
  • Ctrl + y Paste the last item to be cut.

 

Bash shortcut – Processes

  • Ctrl + l Clear the entire screen (like the clear command).
  • Ctrl + z Place the currently running process into a suspended background process (and then use fg to restore it).
  • Ctrl + c Kill the currently running process by sending the SIGINT signal.
  • Ctrl + d Exit the current shell.

 

Bash shortcut – History

  • Ctrl + r Bring up the history search.
  • Ctrl + g Exit the history search.
  • Ctrl + p See the previous command in the history.
  • Ctrl + n See the next command in the history.

 

How to run a command in the background?

You can use the & symbol at the end of a command to run it in the background. For example, if you want to run the `sleep` command in the background, you would type `sleep 100 &`.

How to view all running processes?

You can use the `ps` command to view all running processes. For example, `ps aux` will show all processes running on the system, including the command used to start them.

How to kill a running process?

You can use the `kill` command to kill a running process. For example, if you want to kill the `sleep` command that we ran in the background, you would type `kill %sleep`.

What are some common Linux commands?

Some common Linux commands include `ls` (list files), `cd` (change directory), and `mkdir` (make directory). For a complete list of commands, you can view the man pages for each command (for example, `man ls`).

These are just a few of the many bash shortcuts that are available. By learning and using these shortcuts, you can save time and be more productive. Do you have a favorite bash shortcut? Let us know in the comments! Thanks for reading.

Hope this was helpful to understand some of the basic features of Bash.