solaris commands set 3

七、进程管理
1.ps 显示进程号 命令格式:ps -ef
2.kill 清除进程 命令格式: kill -9 pid
3.nohup 非挂起运行
 
八、软件包管理
1.pkginfo 显示软件包信息
命令格式: pkginfo -d[ device|pathname] -l pkg_name
例子:
这三个域为:
pkg_category 软件包种类,可为application,graphics 或system.
pkg_name 软件包名字,如为SUN产品则机SUNW 起 头.
Description 软件产品的简单说明.

例子:
# pkginfo -d /cdrom/solaris_2_2/s0/Solaris_2.2 |more
利用pkginfo -l 命令显示关于软件包的详细信息,包括软件包的大小(按硬盘块大小计算).
# pkginfo -d /cdrom/solaris_2_2/s0/Solaris_2.2 -l SUNWaudio
上面输出的最后一行指示软件包的大小. 利用此信息和df -k命令来确定你是否拥有足 够硬盘空间来安装此软件包.
2. pkgadd 增加软件包
利用pkgadd 命令增加软件包,当软件包被成功地安装以后,向root发送一个邮件.
命令格式:
pkgadd -d [device | pathname] pkg_name
例子:
# pkgadd -d /cdrom/solaris_2_2/s0/Solaris_2.2 SUNWaudio
3.pkgchk 校验软件包的安装
pkgchk命令通过将软件包的属性及路径名内容与系统记录文件中的值进行对比来校验.命令格式:
pkgchk [-p path1 [path2...]]
此 命令可以检查整个软件包或通过指定-p选项对一特殊路径名进行检查,无输出则意味 着没有问题被检查出.由于/etc/group 文件大小已被改变,所以文件内容的checksum就不对.考察软件包信息pkgadd命令更新文件/var/sadm/install /contents、 此文件为系统中所有已安装软件包的记录文件.没有简单的方法来确定某软件包具有某一特殊文件(或命令).对于已安装的软件包,从/var/sadm /install/contents 记录文件中查找此软件包的路径 名.
4.pkgrm 删除软件包
命令格式: pkgrm pkgname1 pkgname2 …
在调用pkgrm 命令后,将向你警告有依赖关系的软件包信息,并提供放弃此操作的提示.当软件包被成功地删除后,向root发送一个邮件.pkgrm命令通过文件/var /sadm/install/contents 来确定软件包的地址,并且当软件包被删除以后,更新此文件.假如此软件包被两个或更多的包共享,则一定得将这些依赖于此包的所有软件包删除以后才删除此软 件包.
5.spooling 软 件 包
一个软件包可以由安装CD-ROM中拷贝过来存放在系统中,但并没有安装此软件包。例如,一个服务器可以拷贝存储一个软件包,一个没有CD-ROM设备的系统可以从服务器上挂接此软件包,用以安装。软件包也可以利用Software Manager远程安装,暂 略.
服务器下面两个pkgadd命令用以说明如何spool一个软件包到/var/spool/pkg目录下或到一个你指定的目录下.pkgadd命令的-s spool选项会缺省地将软件包拷贝到/var/spool/pkg目录下.
你可以指定一个目录作为-s选项的参数.
客户假如服务器共享了/export/pkgs目录,则客户系统可以挂接目录/export/pkgs并安装软件包.
# mkdir /export/pkgs
# mount venus:/export/pkgs /export/pkgs
# pkgadd -d /export/pkgs SUNWaudio
删除Spooled软件包
在服务器上可以利用-s选项从spooling目录中删除一个软件包.
# pkgrm -s /export/pkgs SUNWaudio
与软件包管理有关的文件和目录

/var/sadm 包含系统记录文件和管理文件的目录
/opt/pkgname 安装未随操作系统一起提供的、名为pkgname的软件包的推荐目录.
/opt/pkgname/bin
/opt/bin 未随操作系统一起提供的、名为pkgname的执行文件的推荐目录.
var/opt/pkgname
/etc/opt/pkgname 未随操作系统一起提供的、名为pkgname的记录文件的推荐目录.
/var/sadm/install/contents 整个系统的软件包映象.
九、数据备份和传输工具
(一) 数据设备名
1.磁带
类型 设备名 容量 机器类型
8mm D8112 5G 8205
8mm D8160 7G 8505-8705
8mm D8170 20G 8900
4mm DDS1(60m) 1.3G  
4mm DDS2(120m) 7G  
4mm DDS3(125m) 12G  
设备名: /dev/rmt/0,/dev/rmt/0n(不倒带)
2.软盘
设备名:/dev/fd0
3.文件
(二) 数据备份命令
Solaris 2.x计算环境提供了几个命令用于备份和恢复文件和文件系统.

多卷备份 连接 系统跨接
ufsdump
ufsrestore Yes No No
tar No Yes Yes
cpio Yes Yes Yes
1.ufsdump命令
对系统管理员而言,ufsdump命令很有用,可对整个文件系统做完全或增量转储.
完全转储是对整个文件系统做备份.在较长的间隔做一次,如一星期或一月.
增量转储是对新创建或修改的文件进行备份.增量转储更频繁一些,可能一天一次.
ufsdump 命令提供了不同等级的转储,从0至9.转储等级用来确定对哪些文件备份.0级指定完全转储,1至9指定不同等级的增量转储.例如,增量转储(1等级)将对 在上一次低等级(0级)转储后修改或创建的文件进行备份.对文件系统作备份时,应将系统转至运行等级S.如系统在运行等级3时,文件可能正在使用,于是可 能造成无效备份.
例子:
# ufsdump 0uf /dev/rmt/0 /export/home
选项及参数:

0 指定0级(完全)转储.
u 更新文件/etc/dumpdates,以记录成功的转储.
f 与下面的/dev/rmt/0参数一起确定转储的磁带设备.
/dev/rmt/0 转储的磁带设备.
/export/home 指定要转储的文件系统.
2.ufsrestore命令
ufsrestore命令从备份磁带上拷贝文件至当前目录下.
ufsrestore命令可用于重载转储好的整个文件系统或备份带上的单个或多个文件.
ufsrestore命令的选项用来指定磁带设备名和被恢复文件的路径名.
恢复过程
用ufsrestore命令按以下步骤恢复一个文件:
# cd /newdir
# ufsrestore tuf /dev/rmt/0
3.tar命令
tar命令是用户级的备份命令,用于备份和恢复文件或目录.
命令格式: tar options tape_device_name [filename]
option c-建立新文档 v-显示路径
t-显示文件列表 f-指定设备
x-抽取文件 i-交互式
例子:
(1)备份过程:
$ tar cvf /dev/rmt/0 *
(2)恢复过程:
$ tar xvf /dev/rmt/0
(3)目录复制
$ tar cvf - mydir|(cd newdir;tar xvf -)
(4) 异地拷贝(必须为可信任用户)
$ tar cvf - mydir|rsh remote tar xvf -
4.cpio命令
cpio(copy in/out)命令是能产生多卷备份的用户级命令.
命令格式:
cpio -ov >tape_device_name
cpio -i [vt] 一旦它识别出介质的尾部,它就提示你插入另一磁带.
cpio命令利用ls或find命令的输出进行文件列表,将这些文件输出到一个文件,
如磁带设备.它在文件之间插入标题以便于恢复,所以比tar命令慢.
cpio命令可用通配符作为参数,然而,cpio反着用通配符,即除满足匹配条件的
文件以外,它将备份所有文件.
备份过程
$ find . -depth -print | cpio -ov > /dev/rmt/0
find命令给cpio命令提供文件和目录名的列表.
-o选项表示从标准输出读.
/dev/rmt/0参数确定磁带设备.
例子:
用find和cpio命令将主目录备份到磁带上:
恢复过程
用cpio命令按以下步骤从磁带上检索文件和目录.
1.将磁带插入磁带设备.
2.改变目录至/tmp目录.
3.用以下cpio目录确定要恢复的文件的路径名.
$ cpio -iv < /dev/rmt/0
-i选项抽取文件,v(verbose)选项与t选项合用则按ls -l格式列出文件,
使用此复合选项只显示文件信息,不抽取文件.
4.用以下cpio命令恢复文件至/tmp目录.
$ cpio -iv < dev/rmt/0 test.file
选项i抽取文件,v表示恢复时显示文件名.
5.从目录/tmp拷贝文件至所需目录.
6.取出磁带.
下面的例子说明如何用cpio命令恢复一个文件.
5.compress,uncompress,zcat 命令
compress命令利用一特殊格式来压缩文件,以减少文件大小.压缩比从20%至80%.
例如,用-v选项对名为bin.file的文件进行压缩:
此文件被压缩后,加上后缀.Z.
zcat < file.taz|tar xvf –
uncompress 解压缩
tar 打包. Tar –cvf 目标文件 源文件。 Tar –xfv ***.tar 解包
gzip / gunzip
6.mt 命令
mt -f /dev/rmt/0 status 报告设备状态
mt -f /dev/rmt/0 rew 倒带
mt -f /dev/rmt/0n fsf 1 前进一段
mt -f /dev/rmt/0n bsf 3 后退两段
7.dd 命令
dd if=/dev/rmt/0 f=/tmp/file bs=1024
8.异地使用磁带机(必须为可信任用户)
(1)备份数据至异地磁带机
tar cvf - dirname|rsh remote dd f=/dev/rmt/0
(2)从异地磁带机读取数据
rsh remote dd if=/dev/rmt/0 tar xvf -
十、改变运行等级
本章介绍基本的系统操作模式、启动和关闭系统的过程等.
关闭系统有几种情况,系统可以彻底关闭,或转入一个中等等级以便完成诸如备份之类的维护工作.
(一)系统引导
启动和关闭系统是系统管理的一个重要部分.
启动(或引导)系统是指操作系统的一部分被装入内存并开始初始化自身.由于系统必须“由自身的自举来将自己提起”所以称为引导或自举.
系统引导后,可用的内存和硬盘设备都被确定下来.系统挂接/(root)文件系统并开始重要的系统处理(如init,pscked,sendmail等).然后使得用户可用注册.
由/sbin/init进程启动一系列shell脚本,完成以下任务:
设定系统的宿主名.
执行文件系统检查程序(fsck).
启动守护程序和网络服务.
一旦脚本执行完毕,系统处在等级3.
有时系统管理员必须修改启动shell脚本以便开始新增加的服务.
(二)系统操作等级
1. 运行等级说明
在Solaris 2.x环境中有8个系统运行等级,这里涉及到4个等级:
(1) 运行等级3
运行等级3也就是完全多用户模式.这是系统的缺省运行等级,也是系统的缺省状态所有系统处理均被执行,文件资源可用挂接,用户可用注册.
(2) 运行等级s,S
运 行等级S是单用户模式,是一个特殊的运行等级.操作系统正在执行,但是所有用户均被注销,大多数系统处理如打印、邮件等都没有执行.只有一个用户,即超级 用户向系统注册.运行等级S对执行备份是很方便的,因为没有用户注册,所以所有数据都是稳定的. 系统由shutdown命令带入运行等级s,S.
(3) 运行等级0
该等级关闭(shutdown)系统至PROM等级,所以此等级对于关电源是安全的.
(4) 运行等级5
该等级关闭(shutdown)系统至关电源状态.
(4) 运行等级6
运行等级6用于关闭(halt)系统至等级0并重新引导至等级3.
2. 显示运行等级
调用who -r命令可以显示系统的运行等级.
$ who -r
run-level 3 Feb 6 15:46 3 2 S
在此例中,系统在缺省等级3.其他域表示:
Feb 6 15:46 最后一次运行等级改变的日期和时间.
3 当前运行等级.
2 最后一次再引导后在此运行等级的次数.
S 前一运行等级.
3.关闭系统的原因
(1)SunTM工作站设计为大部分时间是工作时间.但也有必须关闭系统的时候,运行 等级S用于系统维护,如完成备份等.这一系统等级的变化仍被认为是关闭.
(2) 改变一个系统的配置,如增加或删除某个磁带机或CD-ROM机.
(3) 改变系统硬件配置,如增加或去除一个CPU板子.
(4) 从极端情况的恢复,假如一个挂起的工作站对所有的恢复工作都不反应,可能就必须关掉电源重新开始.
4.关闭系统(shutting down)
关闭系统的方式根据关闭的原因而不同.执行关闭有的是为了转至执行等级S,有的是要停止操作系统并关闭设备的电源.
halt
init 0
(3)紧急关闭
.紧急情况,按Stop_A,如Stop_A不起作用,则将设备电源关闭再打开.这是不得已的极端情况.这两种方法不是干净的关闭,是突然关闭的,仅在紧急情况使用.
(三)例子:
1.增加一个磁带机并完成重新配置引导:
(1)成为超级用户,并确认在/(root)目录下.
(2)键入touch命令:
# touch /reconfigure
(3)键入如下关闭命令:
#halt
(4) 关闭设备电源.
(5) 增加磁带机.
(6) 给设备通电.
2.从挂起的工作站上恢复
如一挂起的工作站对所有键入的命令无反应时,用以下过程恢复:
(1) 按下Stop_A放弃系统并移至PROM监控等级,提示符为: > 或ok
(2)键入sync命令来同步磁盘.
(3)一旦看见“Syncing file system ... done”信息,再按下Stop_A.
(4)发出boot命令来返回至多用户模式.
3.从轻微问题中恢复
如/etc/default/login登记项阻止超级用户注册,也没有用户帐号可以注册,可采用以下步骤恢复:
(1) 按Stop_A放弃系统并移至PROM监控等级.
(2) 输入sync命令来同步磁盘.
(3) 一旦看见“Syncing file system ... done”信息,再按下Stop_A.
(4) 发出boot -s命令至执行等级S.
ok boot -s
(5) 修改/etc/default/login文件以使得root可以注册.
# cd /etc/default
# vi login
(6) 按Control_D,进入运行等级3.
在此过程中,你可能会被提示要输入root口令.

4.从重要问题中恢复
如果你忘记了root口令,或是在/etc/passwd文件中root项无效,则可用以下步骤恢复:
(1) 从Solaris 2.x安装CD-ROM盘上作单独引导.
# boot cdrom -sw
(2) 如需要,可设置终端类型.
#TERM=sun; export TERM
(3) 挂接适当的文件系统并编辑passwd和shadow文件.
# cd /
# mount /dev/dsk/c0t3d0s0/mnt
# cd /mnt/etc
# vi shadow
(4) 卸下文件系统.
# umount /mnt
(5) 重新引导系统.
# reboot
十一、网络应用配置
(一) 网络基本配置文件
1./etc/hosts 主机名解析
2./etc/defaultrouter网关
3./etc/nsswitch.conf 指定查询服务顺序
4./etc/resolv.conf 指定域和域名服务器
5./etc/hostname.hme0 网络接口名
6./etc/netmasks 网络掩码
7./etc/inetd .conf 服务项目定义
(二) 远程访问命令
1. rlogin 在远程机上注册
命令格式 : rlogin hostname -l username
2. rsh 在远程机上执行一个程序
命令格式 : rsh hostname -l username order
3. rcp 在远程系统之间拷贝文件
命令格式 : rsh host:filename filename
(三)访问鉴别相关文件
当rlogin,rsh,rcp命令时,有几个文件对网络安全是很重要的.
/etc/passwd
如远程系统的口令文件有本拥护的登记项,否则必须使用 [-l] 选项以指明不同用户
$home/.rhosts
rlogin,rsh,rcp首先检查用户主目录下的.rhosts文件,如主机及用户被列在文件中,则此用户为可信任主机,不需口令即可登录,如远程鉴别失败,则正常询问口令
/etc/.hosts.equiv
作用与.rhosts 文件类似,文件中列出用户对于本机为可信任用户,
不需口令即可登录(除超级用户)
(四)网络监控
1.rusers 标识网络上注册用户
命令格式:rusers -la
2.rup 标识网络上主机
命令格式:rup
3.ping 检测主机连接状况
命令格式:ping -s [hostname|IP address]
4.spray ping命令格式为低层协议,spray使用高层协议
命令格式:spray hostname
5.netstat 显示与网络有关的各种数据结构
命令格式:netstat -[r| i]n
-r :显示路由信息
-i :显示接口信息
6.ifconfig 显示网络接口
命令格式:ifconfig -a
其中 lo0: 本机自回馈接口
le0: 10M接口
hme0:100M接口
hme1:第二100M接口
7.netstat 显示与网络有关的各种数据结构
命令格式:netstat -[r| i]n
-r :显示路由信息
-i :显示接口信息
8.route 路由设置
命令格式:route [add|delete] 设置网络路由
defaultrouter 9.arp 反响解析
命令格式:arp -[a|s]
十二、图形窗口配置
(本节不作学习要求)
1.双屏配置
(1) /usr/openwin/bin/openwin -dev /dev/fb0 -dev /dev/fb1
(2) /usr/dt/config/Xservers 文件
2.ffbconfig 分辨率调整
命令格式:ffbconfig -dev /dev/fb0 -res mode
此命令只针对creator,creator3D卡
mode : ? 或 1280x1024x76
查看 creator/creator3d: ffbconfig -prconf
3.xwininfo 分辨率确认
4.xhost
命令格式: xhost + 〈- 使能客户显示
5.openwin 初始化
/usr/openwin/lib/openwin-init $home/.openwin-init
/usr/openwin/lib/openwin-menu-programs
6.CDE桌面初始化
/usr/dt/appconifg/C/sys.dtwmrc
7.终端窗口控制字符
erase ^H intr ^C kill ^U start ^Q stop ^S susp ^Z
定义方式:stty erase ^H
十三、系统命令
(非系统安装人员,本节不作学习要求)
1.admintool
2.prtconf
3.sysdef
4.sys-unconfig 重新配置机器
5.eeprom
6.installboot /usr/platform/`uname -I`/lib/fs/ufs/bookblk raw-device
7.网络安装
/cdrom/cdrom0/s0/Solaris2.8/tools/add_install_client -e ether host sun4u
附录: Agile ODC Unix Guidelines
(所有的人员在使用Unix之前,要阅读如下文件)

October 9, 2002

A sizeable investment in time and money has been made to provide Unix systems in the Agile ODC offices. This document defines the guidelines that users and administrators of the Unix systems located in the Agile ODC offices are expected to follow.

These servers were preconfigured before they were shipped from San Jose to insure that they conform. to the install policies that are in place in San Jose. These policies are designed to ensure that the configuration of all Agile Unix systems remain consistent across all of our offices. This promotes ease of use as well as providing an identical environment at each location. This is important to ensure the portability of our software and the environment that our software is tested in.

Guidelines:

1. Users should not change the configuration of the Solaris OS. This means that you should not change the config files in /etc or in any other location on the server. This includes adding new users, mounting NFS partitions, running OS related servers, installing 3rd party software, changing the IP address of the server, changing the permissions of any config file, adding new entries to the hosts files, or any other OS configuration changes.

2. Users should not add any 3rd party software to the Unix systems. This means that you should not install any software that is not part of an Agile product. This includes installing web browsers on any of the available NFS partitions, including your home directory. (Please see the note below about home directories).

3. Users should install Agile related software only in /opt. Users are asked to install Agile software in the /opt filesystem. This keeps all the software in one location. This also means that you should not create (not so) temporary files on the Unix system. The /opt filesystem is available for you to install our software for testing or development. (Please see the note below about home directories). You are expected to install all software that is related to the testing of the Agile software. Internal documentation exists for installing Apache and Apache/SSL. These docs cover the install process of Apache with Weblogic and Apache/SSL with Weblogic. Of course, if you are having problems with an install, help is available.

4. Requests for software installs should be directed to the sysadmin. If you want an additional piece of software installed on the system, please request that the software be installed, rather than trying to install it yourself. This will benefit everyone at Agile as the software will be added to our jumpstart server and distributed to all the Unix hosts for use by all the Agile Unix users. (Please see the note below about web browsers).

5. Users shall not share accounts and passwords. The sharing of Unix accounts and passwords is prohibited at Agile. It is your responsibility to keep your password private and not share it. Since we are using sudo at Agile, your password might provide root access on a given server. Please do not share your Unix account or password with anyone. If an employee needs a Unix account, then we will be happy to give them an account. We have not turned down any new account requests. Please do not share your Unix account or password with anyone.

6. Users should not reboot Unix systems. If you think you need to reboot a Unix system, most likely you probably don't. Unix servers are not windows boxes. It is common to see Unix systems that have been up for three to four months at a time. Generally speaking, problems won't be magically fixed if you reboot (as happens with Windows). This is because there is no Registry in Unix and because user processes typically cannot cause kernel level corruption of the OS. If, after all of this, you still feel you need to reboot the server, you should contact your local system admin and ask them to reboot the server. In case of an after hours emergency reboot, please send email to your local admin before rebooting informing them that you are about to reboot the server.

7. Users should share the Unix systems. The Solaris Unix systems that we have here are multi-user multitasking servers. They are capable of supporting hundreds of concurrent users and thousands of concurrent processes. We will be moving to a model where multiple engineers are sharing the same Unix server. You are expected to share the Unix servers with other people who are testing or installing on the same system as you are. This means that you might have to configure your install to use non-standard ports. The recommended manner of doing this is to install your software in a sub-directory of /opt, such as /opt/yourname. If you need to have multiple copies of a product, perhaps /opt/yourname/inst1 or /opt/yourname-inst1 would be a good alternative. For the port selection, we are going to have to communicate better. Please use either 'lsof -i or 'netstat -a' to look for processes that are "LISTEN'ing" to a particular port. If you want port 7001 and there is a process already there, select 7011 or 7101. It is also recommended that you normally test install with non-default ports. This leaves the default ports available for "stock" install testing.

Note about web browsers:
The Agile Unix environment currently supports only Netscape 6.2 for Unix as a Unix web browser. We do not support IE as Microsoft has dropped support for their Unix web browser product.

Netscape should be installed on your local Unix servers by your local admin. It should be located in /opt/netscape62. Users should not install the Netscape Unix browser independently on the Unix servers. Please see you local Unix admin if you cannot find Netscape on an Agile ODC Unix server.

Note about home directories:
Your home directories are NFS mounted from your local admin server onto all the local Unix hosts. The purpose of this is to provide disk space for you to keep information that you would like to hold on to.

Your home directory is not a place for you to install software that you want to run on the Unix hosts. This includes web browsers, 3rd party software and any Agile software. Please do not install any software on the admin NFS partition that you plan to run a Unix host. The software will run slower from the admin server than from a local server, it will put an increased load on the network and the admin server. In general, it is not a good practice to run programs over NFS when the local server has the disk resources to host the application.



Link URL: http://hyyuanqiang.blog.163.com/blog/static/594151372009218105914394

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12165911/viewspace-604330/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12165911/viewspace-604330/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值