前言:
............................................
1. What's Linux
linus torvals-----发音,读音linnerks or linniks
linux is not unix
linux is freedom----?
衍生了 ubutun/redhat/
---Shell??
shell/command/terminal
2. Shell Programing && Linux Kernel
. which --
. sudo apt-get install --
. ctrl+a/ctrl+e
. curl
. pwd
. ls --- ls -F ---- ls -a ---- ls ~ :用户目录 ls or ls .当前目录
. initial two env
. cd ----change directory
cd -
cd .. cd / cd ~
mkdir/rmdir -p
rm -rf
对-f的误区: ignore nonexistent files and arguments, never prompt
cat
wc (what the count)---统计文件行数 / wc -l
wc -w ????????????????? how how it works??
head -count file --打印前几行
tail --count file --打印末尾几行
file 查看文件内容属于什么类型,不根据后缀查找,根据内容查找
find
less/more
man find
man command ---------------用户手册
man 里查找一个单词 /selection
n/N上下匹配
command -h
command --help -----------属man 的一个子集,部分信息,没有mam 全面
.I/O reduction i/o重定向
stdin ---with keybord
stdout ----to standard output to screen, reduction to output to a file
ps
ps aux --------------打印出系统所有进程
ps -ef ------------------效果同上
ps aux | grep
kill -9 PID
exit
切换其它shell工作,默认是bash
/etc/shells
推荐 zsh/chhshell
tail -f
top 系统内存使用情况
jobs 调出后台运行的进程 comman & 不产生输出,
bg/fg %1 -------------回到之前的进程l
kill -9 1(count) ------kill 后台进程
ctrl + r --search history
网络命令
ping
telnet ip port
wget ---用于下载文件
curl ----可以用作http客户端, 发起一个请求 (/put(新增)/delete/post(更新)/get/options/head) 去了解 rest full api
挺有趣的 get 方法 querry param --------- 请求参数
tail -f 直接显示出新增项,用于跟踪文件
ssh
scp
netstat ------查看端口情况
lsof -i:port
lsof -i:port -t (只打印PID)
kill -9 `lsof -i:port -t`---------------反引号中先执行
telnet 去验证服务端是否正常工作,可以建telnet server方便使用
redis分布式的系统
RPC 远程过程调用
grep
grep -o -i -a -inr --color(高亮)
awk awk -F: '{print $1 " 喜欢 " $3}' hobby ---------(-F 可以用来指定分隔符 比如-F :,$2 打印第二列)
sed
安装下以下程序,
z(记录访问过的file)
j
Piping 管道命令
|
grep 跑步 hobby| awk '{print $1}' | sort | uniq
(sort 排序/uniq按消除重复,之消除临项)
System 命令
sudo
apt-get
dpkg
编辑器:
vim ---vi improve
nano
vim:
shift : help可以查看帮助
shift ] 进入文档
j k 上下移动
:set nu
u撤销上一个操作 undo
ctrl +r ----redo
d+D --------删除下面所有内容
yy ------复制一行
w/e/b ->(这些符号以空格为分割符,w跳到单词首,e单词尾,b跳到上一个单词)
f/F
#/%
v/V
J 去掉换行,将多行放到一行。与块选择配合使用
= 缩进