Written with StackEdit.
why you need to learn? Because mastering command line will make you like a Hacker.
Command line is case sensitive and require file extension. A command line includes Command Name –Options Arguments Extras. Each word is separated by space. Either absolute path or relative path is OK.
cheatsheet: https://github.com/0nn0/terminal-mac-cheatsheet
my frequent usage
command |
function |
note |
say “hello” |
Pronounce |
|
sleep 600 && say “hello” |
A timer for 600s and alarm |
|
type coomandName |
tell it’s internal or external command |
|
man commandName |
Open manual for the command name |
Q to quit |
man –k keyword |
open all manual with certain keywords |
|
pwd |
print working directory |
|
ls |
list directory content |
similar to dir |
cd |
change directory |
|
cd / |
go to root directory |
|
cd ~ |
go to user directory |
|
cd .. |
go to upper directory |
|
cd first letter+ |
auto complete the whole folder name |
|
ls -a |
list hidden folder |
|
ls -la |
list hidden folder and files |
|
cat |
concatenate |
|
less |
|
|
which command name |
location of command |
|
whereis command name |
location of command |
|
* ? [] |
wildcard characters |
|
mk dir, cp, mv, rm |
make directory, copy,move, reomve |
|
vi |
visual text editor |
|
nano |
nano text editor (much better) |
|
open . |
use Finder to open current directory |
|
history |
see what you have input |
|
ctr+ L |
clear screen |
|
ctr+ C |
stop current execution |
|
echo string |
print string |
|
alias string=”command name” |
make alias for command |
|
su |
substitute user |
|
install software
Homebrew is the most powerful package manager:
‘/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”’
Then you can use brew install
or brew cask install
to install many softwares
- Dash: collection of all documentation
- cheatsheet: shortcut anytime
Directory structures in Mac HD
4 visible file folders under root
1. Applications: for software
2. System: /library/…
3. Library: has Dictionaries, desktop picture, documentation, Favorites, Fonts, iTunes, Java Mail, preferences, etc
4. User: / yourname/Desktop, Download, Library, Documents, Application
Hidden file folders:
• bin
• cores
• dev
• home
• net
• Network
• private
• sbin
• usr
• Volumes
• files: etc, var, tmp
⌥ is alt (option), imagine it as a track changing switch
^ is control
⇪ Capslock
⇧ Shift
other
convert MS table to MD table http://www.tablesgenerator.com/markdown_tables
write MD in MS word: http://www.writage.com/
Reference:
http://xiaolai.li/2016/06/16/makecs-basic-dev-env-settup/
https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/ShellScripting/CommandLInePrimer/CommandLine.html
https://www.renfei.org/blog/mac-os-x-terminal-101.html