目录

linux命令

welcome to learn terminal command!!!

linux命令

永!远!不!要!执!行!你!不!清!楚!在!干!啥!的!命!令!

实用性

1
$ ls -l | sed '1d' | sort -n -k5 | awk '{printf "%15s %10s\n", $9,$5}'

按文件大小增序打印出当前目录下的文件名及其文件大小(单位字节)

1
$ history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10

输出你最常用的十条命令

1
$ http POST http://localhost:4000/ < /<json文件路径>

做测试的时候很有用的一个命令,需要下载http

1
$ brew install http
1
2
3
4
5
6
7
$ lsof -n -P -i TCP -s TCP:LISTEN

COMMAND  PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
QQ       290 smartestee   33u  IPv4 0x2f3beaa58a62d73b      0t0  TCP 127.0.0.1:4300 (LISTEN)
QQ       290 smartestee   34u  IPv4 0x2f3beaa58c69673b      0t0  TCP 127.0.0.1:4301 (LISTEN)
idea    3257 smartestee  164u  IPv4 0x2f3beaa588d11e43      0t0  TCP 127.0.0.1:6942 (LISTEN)
idea    3257 smartestee  385u  IPv4 0x2f3beaa58c69316b      0t0  TCP 127.0.0.1:63342 (LISTEN)

查看端口的使用情况

1
$ ps -ef

查看进程

1
$ kill  xxxx

端口冲突时,用此命令,关闭某个端口。用PID替换xxxx

1
$ history

查看历史命令记录

1
$ pwd

当前位置

1
$ which xx

path位置,搭建环境的时候肯定会用得到

Linux 文件系统命令

修改问价拥有者

1
2
$ chgrp -R 组名 文件 / 目录
$ chown -R 账户名 文件 / 目录

修改文件权限

1
$ chmod 
  • 使用数字
    • r:4, w:2, x:1
    • 每种身份的权限的累加的。
1
$ chmod 777 test
  • 使用符号修改

    • u: user, g: group, o: others, a: all

    • 添加权限用+, 除去用-, 设置用=

      1
      
      $ chmod u=rwx, g=rw, o=r test
      
      1
      
      $ chmod a-x test
      
      1
      
      $ chmod go+r test
      

1
$ sudo !!

以root权限执行上一条命令(注意上一条命令的内容,以免发生意外)

例如:在Ubuntu 安装软件或插件的时候需要用到这个命令

1
$ sudo apt-get install nginx

查看和修改:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ cat
$ more
$ less
$ head
$ tail

$ vi
$ vim

$ mkdir
$ touch

git

1
$ git

先给出比较常用的

1
$ git add <一个或多个文件名(文件名之间是用空格,也可以是一个点,表示添加全部)>
1
$ git commit -m "注释"

本地提交

1
$ git checkout <分支名或master>

切换分支与master

1
$ git branch <分支名>

新开一个分支

1
$ git merge <分支名>

主分支与分支的合并

1
$ git push origin master

提交到github上

1
$ fuck

纠正命令行输入的错误,比手动改快,实用。

安装:

1
$ brew install thefuck

娱乐

1
$ cmatrix
1
$ telnet towel.blinkenlights.nl

telnet是基于Telnet协议的远程登录客户端程序,经常用来远程登录服务器.除此还可以用它来观看星球大战

1
$ fortune

随机输出名言或者笑话,

还有很多,有兴趣的可以通过这个链接去看:知乎

个人博客 yusank

比较牛逼的一个查找命令的网站:http://www.commandlinefu.com/commands/browse/sort-by-votes

每天都有更新各种命令组合