常用mac终端命令

2018年10月23日
1.显示Mac隐藏文件的命令:

defaults write com.apple.finder AppleShowAllFiles -boolean true

隐藏Mac隐藏文件的命令:

defaults write com.apple.finder AppleShowAllFiles -boolean false

2018年9月7日
1.普通用户和root用户切换

wangyuMBP:3.7.2云南 mac$ sudo -i
Password:
wangyuMBP:~ root# chown -R /Users/mac/Desktop/3.7.2云南/fastlane 
wangyuMBP:~ root# su - mac
wangyuMBP:~ mac$ pwd

[root@localhost ~]# chmod 777 /home/user 注:仅把/home/user目录的权限设置为rwxrwxrwx
[root@localhost ~]# chmod -R 777 /home/user 注:表示将整个/home/user目录与其中的文件和子目录的权限都设置为rwxrwxrwx

2018年6月28日
1.复制文件

cd /usr/local/var/www/317/iOS/
ls 20180628*
cd 20180628_150504
cd 317hu-SIT20180628_150504
cp 317hu-SIT.ipa /Users/hu317/Desktop

2018年6月13日
1.删除指定目录下 如删除所有201805*开头的文件夹

rm -rf 201805*

2.查找指定目录下 (暂不清楚规则)

find ./* -mtime +3
find ./* -mtime +30
find ./* -mtime +30|more
find ./* -mtime +30|xargs -ls

3.罗列指定类型的文件

ls 201805*
ls 201804*

4本地登录远程电脑,直接在本地电脑终端操作远程电脑文件夹

ssh hu317@172.16.150.244
image.png

或者用如下图形化界面操作

open vnc://172.16.150.244

2018年6月5日

1.全局显示finder下隐藏文件

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder

2.全局隐藏finder下隐藏文件

defaults write com.apple.finder AppleShowAllFiles FALSE

killall [Finderwxshy.com](http://Finderwxshy.com)

2018年4月26日
1.环境变量创建


image.png

2018年4月10日
1.mac 怎么查看端口号是否被占用

命令 lsof -i tcp:port (port替换成端口号,比如6379)可以查看该端口被什么程序占用,并显示PID,方便KILL

2017年6月1日
1.查看xcode相关的命令
xcodebuild -h

2017年5月25日
1.设置全部变量可以在如下两个文件 cd ~
.bash_profile 和 .profile (网上有人说home下有.bash_profile或.bash_login时,会忽略调用.profile)

vim ~/.bash_profile 
image.png

所以可以把东西全部移动一个文件里(目前我是移到.profile)

export WEB="/usr/local/var/www"
alias ll="ls -l"
export DES="/Users/yanchengyi/Desktop"
alias opz="open /Users/yanchengyi/Documents/wangyu/pzworkspace"
alias opd="open /Users/yanchengyi/Downloads"
# Duotai proxy
alias pon='export http_proxy=http://duotai:pEyz8I@marriott.h.xduotai.com:26;export https_proxy=$http_proxy'
alias poff='unset http_proxy;unset https_proxy'

test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
export PATH="$HOME/.fastlane/bin:$PATH"

别忘了 最后更新启动下
source .profile

2017年3月13日
1.查看mac电脑cpu型号

sysctl machdep.cpu.brand_string
Paste_Image.png

2017年1月18日
1.返回上级目录
cd ..
返回上次访问的目录
cd -

Paste_Image.png

2016年11月24日
1.查询当前服务打开情况(前提用brew安装的命令)

brew services list
Paste_Image.png

nginx启动命令

sudo ngnix

jenkins 重启命令

brew services reload jenkins
Paste_Image.png

2016年11月7日
1.给ip地址添加域名访问

 sudo vim /etc/hosts
Paste_Image.png

2016年10月28日
一.命令添加别名
原理:根目录下 修改pofile文件
1.给路径添加别名 ( export WEB="/usr/local/var/www")
2.给命令添加别名( alias ll="ls -l")

cd ~
vim .profile

修改成如下内容


Paste_Image.png

之后保存 按esc进入一般模式,在 按 (shift+:) 在加wq保存 (如果不需要保存直接按q)
之后重启下 proifle

source .profile

效果如下:(路径别名使用 $WEB)


Paste_Image.png

2016年10月17日
1.绝对路径
绝对路径以 / 开头

cd /usr/local/var/www
cd /Users/yanchengyi/Desktop/

2.相对路径
返回上一级目录 ../ (当前目录./)
比如你现在在如下目录 www/317/dir
你要查看www/317/ios
如下两种方式都可以

cd ../ios
cd ../../317/ios
Paste_Image.png

2016年10月15日
1.终端终端正在执行的任务 ctrl+c


Paste_Image.png

2.退出带冒号的 说明命令 q


Paste_Image.png

2016年9月22日
1.history 看最近打印的终端命令 (如果需要删除最近的 history -c)
Paste_Image.png

2.如果要清楚当前终端命令日志用 clear
Paste_Image.png

3.终端窗口添加 command + t 切换 commad+shfit+[/]

终端命令 一般用 tab键自动补全 eg:cd /Us 按 tab建会 自动补全 cd /Users/

如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 用 Tab 键可以自动补齐 0. ctrl + umac终端里,快速删除一行 1.ls 列出目录下所有文件...
    江河_ios阅读 7,448评论 0 2
  • 原作者:u012701023 OSX 的文件系统 OSX 采用的Unix文件系统,所有文件都挂在跟目录 / 下面,...
    qiuYang_HANABI阅读 2,996评论 0 0
  • 1.pwd(显示当前目录层次) 2.ls显示文件 ls 显示在当前目录下的所有文件或文件夹 ls 【目录】 显示在...
    iBlocker阅读 1,520评论 0 0
  • (一)基本命令 命令格式: 命令 参数 1.ls 显示文件名,等同于dos下dir命令 命令格式:ls [opti...
    飞羽孟德阅读 1,974评论 0 3
  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,483评论 0 5