MacOS X 专用命令行梳理

open

pbcopy and pbpaste

tree -L 1 | pbcopy

mdfind

screencapture

launchctl

say

diskutil

brew

列表清单

快捷操作

TabAuto-complete file and folder names
Ctrl + AGo to the beginning of the line you’re currently typing on
Ctrl + EGo to the end of the line you’re currently typing on
Ctrl + UClear the line before the cursor
Ctrl + KClear the line after the cursor
Ctrl + WDelete the word before the cursor
Ctrl + TSwap the last two characters before the cursor
Esc + TSwap the last two words before the cursor
Ctrl + LClear the screen
Ctrl + CKill whatever you’re running
Ctrl + DExit the current shell
Option + →Move cursor one word forward
Option + ←Move cursor one word backward
Ctrl + FMove cursor one character forward
Ctrl + BMove cursor one character backward
Ctrl + YPaste whatever was cut by the last command
Ctrl + ZPuts whatever you’re running into a suspended background process
Ctrl + _Undo the last command
Option + Shift + Cmd + CCopy plain text
Shift + Cmd + VPaste the selection
exitEnd a shell sessio

基础操作

/ (Forward Slash)Top level directory
. (Single Period)Current directory
.. (Double Period)Parent directory
~ (Tilde)Home directory
sudo [command]Run command with the security privileges of the super user
nano [file]Opens the Terminal editor
open [file]Opens a file
[command] -hGet help about a command
man [command]Show the help manual of the command
Change Directory
cdHome directory
cd [folder]Change directory, e.g. cd Documents
cd ~Home directory
cd/Root of the drive
cd -Previous directory or folder you last browsed
pwdShow your working directory
cd..Move up to the parent directory
cd../..Move up two levels

list

lsDisplay the name of files and subdirectories in the directory
ls -CForce multi-column output of the listing
ls -aList all entries including those with .(period) and ..(double period)
ls -1Output the list of files in one entry per line format
ls -FDisplay a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic link
ls -SSort files or entries by size
ls -lList in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more
ls -l /List of the file system from root with symbolic links
ls -ltList the files sorted by time modified (most recent first)
ls -lhLong listing with human readable file sizes in KB, MB, or GB
ls -loList the file names with size, owner, and flags
ls -laList detailed directory contents, including hidden files

文件磁盘

duList usage for each subdirectory and its contents
du -sh [folder]Human readable output of all files in a directory
du -sDisplay an entry for each specified file
du -sk* | sort -nrList files and folders, totaling the size including the subfolders. Replace sk* with sm* to list directories in MB
df -hCalculate your system’s free disk space
df -HCalculate free disk space in powers of 1,000 (as opposed to 1,024)

参考资源