首页 > Linux操作系统 > Linux操作系统 > linux之常用命令
1 date----显示、修改系统时间
date [options][+format][date]
$ date -s 06/09/2004 修改日期(按月日年格式)
$ date -s 13:56:00 修改时间(按时分秒格式)
$ date -r test 显示test文件最后一次的修改时间
$ date +'%Y-%m-%d' 以yyyy-mm-dd格式显示日期,其它格式请参考帮助
$ clock -r 查询BIOS时间
$ clock -w 把修改后的时间写回BIOS
2 uniq----过滤、统计、删除重复行
uniq [options][file1 [files]]
$ uniq -c file file中的重复行输出一次,并在每行前显示重复次数
$ uniq -d file file中的重复行输出一次,但不输出唯一的行
$ uniq -u file 只输出file中的唯一行
$ uniq file1 file2 把file1中的重复的相邻行删除,并把每行的一个拷贝送到file2
3 wc-----输出每个文件中的字符数、单词数及行数。
wc [options][files]
$ wc -l file 输出file中的行数
$ wc -w file 输出file中的单词数
$ wc -c file 输出file中的字符数
4 shutdown-----终止所有进程序,关闭计算机。
shutdown [options] when [message]
用when可以是指定的关机时间(以hh:mm格式)、关机前要等待的时间(以+m格式)、或者now。message指定一条广播消息通知所有用户退出系统。showdown给所有进程发送SIGTERM信号,并调用init 1执行实际的关机动作。
$ shutdown -c 取消正在进行的关闭操作
$ shutdown -f 快速重新启动,在重新启动时禁止对fsck的常规调用
$ shutdown -h 当关闭完成时停止系统
$ shutdown -k 输出警告信息,但禁止实际的关闭
$ shutdown -n 不调用init就执行关闭
$ shutdown -r 当关闭完成时重新启动系统
$ shutdown -t 5 在杀死进程和改变运行级别之间确保延时5秒
5 tac从最后一行开始显示
6 nl显示同时输出行号
7 less与more类似,但其优点是,可以往前翻页
8 head只看头几行
head[-n number] [文件名]
-n显示number行
head -n 20 test.txt
显示test.txt前20行
head -n 20 test.txt | tail -n 10
9 tail只看未尾几行
tail [-n number] [文件名]
-n显示number行
tail -n 20 test.txt
显示test.txt后20行
10 od以二进制的方式读取文件内容
11 cat[-n]
-n连行号一起输出到屏幕上 与nl相似
12 less[文件名]
less的用法比more更有弹性,使用less可以用pageup、pagedown翻看
less test.txt
/word
在test.txt中搜寻word这个字符串
q:退出less
13 如何在vi中做到高亮显示
:set hlsearch
或是在~/.vimrc李加上一行:
set hlsearch
取消高亮:就set nohlsearch
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20976446/viewspace-683729/ ,如需转载,请注明出处,否则将追究法律责任。