2 minute read

  • cd -: Switch back to the last working directory.

Running Multiple Commands

  • Run commands sequentially:
    command_1; command_2; command_3
    
  • Run commands sequentially only if the previous command succeeds:
    command_1 && command_2
    

Previous Commands and Arguments

  • Repeat the last command:
    !!
    
  • Access specific arguments of the previous command:
    • !:n: Replace with the nth argument of the last command.
      Example: !:0 for the command itself, !:-1 for the first argument.
    • Keyboard shortcuts:
      • Alt + .: Last argument of any previous command.
      • Esc + .: Last argument of the most recent command.
  • Common argument patterns:
    !^      # First argument
    !$      # Last argument
    !*      # All arguments
    !:2     # Second argument
    !:2-3   # Second to third arguments
    !:2-$   # Second to last arguments
    !:2*    # Second to all arguments
    !:2-    # Second to second-last arguments
    !!      # Repeat the last command
    

Spelling Check in Linux

  • Use look to check word spelling:
    look docum
    

Linux Terminal Shortcuts

  1. Ctrl + a: Move to the start of the line.
  2. Ctrl + e: Move to the end of the line.
  3. Ctrl + u: Cut everything before the cursor.
  4. Ctrl + k: Cut everything after the cursor.
  5. Ctrl + l: Clear the terminal.
  6. Ctrl + r: Search command history.
  7. Ctrl + b: Move back one character.
  8. Alt + b: Move back one word.
  9. Ctrl + f: Move forward one character.
  10. Alt + f: Move forward one word.
  11. Ctrl + d: Delete the current character.
  12. Ctrl + w: Cut the last word.
  13. Alt + d: Cut the word after the cursor.
  14. Alt + w: Cut the word before the cursor.
  15. Ctrl + y: Paste the last deleted content.
  16. Ctrl + _: Undo.
  17. Ctrl + x, x: Toggle between the first and current cursor position.
  18. Ctrl + c: Cancel the current command.
  19. Ctrl + j: End search at the current history entry.
  20. Ctrl + g: Cancel search and restore the original line.
  21. Ctrl + n: Next command in history.
  22. Ctrl + p: Previous command in history.

For more, check StackOverflow.


CSV Files: Pretty Display in Terminal

Add this function to your .bashrc:

function pretty_csv {
    column -t -s, -n "$@" | less -F -S -X -K
}

Use with:

pretty_csv your_file.csv

Pretty Code Printing with enscript

sudo apt install enscript
enscript -2rj --highlight=python --color=1 -o output.ps your_script.py

Check Disk Usage

sudo du -ah --max-depth=1 / | sort -hr

Scheduling Tasks with Crontab

Edit and schedule tasks:

cron -e

Tags:

Updated:

Comments