码迷,mamicode.com
首页 > 系统相关 > 详细

Linux基础命令--常用命令工具

时间:2016-12-26 14:17:48      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:linux常用基础命令

1 cd 切换工作目录

[root@localhost ~]# cd /usr/local/    #切换到目录/usr/local下

[root@localhost local]# cd ..       #切换到上一级目录

[root@localhost usr]# cd -        #返回到/usr/local下

/usr/local                

2 touch 创建或修改文件

[root@localhost ~]# touch test.txt

在当前目录下,若果不存在test.txt,就直接创建;若果存在,则是更新文件时间

3 mkdir 创建目录

[root@localhost ~]# mkdir game        #创建目录game

[root@localhost ~]# mkdir -p /home/test/game  #创建多级目录

[root@localhost ~]# mkdir test gamek hello   #创建多个目录

4 pwd 显示当前路径

[root@localhost test]# pwd

/home/test                   #返回当前工作目录

5 ls 显示目录和文件信息

[root@localhost game]# ls            #显示当前目录和文件的名称

[root@localhost game]# ls -a           #显示包含的隐藏文件

[root@localhost game]# ls -l           #显示文件和目录的详细信息

[root@localhost game]# ls -lh          #显示容量信息

[root@localhost game]# ls -ld /home        #查看当前home目录自身的详细信息

[root@localhost game]# ls -lt          #查看有时间排序的详细信息

[root@localhost game]# ls -lu           #显示最后到访时间

[root@localhost game]# ls -lc           #显示属性变更的时间

6 mv 移动或者重命名目录和文件

[root@localhost ~]# mv test.txt text.py     #将text.py 改名为text.py

[root@localhost ~]# mv text.py /home/      #将text.py移动至/home下

7 cp 复制文件和目录

[root@localhost ~]# cp /etc/passwd /home/    #复制passwd到/home下

[root@localhost ~]# cp /etc/passwd /home/pass   #复制passwd到/home下改名为pass

[root@localhost ~]# cp -r /home/logs /tmp/    #复制子文件和目录到/tmp/下

8 rm 删除

[root@localhost ~]# rm test        #删除test

[root@localhost ~]# rm -rf test      #彻底删除且不提示

9 du 显示文件和目录的容量

[root@localhost ~]# du -sh /home     #查看/home所占用的空间

10 df 所有文件系统的使用情况

[root@localhost ~]# df -a        #查看分区及使用情况

[root@localhost ~]# df -i        #查看分区iNode使用情况

[root@localhost ~]# df -h        #带单位显示使用情况

11 cat 查看文件内容

[root@localhost ~]# cat -b /home/passwd  #显示行号,空白行不显示

[root@localhost ~]# cat -n /home/passwd  #显示行号,包括空白行 

12 more 分页查看 

[root@localhost ~]# more /tmp.log      #分页查看,空格看下一页,q退出

13 less 分页查看

[root@localhost ~]# less /tmp.log     #分页查看,空格看下页,方向键可翻页,q退出

14 head 查看文件头部,默认显示前10行

[root@localhost ~]# head -c 10k /tmp.log    #查看前10k的内容

[root@localhost ~]# head -20 /tmp.log      #查看前20行内容

15 tail 查看文件尾部 默认最后10行

[root@localhost ~]# tail -c 10k /tmp.log     #查看尾部10k的内容

[root@localhost ~]# tail -20 /tmp.log       #查看后20行

[root@localhost ~]# tail -f /tmp.log       #动态查看

16 wc 统计行信息

[root@localhost ~]# wc -c /tmp.log        #统计字节数

[root@localhost ~]# wc -l /tmp.log        #统计行数

[root@localhost ~]# wc -w /tmp.log        #统计单词数


本文出自 “实用Linux知识技能分享” 博客,请务必保留此出处http://superleedo.blog.51cto.com/12164670/1886113

Linux基础命令--常用命令工具

标签:linux常用基础命令

原文地址:http://superleedo.blog.51cto.com/12164670/1886113

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!