| 关键词: 进程 用户 txt 文件 tar user 00 test 一个 优先权 |
cpio #cpio -idcmv < lnx_902_disk1.cpio 截压缩 tar # tar cvf backup.tar list ok.txt test.txt //备份生成backup.tar a list 1K a ok.txt 1K a test.txt 1K #tar rvf backup.tar tt.txt //追加tt.txt到backu.tar中去 # tar cvf backup.tar tt.txt //注意会覆盖backup.tar原有的文件 a tt.txt 1K # tar cvf /export/home/wing/mywife.tar ok2.txt ss // 备份到另一个目录 # tar xvf backup.tar //全部还原出来 # tar xvf backup.tar tt.txt //把指定的文件还原出来 tar: 块大小 = 4 x tt.txt, 290 bytes, 1 tape blocks # tar tvf backup.tar //查看里面被压缩了的文件名,并没有解压出来 tar: 块大小 = 4 -rw-rw-rw- 1002/1 290 2003 10月 3 02:10 tt.txt $tar uf myarch mydir //t a r将比较每个存档文件和用户目录中文件的最近更新时间,然后将任何自从上次存档以来所改变的文件拷贝到档案中 参数 说明 c 创建一个新的tar文件 t 列出tar文件的内容 x 从tar文件中解压出指定的文件 r 向已有的tar文件追加一个新文件进去 f 指定文件名 v 详细模式 m 将在从一个档案中抽取文件时,不要给它新的时戳 compress # compress -v kk.txt mm.txt kk.txt: 压缩:58.18% -- 用kk.txt.Z替换 //注意原来的文件将被.Z所替代 mm.txt: 压缩:1.33% -- 用mm.txt.Z替换 # ls err.txt kk.txt.Z mm.txt.Z tt.txt # uncompress -v ok2.txt.Z //解压缩,注意原来的.Z文件将被ok2.txt替代 # uncompress -c test1.Z|more //只是查看文件的内容,没有解压出来 zip #zip winzip test1.txt test2.txt //生成winzip.zip文件 #unzip winzip.zip //解压缩 gzip # gzip -v test2 test3 test2: 0.0% -- replaced with test2.gz//注意把原来的给替换了 test3: 0.0% -- replaced with test3.gz # ls test2.gz test3.gz gunzip #gunzip test2.gz gzcat #gzcat tt.txt.gz -rw-r--r-- 1 keven user 32 10月 2 07:51 test.txt -rw-r--r-- 1 keven user 0 9月 30 08:54 test3 -rw-r--r-- 1 keven user 0 9月 30 08:54 test2 -rw-r--r-- 1 keven user 0 9月 30 08:54 test1 用户和权限 chmod #chmod u+r test.txt #chmod go+rw test.txt #chmod o-w test.txt #chmod 555 test.txt #chmod +t dir //粘带位权限 #chmod g+s file.txt //setuid #chmod u+s file.txt //setgid chown #chown new_owner filename #chown -R new_owner directoryname chgrp #chgrp new_group filename #chgrp -R new_group filename nice #nice -20 dtterm //优先级增加到20 数值越大优先级越高 #nice --20 dtterm //优先级减少到20 groups $ groups //显示自己所在的组 adm $ groups root //显示该用户属于什么组 other root bin sys adm uucp mail tty lp nuucp daemon newgrp $newgrp adm //切换到其它的组 umask % umask 22 起始权限-想得到的权限=umask值 useradd #useradd user3 #useradd -u 1006 -g 4 -d /export/home/user3 -s /bin/sh -c “web user” user3 //完整的添加用户 #useradd -u 1006 -g 4 -d /export/home/user3 -m -s /bin/sh -c “web user” user3 //创建用户的同时创建主目录文件 参数 说明 -c 对每个用户的注释,记录每个用户的个人信息 -d 用户主目录路径 -m 用来创建用户的主目录,通常与-d路径名一起用 -g 用户的默认组 -g 用户的默认gid -e 帐号不再有效,通常在创建临时帐号用 -f 许可用户的最大闲置天数,在创建临时帐号时用到 -u 用户的uid -s 用户的shell路径 userdel #userdel user7 //把user7删除,但是不删住目录 #userdel -r username //把主目录一起删除 usermod # usermod -u 1005 -c adminisrator cole //修改用户的一些信息 #usermod -G group1 ,group2 username //把用户添加到多个组 # usermod -G sys,sysadmin cole # groups cole mail sys sysadmin # usermod -g apache cole //主要组 # groups cole apache passwd #passwd -f user //下次登陆时强制其改变密码 #passwd user //修改其密码 #passwd -l user //锁住用户不能登陆 #passwd -x 30 user //口令有效期为30天 #passwd -w 3 user //口令失效的前3天提醒用户修改 groupadd # groupadd -g 2000 usergroup groupdel #groupdel groupname groupmod #groupmod -n newname oldname #groupmod -g gid groupname //修改其gid #groupmod -g gid -n newname oldname 进程管理 ps 字段概述: F十六进制标志,它们加起来表示进程的当前状态。 如下所述:00 进程终止,而且它们在进程表中的空间已释放。01 系统进程,长驻内存02 进程被父进程跟踪04 进程被父进程跟踪而且已被停止08 该进程无法被信号量唤醒10 该进程当前在内存中,而且被锁定直到一个事件完成20 进程不能被交换出 S 进程当前状态,由以下字母之一显示: O 当前正在处理器上运行 S 睡眠;等待I/O事件完成 R 运行结束I 空闲;进程被创建 Z 僵死。进程已终止 T由于父进程跟踪而停止 X 等待更多的内存 UID进程所有者的用户ID PID进程ID PPID父进程ID C 进程的CPU使用情况(即进程占CPU时间的百分比) PRI 进程优先权方案。较大的数表示较低的优先权 NI 进程的nice值,该值与优先权方案相关联。使一个进程“nicer”意指降低该进程的优先权,以使它不会用尽CPU的时间 SZ进程请求的虚拟内存量。这是该系统对内存需求的一个好的指标。 TTY 启动进程(或者父进程)的终端。带问号的进程无控制终端(通常为系统进程) TIME自进程启动以来占CPU时间总量 COMD产生进程的命令 # ps -f UID PID PPID C STIME TTY TIME CMD keven 360 358 0 19:19:19 pts/2 0:00 -csh keven 477 360 0 19:28:14 pts/2 0:00 ps -f # ps -u wing //特定用户 PID TTY TIME CMD 368 pts/3 0:00 sh # ps PID TTY TIME CMD 360 pts/2 0:00 csh 475 pts/2 0:00 ps # ps -e PID TTY TIME CMD 0 ? 0:01 sched 1 ? 0:00 init 2 ? 0:00 pageout 3 ? 0:00 fsflush 328 ? 0:00 sac 331 ? 0:00 ttymon 153 ? 0:00 rpcbind # ps -ecl //PRI为进程优先权,这里98为最高 F S UID PID PPID CLS PRI ADDR SZ WCHAN TTY TIME CMD 19 T 0 0 0 SYS 96 fec287cc 0 ? 0:00 sched 8 S 0 1 0 TS 59 de7a8808 319 dea06e16 ? 0:00 init 19 S 0 2 0 SYS 98 de7a8108 0 fec4d4b8 ? 0:00 pageout 19 S 0 3 0 SYS 60 de7a7a08 0 fecea0bc ? 0:01 fsflush 8 S 0 329 1 TS 59 de7a7308 448 deac8d68 ? 0:00 sac 8 S 0 256 1 TS 59 de7a6c08 1084 deeb7f02 ? 0:00 sendmail $ ps -eaf UID PID PPID C STIME TTY TIME CMD root 0 0 0 19:18:44 ? 0:01 sched root 1 0 0 19:18:44 ? 0:00 /etc/init - root 2 0 0 19:18:44 ? 0:00 pageout root 3 0 0 19:18:44 ? 0:00 fsflush root 328 1 0 19:19:10 ? 0:00 /usr/lib/saf/sac -t 300 root 331 328 0 19:19:10 ? 0:00 /usr/lib/saf/ttymon root 153 1 0 19:18:53 ? 0:00 /usr/sbin/rpcbind #ps -eaf |grep wing root 317 1 0 19:19:10 ? 0:00 /usr/lib/dmi/snmpXdmid -s wing root 329 1 0 19:19:10 console 0:00 /usr/lib/saf/ttymon -g -h -p wing console login: -T sun-color -d /dev/console wing 368 366 0 19:19:47 pts/3 0:00 -sh 用法:ps [ -aAdeflcjLPy ] [ -o 格式 ] [ -t 项列表 ] [ -u 用户列表 ] [ -U 用户列表 ] [ -G 组列表 ] [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] 选项 意义 功能 ps 无选项 显示在当前shell和终端窗口中的用户进程信息 ps -e every 显示系统中每一个进程的信息 ps -f full 生成一个长列表,显示每个进程的所有可用信息 ps -u userid user 显示特定用户的所有进程信息 $ ps -u wing //wing为用户名 PID TTY TIME CMD 368 pts/3 0:00 sh 494 pts/3 0:00 ps $ ps -U wing PID TTY TIME CMD 368 pts/3 0:00 sh 495 pts/3 0:00 ps $ ps -G user //user为组名 PID TTY TIME CMD 360 pts/2 0:00 csh # priocntl -l CONFIGURED CLASSES ================== SYS (System Class) 系统 TS (Time Sharing) 分式共享 Configured TS User Priority Range: -60 through 60 FX (Fixed priority) Configured FX User Priority Range: 0 through 60 IA (Interactive) 交互 Configured IA User Priority Range: -60 through 60 对于分式共享级,用户提供的优先权范围为:-20~+20 # ps -ecl F S UID PID PPID CLS PRI ADDR SZ WCHAN TTY TIME CMD 19 T 0 0 0 SYS 96 fec287cc 0 ? 0:00 sched 8 S 0 1 0 TS 59 de7a8808 319 dea06e16 ? 0:00 init pgrep //查看进程 # pgrep -lf inetd 616 /usr/sbin/inetd -s -t $ pgrep -l lp 217 lpsched kill signal: 1 暂停 2 中断 3 退出 4 非法指令 5 跟踪中断 6 Abort 7 EMT指令(Emulation竞争trap) 8 浮点格式的异常情况 9 kill(不能被捕获或忽略) 10 通道错误 11不合法的内存区段 12 错误系统调用 13 写入不可读的连通管道 14 alarm clock 15 软件结束信号 16 用户定义的信号1 17用户定义的信号2 18 子进程状态被改变 19 电源坏掉 20窗口(Window)的大小被改变 21Urgent(紧急的)Socket Condition 22 Pollable(可查询的)event 23 停止 24 由用户终止 25 继续执行 26 停止终端输入 27 停止终端输出 28 virtual Timer expired 29 Profiling time expired 30 超过CPU时间 31 超过文件大小限制 32 Socket I/O possible #kill -9 368 //强行杀死一个进程 #kill 368 //杀死一个进程,使用15为默认值,为软杀死 kill -HUP ID //重启一个进程 $sleep 500& $jobs [1]+Running sleep 500 $sleep 500 ^z [1]+stopped sleep 00 $jobs [1]+stopped sleep 500 $bg |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|