教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 专业资料 >

UNIX系统常用命令(2)

来源:网络收集 时间:2026-05-23
导读: -perm 00x000 八进制文件属性 -atime n n天之前访问过的文件 -mtime n n天之间修改过的文件 -ctime n 文件的状态在n前之间修改过 -exec command 如命令的返回代码为零(找到相应的文件)则真,command必须以 \; 结果

-perm 00x000 八进制文件属性

-atime n n天之前访问过的文件

-mtime n n天之间修改过的文件

-ctime n 文件的状态在n前之间修改过

-exec command 如命令的返回代码为零(找到相应的文件)则真,command必须以

\; 结果,此外在命令的执行中 {} 为查找到的文件路径名

-ok command 与exec相类似,但在执行每个命令之间要求用户确认 -print 打印当前路径名

-newer filename 如文件的最后修改日期较filename新则为真

-type c c=[b,c,d,l,p,f]文件类型

-user username 如文件的属主为username则为真

-nouser 文件属主在/etc/passwd文件中不存在

-group grouname 文件组

逻辑运算符: -a -o !

示列:

find $HOME \( -name a.out -o -name "*.o" \) -atime +7 -exec rm {} \; find . -atime 0 -print

find / .name .profile -print

find . -perm 777 -a -mtime 7 -exec chmod 755 {} \;

file

more

less

tail (tail -f filename)

head

wc

read 用于shell编程

col

pg (SYSV)

11. 编辑器

vi

ed

joe

12. 文件内容查找

grep

UNIX系统常用命令

正规表达式: . * ^ $ + ? []

strings

13. 任务调度

at

atq 列出队列中的任务

crontab

14. 存储,归纳及压缩

compress .Z

uncompress .Z

cpio

dd dd if=inputfile of=outputfile

dd if=boot.img of=/dev/fd0H1440

pack .z 30%-50%文本文件

pcat pact file.z

gzip .gz

gunzip

tar tar -[txc]vf targetfile [sourcefile]

tar -cvf target.tar sourcefilelist

tar -tvf target.tar [filename]

tar -xvf target.tar [filename]

GNU TAR:

tar -zcvf target.tar.gz sourcefilelist

tar -zxvf target.tar.gz [filelist]

tar -ztvf target.tar.gz [filelist]

zcat .Z

uuencode

uudecode

15. 其他命令

date

env

unix2dos (linux没有)

dos2unix

uname

uptime

UNIX系统常用命令

time

top

16. 文本处理

cut

fmt 每行格式转化为72列,用于邮件格式化

fold 折行处理,一行到多行,一般为80列

join

paste

sort

tr

tr '\"' '' < file1

#!/bin/sh

for i in *

do

mv $i `echo $i |tr /[a-z]/[A-Z]/`

done

uniq 报告/删除文件中相同的复制行

sed 流编辑器

sed 's/96/tt/' student.txt

awk

awk '{print $1" "$2}' sourcefile

awk -f class.awk student.txt > linux-student.txt

文件class.awk内容如下:

#

#class.awk

#

BEGIN {printf "%-12s%s\n","班级","学号 姓名";

printf "-------------------------------------------\n\n"}

/[1-9]+\B*$/ {class=$0}

/^9[5-8]+/ {printf "%-12s%s\n", class,$0 | "sort"}

#Enf of class.awk

awk -f traffic.awk traffic.txt

文件traffic.awk内容如下:

#

#traffic.awk

UNIX系统常用命令

{ if ( $2 < 10000 ) t_0 += $2;

if ( $2 > 10000 && $2 < 50000) t_10 += $2;

if ( $2 > 50000 && $2 < 100000) t_50 += $2;

if ( $2 > 100000) t_100 += $2;

total += $2 }

END {printf "t_0 = %dKB %5.2f\%\n",t_0,t0*100/total;

printf "t_10 = %dKB %5.2f\%\n",t_10,t10*100/total;

printf "t_50 = %dKB %5.2f\% \n",t_50,t_50*100/total;

printf "t_100 = %dKB %5.2f\%\n",t_100,t_100*100/total;

printf "Total = %dKB\n", total}

#End of traffic.awk

17. 网络配置命令及故障排除命令

17.1 ifconfig

Interface Config , 网卡配置命令, 相关文件:/proc/net/dev

详细使用说明: man ifconfig

示例:

#ifconfig

lo Link encap:Local Loopback

网卡标识 封装类型: 本地回环

inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0

IP地址:127.0.0.1 广播地址:127.255.255.255 子网掩码:255.0.0.0

UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1

已启动 接受广播 本地回环 正在运行 最大传输单元: 3584 路由距离向量:1

RX packets:718 errors:0 dropped:0 overruns:0 frame:0

已接受数据包:718

TX packets:718 errors:0 dropped:0 overruns:0 carrier:0

已发送数据包:718

collisions:0

碰撞:0

eth0 Link encap:Ethernet HWaddr 00:80:C8:4C:6A:D0

网卡标识 封装类型: Ethernet 硬件(MAC)地址: 00:80:C8:4C:6A:D0

UNIX系统常用命令

inet addr:202.118.66.81 Bcast:202.118.66.255 Mask:255.255.255.0

IP地址:202.118.66.81 广播地址:202.118.66.255 子网掩码:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

已启动 接受广播 正在运行 多点广播 最大传输单元: 1500 路由距离向量:1

RX packets:13900 errors:0 dropped:0 overruns:0 frame:0

已接受数据包:13900

TX packets:5859 errors:0 dropped:0 overruns:0 carrier:0

已发送数据包:5859

collisions:0

碰撞:0

Interrupt:10 Base address:0xe400

中断(IRQ):10 端口地址: 0xe400

#ifconfig eth0 显示eth0的相关信息

#ifconfig -a 显示所有网络设备的配置信息

#ifconfig eth0 down Down掉eth0

#ifconfig eth0 202.118.66.81 broadcast 202.118.66.255 [up]

#ifconfig eth0 202.118.66.81 broadcast 202.118.66.255 netmask

255.255.255.0

#ifconfig eth0 up

17.2 route

路由表维护命令, 相关文件: /proc/net/route

$ /sbin/route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

localnet * 255.255.255.0 U 0 0 49 eth0

192.168.1.0 * 255.255.255.0 U 0 0 655 eth1

192.168.2.0 * 255.255.255.0 U 0 0 498 eth2

192.168.3.0 * 255.255.255.0 U 0 0 825 eth3

127.0.0.0 * 255.0.0.0 U 0 0 13 lo

default olive.dlut.edu. 0.0.0.0 UG 1 0 4834 eth0

#route add default gw 202.118.66.1

#route add default gw 202.118.66.1 …… 此处隐藏:3838字,全部文档内容请下载后查看。喜欢就下载吧 ……

UNIX系统常用命令(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/269906.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)