Linux常用命令行汇总
Linux常用命令有哪些?下面yjbys小编特为正在学习Linux的同学们分享十五个常用Linux命令行,欢迎阅读!
1. 磁盘使用情况
du -h 查看当前用户每个文件的大小,格式化显示
df -h 磁盘使用情况
[root@localhost mysql5]# du -h
339M
[root@localhost mysql5]# ls
[root@localhost mysql5]# du -h
17M
[root@localhost mysql5]#
[root@localhost mysql5]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
14G 6.4G 6.5G 50% /
/dev/sda1 99M 12M 83M 13% /boot
tmpfs 506M 0 506M 0% /dev/shm
2、常用文件操作命令
cat,显示文件内容。
cd,改变目录路径。
cp,复制文件。
find,查找文件。
grep,搜索、过滤信息。
ls,列出目录信息。
more,分页显示。
rm,删除文件或目录。
vi,调用vi文本编辑器
[root@localhost king]# cat |more
//查找当前目录下以a开头的文件
[root@localhost king]# ls
king001 kingtest new
[root@localhost king]# find -name "a*"
./
./
./
[root@localhost home]# find king -name "a*"
king/
king/
king/
grep查找keyword的所在行的内容
[root@localhost king]# more |grep "1971"
Federal Election Campaign Act of 1971 to provide bipartisan campaign
ls统计文件个数:原理是ls -l列出多少行 再利用管道作为wc -l输入 以行来数的
[root@localhost king]# ls -l
总计 44
-rwxrw-rw- 1 root root 2395 2012-05-26
-rwxrw-rw- 1 root root 2397 2012-05-26
-rwxrw-rw- 1 root root 1020 2012-05-26
drwxrwxr-x 2 king king 4096 2012-02-02 king001
-rw-rw-r-- 1 king king 0 2012-02-02 kingtest
-rw-r--r-- 1 root root 714 09-30 22:52 new
[root@localhost king]# ls -l|wc -l
7
head 查看文件前20行 tail 查看后面10行
[root@localhost king]# head -20
[Congressional Record Volume 148, Number 2 (Thursday, January 24, 2002)]
[Daily Digest]
[Page D12]
From the Congressional Record Online through the Government Printing Office []
House of Representatives
Chamber Action
Measures Introduced: 13 public bills, H.R. 3622-3634; 8 resolutions, H.
Con. Res. 302-308, and H. Res. 335 were introduced.
Page H78
Reports Filed: No reports were filed today.
Speaker Pro Tempore: Read a letter from the Speaker wherein he
appointed Representative Shimkus to act as Speaker pro tempore for
today.
[root@localhost king]# tail -10
Res. 203, providing for consideration of H.R. 2356, to amend the
Federal Election Campaign Act of 1971 to provide bipartisan campaign
reform, the motion was referred to the Calendar of Motions to Discharge
Committees.
Pages H76-77
Senate Message: Message received from the Senate appears on page H39.
Quorum Calls--Votes: One yea-and-nay vote developed during the
proceedings of the House today and appears on pages H47-48. There were
no quorum calls.
Adjournment: The House met at 10 a.m. and adjourned at 3:38 p.m.
Linux命令经典面试题:统计文件中出现次数最多的前10个单词
使用linux命令或者shell实现:文件words存放英文单词,格式为每行一个英文单词(单词可以重复),统计这个文件中出现次数最多的前10个单词。
cat | sort | uniq -c | sort -k1,1nr | head -10
主要考察对sort、uniq命令的'使用,相关解释如下,命令及参数的详细说明请自行通过man查看,简单介绍下以上指令各部分的功能:
sort: 对单词进行排序
uniq -c: 显示唯一的行,并在每行行首加上本行在文件中出现的次数
sort -k1,1nr: 按照第一个字段,数值排序,且为逆序
head -10: 取前10行数据
[root@localhost king]# uniq -c |sort -k1
1 bye
1 good
1 see
1 tim
1 tim
1 you
2 jack
2 king
[root@localhost king]# uniq -c |sort -r|head -2
2 king
2 jack
-
Linux终端命令快捷键汇总
相信很多Linux桌面用户都对使用Linux终端感到反感,其实它没大家想的那么复杂,很多常见操作都可以直接在终端中进行。yjbys特为大家汇总了提升终端命令执行效率的快捷操作,希望能帮助你学习和提升效率。移动定位光标在终端中移动光标和定位似乎非常不便,其实不是你...
-
Linux系统死机解决方法
Linux系统出现死机了咋办?不要着急,下面yjbys小编为大家分享linux出现死机的原因及解决方法!如果Linux系统出现死机,一般分为两种情况:一是硬件问题;二是软件问题。一、硬件问题可以考虑分析以下几点:1、不要超频CPU,如果已经超频的先回复到原来的频率虽然平时运行...
-
2016年Linux认证精选试题及答案
1.关于硬链接的描述正确的(BE)。A跨文件系统B不可以跨文件系统C为链接文件创建新的i节点D可以做目录的连接E链接文件的i节点同被链接文件的i节点2.在网站发布用户wang的个人网页时,需要创建用户网页目录,假定用户网页目录设定为web(用户目录在/home目录下),如下描...
-
Linux中正则表达式使用方法
在Linux系统中使用grep、awk和sed命令时,需要使用正则表达式。那么正则表达式的使用方法有哪些?跟yjbys小编一起来看看吧!比如我通过grep找代码编译结果中是否有错误。或者是否有我代码的错误。这里说下正则表达式基本的应用:•匹配行首与行尾。•匹配数...