菜鸟备忘之linux命令基础

1、cd  dir:  

      进入文件夹dir中

2、ls:

      列出所在文件夹中的文件

3、ls  –l:

      列出所在文件夹中的文件的具体信息

4、cat  file:

      显示文件file中的内容

5、rm  file : 

      删除文件

6、rm –r dir : 

      删除文件夹

7、vi   file :

      用vi编辑器编辑文件file

8、ps  -ef:

      查看进程  配合grep使用可过滤关键字段的进程: ps –ef | grep  expProcess

9、echo  “hello”:

      输出 hello

10、chmod 777 file :

      给file赋权,  file权限分 rwxrwxrwx, 777 为左侧所有权限都具备。也就是说所有人都可以对这个文件进行读写和运行。

11、chmod u+x file:

      给file增加执行权限,意思让这个文件的拥有者有执行权限

12、sh  shellscript:

      执行shell脚本,亦可以在进入脚本所在文件夹,赋权chmod u+x后 ./shellscript

13、ifconfig :

      查看网卡信息,如mac地址、ip

14、ping  ip: 

      检查网络通不通

15、tcpdump  -i  eth0 host  1.0.0.0  port 1000 –s0 –w a.cap : 

      抓包,在eth0网卡上抓有关1.0.0.0且端口为1000的数据包,并写入a.cap。之后用工具分析

16、dos2unix file:

      将dos文件转为unix文件。 Windows上的换行是\r\n  unix为 \n  所以在window上编辑的文本要在linux上使用,特别是shell脚本,要运行的话,就必须使用这个命令转换。否则会报什么非法的文件末端错误。

17、mv :

       mvfile1  file2  : 将file1 改名为file2

       mvfile1  dir   :将file1 移动到 dir中

18、cp:

       复制文件 cp  file1 file2

       复制文件夹 cp –r  dir1 dir2

19、scp: 

      远程复制   scp  file1 1.0.0.0:/home/   复制file1到1.0.0.0板子上的/home目录下

20、pwd:

       查看当前目录

21、sed

      对文件进行操作,替换、删除等等

      sed -i ‘s/abc/xx/’a.log  将a.log中的所有abc替换为xx

22、kill

       杀进程 kill -9 进程pid    -9的意思是强杀       killall通杀

23、touch filename

       新建文件  或者 >filename 

24、mkdir dirname

       新建文件夹

25、网络重启

       serivce network start
       service network stop
       service network restart

       rcnetwork restart

只为更简单! --Rydiy

猜你喜欢

转载自blog.csdn.net/rydiy/article/details/8294669