21)改变档案或目录之最後修改时间
==============================
执行格式 touch name ( name 可为档案或目录名称 )
22)档案之连结ln
==========
同一档案 可拥有一个以上之名称 可将档案做数个连结
执行格式 ln oldname newname ( Hard link )
Example
ln file1 file2 将名称 file2 连结至档案 file1
执行格式 ln -s oldname newname ( Symblick link )
Example
ln -s file3 file4 将名称 file4 连结至档案file3
23)档案之字串找寻grep
==============
执行格式 grep string file
Example
grep abc file1
寻找档案file1中 列出字串 abc 所在之整行文字内容
24)找寻档案或命令之路径find whereis which
====================
执行格式 whereis command ( 显示命令之路径 )
执行格式 which command ( 显示命令之路径 及使用者所定义之别名 )
执行格式 whatis command ( 显示命令功能之摘要 )
执行格式 find search-path -name filename -print
( 搜寻指定路径下 某档案之路径 )
Example
%find / -name file1 -print ( 自根目录下 寻找档名为 file1 之路径 )
25)比较档案或目录之内容diff
====================
执行格式 diff [-r] name1 name2 ( name1 name2 可同时为档名 或目录名称 )
Example :
%diff file1 file2
比较档案 file1 与 file2 内 各行之不同处
%diff -r dir1 dir2
比较目录 dir1 与 dir2 内 各档案之不同处
26)档案列印输出lp
============
使用者可用 .login 档中之 setenv PRINTER 来设定列印资料时的列表机名
printername :sp1 或 sp2 (1005 教室)
Example
%setenv PRINTER sp2 设定自 sp2 列印资料
一般档案之列印
==============
执行格式 lpr [-Pprinter-name] filename
%lpr file1 或 lpr -Psp2 file1
自 sp2 列印档案 file1
执行格式 enscript [-Pprinter-name] filename
%enscript file3 或 enscript -Psp1 file3
自 sp1 列印档案 file3
?troff 档案之列印
==================
执行格式 ptroff [-Pprinter-name] [-man][-ms] filename
%ptroff -man /usr/local/man/man1/ptroff.1
以 troff 格式 自 Apple laser writer 列印 ptroff 命令之使用说明
%ptroff -Psp2 -man /usr/man/man1/lpr1
以 troff 格式 自 sp2 列印 lpr 命令之使用说明
列表机控制命令
==============
?检查列表机状态 及列印工作顺序编号和使用者名称
================================================
执行格式 lpq [-Pprinter -name]
%lpq 或 lpq -Psp1
检查 sp1 列表机之状态
?删除列表机内之列印工作 ( 使用者仅可删除自己的列印工作 )
========================
执行格式 lprm [-Pprinter -name] username 或 job number
%lprm user 或 lprm -Psp1 user
删除 sp1 中 使用者 user 的列印工作 此时使用者名称必须为 user
%lprm -Psp2 456
删除 sp2 编号为 456 之列印工作
27)Job 之控制ps
===========
UNIX O.S.,可於 foregrourd 及 background 同时处理多个 process
一般使用者执行命令时 皆是在 foreground 交谈式地执行 process 亦可将 process
置於 background 中 以非交谈式来执行 process
?查看系统之 process
====================
执行格式 ps [-aux]
Example:
%ps 或 ps -x (查看系统中 属於自己的 process )
%ps -au (查看系统中 所有使用者的 process )
%ps -aux (查看系统中 包含系统内部 及所有使用者的 process )
?结束或终止 process
====================
执行格式 kill [-9] PID ( PID 为利用 ps 命令所查出之 process ID )
Example:
%kill 456 或 kill -9 456
终止 process ID 为 456 之 process
?在 background 执行 process 的方式
===================================
执行格式 command & (於 command 後面加入一 "&" 符号即可 )
Example:
%cc file1.c &
将编译 file1.c 档案之工作 置於 background 执行
执行格式 按下 "Control Z" 键 暂停正在执行的 process 键入 "bg" 命令
命令 将所暂停的 process 置入 background 中继续执行
Example:
%cc file2.c
^Z
Stopped
%bg
==============================
执行格式 touch name ( name 可为档案或目录名称 )
22)档案之连结ln
==========
同一档案 可拥有一个以上之名称 可将档案做数个连结
执行格式 ln oldname newname ( Hard link )
Example
ln file1 file2 将名称 file2 连结至档案 file1
执行格式 ln -s oldname newname ( Symblick link )
Example
ln -s file3 file4 将名称 file4 连结至档案file3
23)档案之字串找寻grep
==============
执行格式 grep string file
Example
grep abc file1
寻找档案file1中 列出字串 abc 所在之整行文字内容
24)找寻档案或命令之路径find whereis which
====================
执行格式 whereis command ( 显示命令之路径 )
执行格式 which command ( 显示命令之路径 及使用者所定义之别名 )
执行格式 whatis command ( 显示命令功能之摘要 )
执行格式 find search-path -name filename -print
( 搜寻指定路径下 某档案之路径 )
Example
%find / -name file1 -print ( 自根目录下 寻找档名为 file1 之路径 )
25)比较档案或目录之内容diff
====================
执行格式 diff [-r] name1 name2 ( name1 name2 可同时为档名 或目录名称 )
Example :
%diff file1 file2
比较档案 file1 与 file2 内 各行之不同处
%diff -r dir1 dir2
比较目录 dir1 与 dir2 内 各档案之不同处
26)档案列印输出lp
============
使用者可用 .login 档中之 setenv PRINTER 来设定列印资料时的列表机名
printername :sp1 或 sp2 (1005 教室)
Example
%setenv PRINTER sp2 设定自 sp2 列印资料
一般档案之列印
==============
执行格式 lpr [-Pprinter-name] filename
%lpr file1 或 lpr -Psp2 file1
自 sp2 列印档案 file1
执行格式 enscript [-Pprinter-name] filename
%enscript file3 或 enscript -Psp1 file3
自 sp1 列印档案 file3
?troff 档案之列印
==================
执行格式 ptroff [-Pprinter-name] [-man][-ms] filename
%ptroff -man /usr/local/man/man1/ptroff.1
以 troff 格式 自 Apple laser writer 列印 ptroff 命令之使用说明
%ptroff -Psp2 -man /usr/man/man1/lpr1
以 troff 格式 自 sp2 列印 lpr 命令之使用说明
列表机控制命令
==============
?检查列表机状态 及列印工作顺序编号和使用者名称
================================================
执行格式 lpq [-Pprinter -name]
%lpq 或 lpq -Psp1
检查 sp1 列表机之状态
?删除列表机内之列印工作 ( 使用者仅可删除自己的列印工作 )
========================
执行格式 lprm [-Pprinter -name] username 或 job number
%lprm user 或 lprm -Psp1 user
删除 sp1 中 使用者 user 的列印工作 此时使用者名称必须为 user
%lprm -Psp2 456
删除 sp2 编号为 456 之列印工作
27)Job 之控制ps
===========
UNIX O.S.,可於 foregrourd 及 background 同时处理多个 process
一般使用者执行命令时 皆是在 foreground 交谈式地执行 process 亦可将 process
置於 background 中 以非交谈式来执行 process
?查看系统之 process
====================
执行格式 ps [-aux]
Example:
%ps 或 ps -x (查看系统中 属於自己的 process )
%ps -au (查看系统中 所有使用者的 process )
%ps -aux (查看系统中 包含系统内部 及所有使用者的 process )
?结束或终止 process
====================
执行格式 kill [-9] PID ( PID 为利用 ps 命令所查出之 process ID )
Example:
%kill 456 或 kill -9 456
终止 process ID 为 456 之 process
?在 background 执行 process 的方式
===================================
执行格式 command & (於 command 後面加入一 "&" 符号即可 )
Example:
%cc file1.c &
将编译 file1.c 档案之工作 置於 background 执行
执行格式 按下 "Control Z" 键 暂停正在执行的 process 键入 "bg" 命令
命令 将所暂停的 process 置入 background 中继续执行
Example:
%cc file2.c
^Z
Stopped
%bg
本文介绍了UNIX系统中一系列常用命令,包括改变档案或目录修改时间的touch命令、文件连结的ln命令、字串找寻的grep命令等文件操作命令,以及查看和控制进程的ps、kill等命令,还涉及打印机相关操作命令。
1174

被折叠的 条评论
为什么被折叠?



