Other Useful Commands - Paiet/Tech-Journal-for-Everything GitHub Wiki
- Foreground and Background processes
- Ctrl+Z pauses a program
-
fg
unpauses a program
nano
ctrl+Z
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
- 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
-
!<#>
reruns the numbered command
-
!<string>
reruns the last command that started with <string>
ls -lah
touch test{1..9}
!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** ⚠️