Mac常用命令行


ls 參數 目錄名
ls /
ls /System/Libray
-w 顯示中文 -l 詳細信息 -a 包括隱藏文件
cd 目錄名
pwd 當前目錄名
mkdir 目錄名
rmdir 刪除一個空目錄
mvdir dir1 dir2
dircmp dir1 dir2
diff dir1 dir2
cp file1 file2
rm 參數 文件
mv file1 file2
chmod 參數 權限 文件
cat filename
pg filename
od -c filename
find .-name"*.c" -print
file filename
grep "^[a-zA-Z]" filename
uniq file1 file2
comm file1 file2
wc filename

 

編輯:
nano 文件名, ctrl+O(save) ctrl+X(exit)

vi編輯器使用:
vi filename
i 插入模式
esc 推出插入模式
:w 保存當前編輯的文件但不退出
:w newfile 文件另存為
:w! filename 當前文件的內容替換filename中的原有內容
:q 退出,文件為保存時會提示
:q! 強制退出,不保存文件
:wq 先保存文件,然后退出到shell
:x 或者ZZ ,保存並退出返回shell

ctrl + u 清空當前行
ctrl + a 移動到行首
ctrl + e 移動到行尾
ctrl + f 向前移動
ctrl + b 向后移動
ctrl + p 上一條命令
ctrl + n 下一條命令
ctrl + r 搜索歷史命令
ctrl + y 召回最近用命令刪除的文字
ctrl + h 刪除光標之前的字符
ctrl + d 刪除光標所指的字符
ctrl + w 刪除光標之前的單詞
ctrl + k 刪除從光標到行尾的內容
ctrl + t 交換光標和之前的字符

 


腳本命令
sh 腳本文件名
sh /clean

alias ip="ifconfig | grep inet | grep netmask"

Mac
截圖:

say "hello"
screencapture -iW ~Desktop/screen.jpg 截取選定的窗口
screencapture -S ~Desktop/screen.jpg 截取當前窗口
screencapture -iC ~Desktop/screen.jpg 截取一部分

快捷鍵:
ctrl + space 輸入法切換
大寫鍵 ,中英文切換
cmd + Click 打開文件/文件夾/鏈接
cmd + n 新建窗口
cmd + w 關閉當前頁
cmd + t 新建標簽頁
cmd + 數字 , cmd + 方向鍵,切換標簽頁
cmd + enter 全屏
cmd + tab 切屏
cmd + d 左右分屏
shift cmd + d 上下分屏
cmd + ; 自動補全歷史紀錄
shift cmd + h 自動補全剪貼板歷史

ctrl + 方向鍵 切換窗口
cmd + ctrl + d 查Mac自帶詞典


后台服務管理:
LaunchDaemons 未登錄前就啟動的服務
LaunchAgents 用戶登錄后啟動的服務

服務的plist文件目錄:
user:
~/Library/LaunchAgents
administrator:
/Library/LaunchAgents
/Library/LaunchDaemons
Mac OSX
/System/Library/launchAgents
/System/Library/LanuchDeamons

禁用服務的方法:
$sudo launchctl unload plist filepath
$sudo launchctl unload -w plist filepath
比如禁用spotlight
$sudo lanuchctl unload /System/Library/LaunchAgents/com.apple.Spotlight.plist
$sudo lanuchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist
然后重啟Mac OS;
方法2:
$sudo lanuchctl unload /System/Library/LaunchAgents/com.apple.Spotlight.plist
然后將plist文件mv到其他目錄備份,重啟。

還原服務:
$sudo launchctl load -wF plist filepath
或者:
將備份的plist文件mv回原來的文件夾
$sudo launchctl load plist filepath

查看服務的狀態:
launchctl list

環境變量設置
echo $SHELL 查看當前的shell
PATH變量設置:
vi .bash_profile 回車 編輯文件
i進入編輯模式,添加usr/local/mysql/bin到環境變量
export PATH=${PATH}:/usr/local/mysql/bin
按esc退出插入文字編輯模式
鍵入wq回車 ,保存並退出vi
鍵入source .bash_profile 讓修改的文件生效


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM