Mac搭配的系统是基于Linux内核开发的,因此大部分Linux的命令都适用于Mac上 对于我个人来说,作为一名Mac用户,一名特意买一本MacBook来开发(满足好奇心)来说,使用命令行操作是非常帅气的。 同时,熟悉了使用命令操作一些功能能够极大的提高工作效率。 因此为了提高开发效率,特意学习一下Mac的命令操作。 下面是一些常用的Terminal操作。
xcode
https://developer.apple.com/xcode/
安装item2
https://iterm2.com/
安装git
https://git-scm.com/
安装brew
https://brew.sh/index_zh-cn
安装oh-my-zsh (* 只有安装了这个,item2 才好用,一些配置才会生效)
https://ohmyz.sh/#install
launchd # 是 macOS 中非常重要的程序,相当于 Linux 世界的 systemctl
launchctl list
cd # 进入目录
sudo # 获取临时root权限
find ~iname xxx # 查找文件夹
sudo shutdown -h now | sudo halt # 关机
sudo reboot | sudo shutdown -r now # 重启
passwd # 修改用户密码
history # 最近执行的命令以及编号
env # 显示当前所有设置过的环境变量
who # 当前登陆的所有用户
whoami # 当前正在操作的用户名
其它命令
say xxx # say命令能让电脑读出后面的文字
# Mac OS会自带6个系统嗓音(3男3女),你可以自己选择。
say --voice=Sin-ji 这里是粤语发音 # 指定粤语发音
say -v Sin-ji 这是粤语发音 # 同上
say -f 1.txt -v Sin-ji # 读取a.txt 的内容
say -f 1.txt -v Sin-ji -o a.aiff # a.txt 的内容保存为音频文件
open ~ # 打开指定目录
open file # 打开指定文件 open /Applications QQ.app
pbcopy # pbcopy 和 pbpaste 是读取及写入系统剪贴板的命令,支持 Unix 管道操作,也就是说你可以 ls ~ | pbcopy 或者 pbcopy < blog.txt。
pbpaste # 粘贴内容
sw_vers # 查看系统版本
ssh xxx@ip -p 端口
mkdir 文件名 # 建立新目录
rm -rf # 删除文件夹
rm # 删除文件
pwd # 显示当前文件夹路径
安装Homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
查找软件包
brew search wget
安装软件包
brew install wget
列出已安装的软件包
brew list
删除软件包
brew remove wget
查看软件包信息
brew info wget
列出软件包依赖关系
brew deps wget
更新软件包
brew update
列出过时的软件包
brew outdated
更新过时的软件包(全部或单个)
brew upgrade
brew upgrade wget
i —— 插入模式
esc —— 退出
:wq —— 保存并退出
:q! —— 不保存退出
u —— 撤销上一次操作
ctl+r 和u相反
command + t —— 在终端新打开一个终端
command + c —— 复制
command + v —— 粘贴
command + z —— 撤销
command + 左(右) —— 移到行头(尾)
command + shift + 左(右) —— 移到行头(尾)并选中
command + r —— 刷新网页
fn + 上(下) —— pageup(pagedown)
fn + delete —— 向后删除
gunzip filename.gz
gunzip -g filename.gz
or
[root@linux ~]# cd /usr/local/src
[root@linux src]# tar -zxvf /tmp/etc.tar.gz
sysctl hw.physicalcpu: 2
sysctl hw.logicalcpu: 4
code .
命令直接使用 VsCode 打开当前文件夹1.命令开启方式
–> 打开VSCode
–> 组合键 command+shift+p
–> 输入shell command
–> 点击提示 Shell Command: Install ‘code’ command in PATH运行
2.手动开启方式
-> 打开VSCode
–> 组合键 command+shift+p
–> 输入shell command
–> 点击提示Shell Command: Install ‘code’ command in PATH 运行
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有