Other Useful Commands - Paiet/Tech-Journal-for-Everything GitHub Wiki

  • Foreground and Background processes
    • Ctrl+Z pauses a program
    • fg unpauses a program
      1. nano
      2. ctrl+Z
      3. fg
    • bg unpauses the program but runs it in the background
    • Adding an & to a command runs it in the background as soon as its initiated
    • jobs
      • Checks for running jobs before logging out
  • Chaining commands
    • Allows running multiple commands from one line
    • uname -a; hostname; df -h; free -h
  • Multi-line commands
    • Some commands are really long
    • Can be broken up on more than one line
    • Useful when there are a lot of options/arguments
    • Use a \ to indicate the command continues on the next line
    • Normal command
      • useradd -d /home/jdoe -e 01/01/2018 -g jdoe -G adm,wheel -p password123 -s /bin/zsh -u 1001 jdoe
    • Multi-line version
      • useradd -d /home/jdoe \
      • -e 01/01/2018 \
      • -g jdoe \
      • -G adm,wheel \
      • -p password123 \
      • -s /bin/zsh \
      • -u 1001 \
      • jdoe
  • Viewing command history
    • List command history
      • history
    • Options
      • -c Clear the history
      • -w Write the history to ~/.bash_history
    • history -cw
      • Clears the history and then writes an empty history over ~/.bash_history
    • !! represents the previous command
      • uname
      • !! -a
    • !<#> reruns the numbered command
    • !<string> reruns the last command that started with <string>
      1. ls -lah
      2. touch test{1..9}
      3. !ls
  • Alias
    • Assign an alternate name to a command
    • alias ls='ls -lah'
    • Tied to the current session
    • Must be redefined each time you launch a shell
⚠️ **GitHub.com Fallback** ⚠️