Bash tricks – Some of the useful bash shortcuts

Posted In: blog |

The bash tricks list:

  1. Quick cd to previous directory
  2. Set the default text editor
  3. Change the default history size (number of commands that are saved)
  4. Find and run a command from history

    or you can use CTRL-r
  5. Run the last command
  6. Delete the actual line CTRL-u and paste it back CTRL-y
  7. Exit bash without saving history
  8. List all in directory sorted by modify date
  9. Preview a command in an interval
  10. Create new nested directories at once
  11. Find files and execute a command on them
  12. Loop through a command numerous times

    Shorter way of doing above :
  13. Synchronize a local direcotry with a remote one
  14. Delete all files in directory (shortcut for directories with large amount of files)
  15. Print file by columns using awk

    It will print first column, determining columns by “delimiter”
    Real life exapmle, print all usernames in system:
  16. Replace Xth column in a row using awk

    It will print first column, determining columns by “delimiter”
    Real life exapmle, print all usernames in system and replace the password column with a dash:
  17. Simple way to change date:
  18. Simple way to change time:
  19. Grep recursively :
  20. Examine local network:
  21. Find out which directories consume most of the disk space:
  22. Quick & dirty way to reboot

If You want more, check this cheatsheet.

BASH / Redline Shortcuts

  1. ALT + . – Use the last word of previous command
  2. CTRL + t – Auto correct misspelled word
  3. CTRL-x CTRL-e – Edit a command / script in default editor
  4. CTRL + u – Cuts text up until the cursor.
  5. CTRL + k – Cuts text from the cursor until the end of the line
  6. CTRL + y – Pastes text
  7. CTRL + e – Move cursor to end of line
  8. CTRL + a – Move cursor to the beginning of the line
  9. ALT + f – Jump forward to next space
  10. ALT + b – Skip back to previous space
  11. ALT + Backspace – Delete previous word
  12. CTRL + W – Cut word behind cursor
  13. Shift + Insert – Pastes text into terminal

Post Tags: bash | linux | redline | tricks |


Comments Off on Bash tricks – Some of the useful bash shortcuts