Linux使用技巧

1. 查找当前目录(包括子目录)文件中的字符

grep -r "所要查找字符" *

2. 循环使用

for i in `seq 1 1000`; do echo "$i";done

执行1000次echo

3. 自定制命令

将alias self_bin = 'cd /home/self_bin' 放在/root/.bashrc中 然后source /root/.bashrc中

在命令行执行self_bin 就相当于执行cd /home/self_bin

4. 创建目录树

mkdir -p folder/{folder_1,folder_2,folder_3,folder_4,folder_5}

5. 使用vim编辑文件的时候,可以使用x,保存退出,通常大家都知道wq是保存退出,其实一个x命令就搞定了。

6. 更改mac地址

ifconfig eth0 down

ifconfig eth0 hw ether 00:0C:29:36:97:20

ifconfig eth0 up

如果想重启后也生效的话

将ifconfig eth0 hw ether 00:0C:29:36:97:20放到/etc/rc.local里面

7.查看系统信息

cat /proc/cpuinfo

cat /proc/meminfo

cat /proc/version

8.网卡混杂模式

网卡 eth0 改成混杂模式:

ifconfig eth0 promisc

关闭混杂模式:

ifconfig eth0 –promisc

9. lsof 用法小全

lsof abc.txt 显示开启文件 abc.txt 的进程

lsof -i :22 知道 22 端口现在运行什么程序

10. 查看开启哪些端口

netstat -antulp

11. pidof 进程名 可以查出该进程的进程号

12. strace 进程名 跟踪进程,调试时候可用到

13 tail -f -n /var/log/messages 可以实时看出messages输出的日志

14 dd命令可生成文件。

dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file

你可能感兴趣的:(Linux)