Bash stands for “Bourne Again SHell”, is a replacement/improvement of the original Bourne shell (sh).
Today finished a phone interview with Comcast and scheduled onsite. They asked me about Bash and OOD/P.
Then I think I should write a Bash Note so that I can easily look them up next time.
Cheatsheet: https://github.com/skywind3000/awesome-cheatsheets
pwd
ssh user@host
ssh -p port user@host
whoami # return current username
passwd # allow current user
finger username # Displays information about user.
uname -a # show kernel info
man command # show manual
df # show disk info
ps # show your processes
kill PID # kill process by process ID
killall processname # kill process by process name
top # show current process
whois domain # get domain info
dig domain # get DNS info of a domain
wget file # download file
scp source_file user@host:directory/target_file # copy file from local to remote
copy file from remote host to local
1
2scp user@host:directory/source_file target_file
scp -r user@host:directory/source_folder farget_folderalso accepte port
1
scp -P port user@host:directory/source_file target_file
Example of Shell programming
1  | 
  | 
IF
1  | if [expression]; then  | 
case
1  | case expression in  | 
Loop
3 kinds of loop
1  | for x := 1 to 10 do  | 
1  | while condition; do  | 
1  | until condition; do  | 
Debugging
1  | bash -n scriptname # won't run, grammer checking only  | 
something else
edit .bashrc
1  | echo $PS1 # shown the current prompts  | 
Then run source ~/.bashrc to execute
If you want to auto load .bashrc when open a new terminal, edit .bash_profile (or .zshrc for me)
1  | # The next line enables shell include .bashrc if it exists  |