- 论坛徽章:
- 0
|
§2 基本的OS命令
§2.1 查找用户信息
Ø
确定谁登陆到了系统(w, who, finger, rusers -l, whodo)
W查看哪些用户在线,是who, uptime, and ps –a的结合
bash-2.03# w
3:21pm up 19 day(s), 10 min(s), 2 users,
load average: 0.00, 0.00, 0.01
User
tty login@ idle
JCPU PCPU what
root
pts/1 12:21pm w
root
dtremote 10:46am 4:35
1 admintool
root
pts/3 10:46am 2:56
admintool
用who可以看出用户是从哪里登陆的
bash-2.03# who
root
pts/1 Sep 7 12:21
(10.50.44.88)
root
dtremote Sep 7 10:46
(172.19.148.164:0)
root
pts/3 Sep 7 10:46
(172.19.148.164:0.0)
用finger同时可以查看用户信息:
bash-2.03# finger
Login
Name TTY Idle
When Where
root
Super-User pts/1 Fri 12:21 10.50.44.88
root
Super-User
dtremote 4:39 Fri 10:46 172.19.148.164:0
查看远程用户登陆情况:
bash-2.03# rusers -l
Sending broadcast for rusersd protocol
version 3...
root
TS-3:pts/1 Sep 7 12:21 (10.50.44.88)
root
TS-3:dtremote Sep 7 10:46
4:41 (172.19.148.164:0)
查看谁在干嘛
bash-2.03# whodo
Fri Sep
7 15:29:00 JST 2007
TS-3
pts/1
root 12:21
pts/1 2961 0:00 bash
pts/1 2995 0:00 whodo
dtremote
root 10:46
? 2732 0:00 Xsession
pts/2 2771 0:00 sdt_shell
pts/2 2773 0:00 sh
pts/2 2787
0:00 dtsession
? 2796 0:00 sdtperfmeter
? 2794 0:00 dtwm
? 2795 0:00 dtterm
pts/3 2800 0:00 sh
pts/3 2861 0:00 bash
pts/3 2866 0:00 dtpad
pts/3
2971 0:00 admintool
pts/3 2862 0:00 textedit
pts/3 2962 0:00 admintool
pts/2 2786 0:00 ttsession
pts/2 2850 0:00 sh
pts/2 2851 0:00 dtpad
? 2775 0:00
dsdm
pts/3
root 10:46
bash-2.03#
Ø
查找UID,GID
bash-2.03# id
uid=0(root) gid=1(other)
§2.2 创建和编辑文件(cat, touch, cp, mv, vi)
Ø
使用cat
bash-2.03# cat > meil
hello
bash-2.03# cat meil
hello
bash-2.03# cat >> meil
hello again
bash-2.03# cat meil
hello
hello again
bash-2.03#
Ø
使用touch
Touch 具有创建文件和修改文件修改时间的功能
bash-2.03# ls -l touch.txt
touch.txt: No such file or directory
bash-2.03# touch touch.txt
bash-2.03# ls -l touch.txt
-rw-r--r--
1 root other 0 Sep
7 15:38 touch.txt
bash-2.03# touch touch.txt
bash-2.03# ls -l touch.txt
-rw-r--r--
1 root other 0 Sep
7 15:40 touch.txt
bash-2.03#
Ø
使用cp ,mv
Ø
使用Text Editor
命令的启动方式有:
/usr/openwin/bin/textedit
&
/usr/dt/bin/dtpad&
Ø
使用vi
注意的是solaris中不支持使用退格.编辑时常用i,a,表示insert , append. D 表示delete, o表示open一个新行.y 表示拷贝,注意是小写. P表示put, 注意是大写.
以下是linux中相关,多数能通用.
需要加强掌握的vi命令
w 移动下个字的开头 word
b 跳到上自个的开头
:1,#d, 删除指定行
X
删除当前光标的左字符
#x
删除后面的#个字符
D
删除到行尾
cw
change word,修改一个单词,
c#w
修改#个单词
cc 修改行
C 替换到行尾
r
replace 取代一个字符
R 取代多个字符
yw 拷贝一个word
P 粘贴
yy 拷贝一行
#yy
拷贝#行
.
重复上一个命令
查找过程中忽略大小写:
:set ic 英文猜测是ignore case , 恢复默认配置:set noic:
读文件到当前位置: :r
file1 英文猜测是read
也可以插入指定行: :line# r filename
编辑多个文件, vi
file1 file2 file3, 键入:n进入下一个文件, 进入下一个文件,不保存对当前文件的修改,键入:n!
Table 20. Some
Basic vi Commands
Task
Command
How to
save/quit a file.
Quit without saving changes.
:q!
Write changes.
:w
Write changes and quit.
:wq
Write changes and quit.
ZZ
How to move
around in a file.
Move cursor one character left.
h
Move cursor one character right.
l
Move cursor up one line.
k
Move cursor down one line.
j
Go to end of the file.
G
How to add
text.
Insert text (insert mode).
i text Esc
Append text at cursor location.
a text Esc
Append text at end of the line.
A text Esc
How to exit to command mode.
Esc
How to make
changes to a file.
Delete line.
dd
Delete character.
x
Delete word.
dw
Open new line above.
O text Esc
Open new line below.
o text Esc
Yank/copy line.
Y
Put before.
P
Put after.
p
§2.3 连接命令和重定向
有; &&
| 等.
§2.4 帮助手册
多数用户命令位于section
(1),系统管理命令位于section
(1M).手册页on a local system or NFS-mounted
from a server.
oak% whatis chownchown chown (1) - change owner of filechown chown (1b) - change ownerchown chown (1m) - change ownerchown chown (2) - change owner and group of a fileoak% man -s2 chownchown(2) SYSTEM CALLS chown(2) NAME chown, lchown, fchown - change owner and group of a file SYNOPSIS #include #include int chown(const char *path, uid_t owner, gid_t group); int lchown(const char *path, uid_t owner, gid_t group); int fchown(int fildes, uid_towner, gid_t group); DESCRIPTIONchown() sets the owner ID and group ID of the file specified by path or referenced by the open file descriptor fields to owner and group respectively. If owner or group is specified as -1, chown() does not change the corresponding ID of the file.(Additional lines deleted from this example)
§2.5 查看磁盘信息
bash-2.03# df -k
Filesystem kbytes used
avail capacity Mounted on
/dev/md/dsk/d2 6198606
277636 5858984 5% /
/dev/md/dsk/d3 15493995 10617294 4721762 70%
/usr
/proc 0 0
0 0% /proc
fd 0 0
0 0% /dev/fd
mnttab 0 0
0 0% /etc/mnttab
/dev/md/dsk/d6 5165838
281252 4832928 6% /var
swap 15280600 16 15280584 1%
/var/run
swap 15281224 640 15280584 1%
/tmp
/dev/md/dsk/d4 31204486 10798255 20094187 35%
/opt
/dev/md/dsk/d7 4133838 5249 4087251 1%
/export/home
bash-2.03# df /opt/
/opt (/dev/md/dsk/d4 ):40812462 blocks 3586164 files
按类型查看:
bash-2.03# df -F ufs
/ (/dev/md/dsk/d2 ):11841940 blocks 740826 files
/usr (/dev/md/dsk/d3 ): 9753402 blocks 1812099 files
/var (/dev/md/dsk/d6 ): 9769172 blocks 616878 files
/opt (/dev/md/dsk/d4 ):40812462 blocks 3586164 files
/export/home (/dev/md/dsk/d7 ): 8257178 blocks 499323 files
bash-2.03# df -F tmpfs
/var/run (swap ):30555744 blocks 887534 files
/tmp (swap ):30555744 blocks 887534 files
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21908/showart_376462.html |
|