scp命令

scp <local file> <remote user>@<remote machine>:<remote path>

#On the other hand if you are on the computer wanting to receive file from a remote computer
scp username@remote:/file/to/send /where/to/put

添加指定公钥文件

ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@192.168.55.232

指定远程主机别名

# ~/.ssh/config
Host lab
    HostName remote
    User user
    Port port

# 登入远程主机
ssh lab

sftp使用

sftp 用户名@ip地址

# 查看远程当前工作目录
pwd
# 查看本地当前工作路径
lpwd

# 上传文件
put -r /User/ren/local/test.zip /home/root/remote

# 下载文件
get -r /home/ren/remote/test.zip /User/ren/local

shell 脚本

#!/bin/sh

启动Apache

启动:sudo apachectl start

停止:sudo apachectl stop

重启:sudo apachectl restart

bash

cd -          #回到上次所在目录

cd !$        #把上个命令的参数作为输入。

cd           #回到主目录

cd ~         #同样也是回到主目录

激活zsh

chsh -s /bin/zsh

# 更换bash
chsh -s /bin/bash

jobs control

Ctrl+z #will suspend the currently forgrounded program
bg #将进程搬到后台运行(Background)
fg jobID #place job in the foreground, and make it the current job.
jobs #show the following job running in the background.

查找进程

ps aux | grep ssh
ps -ef

ssh

# 访问端口
ssh -p 29093 root@45.78.42.114
# for X11 forwarding
ssh -Y root@45.78.42.114 

# 端口转发
ssh -D 7701 root@34.70.102.19

# 反向端口转发
lab$ ssh -R 10022:localhost:22 jumpbox
jumpbox$ ssh user@localhost -p 10022
lab$

列出网络端口号

netstat -an | grep 3306
lsof -i:80

格式化json数据

cat data | python -m json.tool

解压

tar -x #extract
tar -z #if the tar file also compressed with .tar.gz or tgz extension
tar -xvf file.tar
tar -zxvf data.tar.gz

PANDOC

pandoc -s -o doc.docx test.md

HOMEBREW

brew search xxxx #查找软件包

brew install xxxx #安装软件包
brew list #列出已安装的软件包
brew remove xxxx #删除软件包
brew info xxxx #查看软件包信息
brew deps xxxx #列出软件包的依赖关系
brew update #更新brew
brew outdated #列出过时的软件包,已安装但不是最新版
brew upgrade #更新全部过时的软件包
brew upgrade xxxx #更新指定的软件包

brew tap                   # list tapped repositories
brew tap tapname           # add tap
brew untap tapname         # remove a tap

添加日志文件到console中

cd ~/Library/Logs
ln -s /opt/local/apache2/logs/ apache2

重启 php-fpm

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist

jdk位置

/Library/Java/JavaVirtualMachines/

加载memcached

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

查看当前文件大小

du -sh *

添加ss例外

||ads.example.com^

SwitchyOmega 无法登陆谷歌账号

*.googleapis.com +proxy

unrar

brew install unrar
unrar x test.rar

安装受损文件

sudo spctl --master-disable

修改item的vim光标输入问题

let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"

修改mac地址

# 查看当前所有端口mac地址
networdsetup -listallhardwareports

# 修改en1的网卡mac地址
sudo ifconfig en1 ether e4:ce:8f:32:51:82

# 查看是否修改成功
ifconfig en1 | grep ether

alfred

# 放大展示
cmd+L

launchctl

# 查看所有服务
launchctl list | grep <service name>

# 查看服务状态
# 停止
launchctl stop <Service Name>
# 开始
launchctl start <Service Name>
# kill
launchctl kill <Service Name> 

# 卸载服务
launchctl unload ~/Library/LaunchAgents/com.chanjh.wifikeeper.plist
launchctl stop com.chanjh.wifikeeper

# lauchd 配置 
~/Library/LaunchAgents
/Library/LaunchAgents
/Library/LaunchDaemons
/System/Library/LaunchAgents
/System/Library/LaunchDaemons