What are other shortcut commands?

QuestionsQuestions8 SkillsProDec, 17 2025
095

You're exploring some great efficiency tips! Besides cd -, the Linux terminal offers many shortcuts that can significantly speed up your work. Here are some of the most common and useful ones, categorized for easier understanding:

  1. cd (without arguments):

    • Purpose: Takes you directly to your home directory (/home/labex in your case).
    • Example: If you're deep in /temp/some/long/path, just type cd to get back home quickly.
  2. cd ~:

    • Purpose: Also takes you to your home directory. ~ is a universal shortcut for a user's home directory.
    • Example: cd ~/project would take you to /home/labex/project directly, no matter where you currently are.
  3. cd .:

    • Purpose: Changes to the current directory. This might seem pointless, but it can be useful in scripts or when needing to re-evaluate the current directory context.

Command History Shortcuts

These are extremely powerful for reusing previous commands:

  1. Up Arrow ():

    • Purpose: Cycles backward through your command history. Press it repeatedly to find older commands.
    • Usefulness: Re-run a previous command, or modify it slightly without retyping.
  2. Down Arrow ():

    • Purpose: Cycles forward through your command history (after using the Up Arrow).
  3. !!:

    • Purpose: Repeats the last command executed.
    • Example: If you just ran sudo apt update and it failed because you forgot to run it with sudo, you can type sudo !! to re-run apt update with sudo.
  4. !string:

    • Purpose: Repeats the most recent command that starts with string.
    • Example: If you previously ran ls -la /some/directory, you could type !ls to run it again.
  5. ctrl + r (Reverse-i-search):

    • Purpose: Interactively search through your command history.
    • How to use: Press Ctrl + R, then start typing a part of the command you're looking for. The terminal will display the most recent matching command. Press Ctrl + R again to cycle through older matches. Press Enter to execute, or Left/Right Arrow to edit.

Text Editing & Cursor Movement Shortcuts (within the current line)

These are invaluable for editing commands on the fly:

  1. Ctrl + A:

    • Purpose: Move the cursor to the beginning of the current line.
  2. Ctrl + E:

    • Purpose: Move the cursor to the end of the current line.
  3. Ctrl + U:

    • Purpose: Cut (delete) everything from the cursor position to the beginning of the line.
  4. Ctrl + K:

    • Purpose: Cut (delete) everything from the cursor position to the end of the line.
  5. Ctrl + W:

    • Purpose: Cut (delete) the word before the cursor.
  6. Ctrl + Y:

    • Purpose: Paste the most recently cut text (from Ctrl + U, Ctrl + K, or Ctrl + W).
  7. Alt + F:

    • Purpose: Move the cursor forward one word.
  8. Alt + B:

    • Purpose: Move the cursor backward one word.

Process Management & Screen Clearing

  1. Ctrl + C:

    • Purpose: Interrupt (kill) the currently running foreground process. Useful if a command is stuck or you want to stop it.
  2. Ctrl + D:

    • Purpose: Sends an "end of file" signal. In a terminal, this typically exits the current shell session (logs you out) if no process is running, or closes input if a program is waiting for input.
  3. Ctrl + L:

    • Purpose: Clears the screen. It works similarly to the clear command but is often faster as it's a built-in shell shortcut.

Tab Completion

  1. Tab key (press once or twice):
    • Purpose: Auto-completes commands, file names, directory names, and even command arguments.
    • Example:
      • Type cd /ho and press Tab -> it often completes to cd /home/.
      • Type ls /home/labex/pr and press Tab -> it completes to ls /home/labex/project/.
      • If there are multiple possibilities, pressing Tab twice will show all options.

These shortcuts can significantly boost your efficiency and make working in the terminal much more enjoyable. I recommend trying them out as you practice! You'll find yourself reaching for them instinctively in no time.

Do any of these seem particularly interesting to you, or would you like to know more about a specific type of shortcut?

0 Comments

no data
Be the first to share your comment!