Solaris系统管理培训

Solaris系统管理培训(第一章:系统概念)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

第一章:系统概念(System Concepts) 
Objectives 

Upon completion of this module, you should be able to

  Match the three parts of an operating system (kernel, shell, and file system) to their definitions
  Identify the three most common shells in the Solaris environment
  Distinguish between multitasking and multiuser
  Describe the client-server relationship
  Define the following basic system terms: host, host name, network,
  IP (Internet Protocol) address, client, and server

操作系统的主要三个部分 
UNIX操作系统是基于文件的,操作系统的主要三个部分是: 
  Kernel 
  Shell 
  File structure 

Kernel 是操作系统的核心,它的主要功能是: 
 管理系统的设备、内存、进程以及守护进程 
 系统程序与系统硬件之间接口 
 执行所有的命令 
 管理: 
   Swap space(交换分区) – 系统运行时保留的一部分磁盘空间
   Daemons (守护进程)– 处理特定的系统任务

shell 是用户与kernel之间的接口。它就像是命令的解释器或翻译器。Shell接收你输入的命令,对你的输入作出解释,然后就将它发送给kernel执行。
操作系统的 Shells种类 
Solaris系统中有三种shell: 
  Bourne shell ($) – 这是Solaris的缺省shell。Bourne shell为 AT&T UNIX 环境而开发。(/usr/bin/sh)
  Korn shell ($) – 是Bourne shell的一个超级。它增加了一些功能,如:别名、历史记录以及命令行编辑等。(/usr/bin/ksh)
  C shell (%) –C shell的语法类似于C语言,并且,C shell有些功能与 Korn shell相类似。(/usr/bin/csh)

Solaris环境的文件结构是分成的目录树结构,类似于DOS的文件结构。是一些有特定目的而组织在一起的目录、子目录和文件。
目录 (Directory) – 其他目录和文件所在处
子目录(Subdirectory) – 属于其他目录的所有目录

根目录(/)位于目录树的最顶层,包含 : 

/usr目录包含系统的一些命令、工具、库文件等 。 
/opt目录包含的三方应用软件。 
/dev目录包含诸如磁盘、键盘、磁带机、显示器等地设备驱动程序。
/etc目录包含系统配置文件,如用户口令文件等等。 
/export目录一般包含用于NFS共享的目录。 
/export/home目录包含用户的个人主目录。 
/kernel目录包含系统结构的kernel文件。这个目录下的文件genunix是系统的UNIX kernel 。

虚拟内存操作系统——交换分区(Swap Space) 
  虚拟内存操作系统增大了物理内存,它将硬盘中的一部分空间用于存储暂时不用内存数据。这块硬盘空间叫做交换分区。与Windows下的SWAP文件的功能相似。
守护进程(Daemons) 
  守护进程是在后台运行的程序,它负责系统的某个特定的功能,比如打印。

系统管理的一些常见的概念: 
主机(Host) – 网络环境下的某台计算机系统。 
主机名(Host name) – 某台系统的名字,网络中的任何系统都必须有自己的主机名。
IP地址(IP address) – 网络软件用于鉴别网络中某台机器的一个数字符号。
客户机(Client) – 使用网络中一个和多个服务的主机和进程。
服务器(Server) – 在网络中提供一个或多个服务的主机和进程。
网络(Network) – 许多机器连接在一起、可以互相通信的集合。

Solaris有下列特性: 
多任务(Multitasking) – 多个进程或应用程序可以同时运行。
多用户(Multiuser) – 同时可以有多个用户访问系统资源。
分布处理(Distributed processing) – 通过网络使用资源。

 

Solaris系统管理培训(2)

Solaris系统管理培训(第二章:OpenBoot PROM)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

OpenBoot PROM介绍 
所有Sun机器都一个用于基本硬件测试和初始化的固件,还有一个提供多种重要功能的用户程序。
   基本元素 
Sun系统的基本硬件元素包括: 
Boot PROM芯片,它永久的固定在主板中。 
非易失性随机访问内存(non-volatile random access memory (NVRAM) )芯片,包含主机的基本信息。 

Boot PROM内容 
boot PROM有以下功能: 
  加点自检(Power-on self-tests (POST)) 
    系统重起始开始执行。
    检测基本CPU板 
    因机器型号不同而不同。
  设备驱动 
   有一些小型设备驱动程序,使得启动的初始化过程中可以与不同的外围设备相通讯
  用户操作界面 
NVRAM 内容 
 除了永久性存在地以太网地址、主机ID、时钟外,还保存着可以修改的系统的配置参数。

Basic Boot PROM Commands 
ok banner 
ok boot 
ok help 
ok printenv 
ok setenv 
ok set-defaults 
ok probe-scsi 
ok probe-scsi-all 
ok probe-ide 
ok reset 
The Open Boot banner Command 
The banner command lists several pieces of useful information about the system such as model, amount of memory, and hostid. You can also use the banner command to identify your system’s PROM version number. Three boot PROM levels are discussed in this module. 
ok banner 
Sun UltraSPARC 60 UPA/PCI (2 X UltraSPARC-II 296MHz), Keyboard Present 
OpenBoot 3.11, 256 MB memory installed, Serial #3159808. 
Ethernet address 8:0:22:1a:e7:3f, Host ID: 72303700. 
ok 
boot 命令和参数 
您可以在boot命令后键入一个或多个参数。这些参数传递改操作系统内核,将影响整个启动过程。
命令格式 
ok boot [device_name] - [options] 
参数 
a 交互式启动系统。提示输入根设备和交换设备以及一些重要的系统文件
r 启动时系统将重新查找所有的设备,在/devices和/dev目录下重新生成文件,更新/etc/path_to_inst文件。 

s 系统启动后停留在S运行级别。可以用来系统错误排除。 
v 详细地显示出系统的启动信息。有时可以用来系统的错误排除。
printenv 命令 
printenv命令显示NVRAM的参数以及参数的缺省值。 
查看缺省启动设备 
您可以使用printenv显示缺省启动设备。 
ok printenv 
Parameter Name Value Default Value 
tpe-link-test? True true 
output-device ttya screen 
input-device ttya keyboard 
sbus-probe-list f0123 f0123 
keyboard-click? False false 
diag-file 
diag-device net net 
boot-file 
boot-device disk disk 
auto-boot? true true 
More [,,q] ? q 
您可以在系统的输出中查看缺省启动设备,参数是boot-device。您也可以输入printenv boot-device,这样只显示启动设备的值。 
重新定义PROM Boot值 
使用setenv命令可以重新定义PROM的值 。下面的例子中把auto-boot? 变为 false,然后reset命令使系统重新启动,使变化生效。 
ok printenv auto-boot? 
auto-boot?true true 
ok 
ok setenv auto-boot? false 
auto-boot? = false 
ok reset 
重置缺省值 
使用set-defaults 命令将所有的参数重新设置为缺省的值。 
ok set-defaults 
______________________________________________________________________
注意 –set-defaults命令只对有缺省值的参数生效。 
______________________________________________________________________
影响系统启动和自检的按键有: 
stop 
如果在系统加电自检时按下Stop键,就取消POST(加电自检)诊断,然后停留在OK状态。
Stop+d 
在系统自检时同时按下stop和d键,系统将自动转到诊断模式,诊断模式下系统将更完全地进行自检。
Stop+n 
如果由于NVRAM的设置不正确而导致系统无法正确启动时,可以在系统加电自检时同时按下stop和n键。它的作用是将NVRAM的参数值设为默认值。
Stop+a 
     同时按下stop和a键将中断操作系统的运行,退到OK状态。 
警告:尽量不要在操作系统运行时按stop+a,这将导致操作系统停止并且导致数据的丢失。在万不得以的时候,在按下stop+a后,键入sync命令用以将内存的数据同步到硬盘中。
探测系统总线 
将外围设备(如光驱、硬盘)与主板连接在一起的I/O总线有SCSI(small computer system interface)总线和IDE (integrated drive electronics)总线。 

在OpenBoot 3.x系统中使用probe-命令 
在OpenBoot 3.x的系统中,使用probe-命令时,您会看到一个警告。如果您在操作系统运行状态下,用stop-a将系统强行暂停,或使用halt退出操作系统。这样的状态下使用probe-命令会造成机器挂起。因此,您必须先运行reset-all命令。
请先设置auto-boot?为false后再运行reset-all,系统将重新自检,停留在OK状态下,然后可以运行这个命令。
显示连接在SCSI总线上的设备 
probe-scsi命令将鉴别连接在SCSI控制器上的设备。 
ok probe-scsi 
Target 3 
Unit 0 Disk SEAGATE ST1480 SUN0424626600190016 
Copyright (c) 
All Rights Reserved 
Target 6 
Unit 0 Removable Read Only device SONY CD-ROM 
ok probe-scsi-all 
显示连接在PCI总线上的IDE设备 
ok probe-ide 
Device 0 ( Primary Master ) 
ATA Model : ST 34342A 
Device 1 ( Primary Slave ) 
Not Present 
Device 2 ( Secondary Master ) 
removable ATAPI Model : CDR-8240B 
Device 3 ( Secondary Slave ) 
Removable ATAPI Model yyyyyyyyyyyyyyy 
可以使用devalias命令查看设备别名的物理地址,这样就可以知道启动设备的物理设备了。
ok devalias 
screen /SUNW,ffb@1e,0 
mydisk /pci@1f,0/pci@1,1/ide@3/disk@0,0 
net /pci@1f,0/pci@1,1/network@1,1 
cdrom /pci@1f,0/pci@1,1/ide@3/cdrom@2,0:f 
disk /pci@1f,0/pci@1,1/ide@3/disk@0,0 
disk3 /pci@1f,0/pci@1,1/ide@3/disk@3,0 
disk2 /pci@1f,0/pci@1,1/ide@3/disk@2,0 
disk1 /pci@1f,0/pci@1,1/ide@3/disk@1,0 
disk0 /pci@1f,0/pci@1,1/ide@3/disk@0,0 
ide /pci@1f,0/pci@1,1/ide@3 
floppy /pci@1f,0/pci@1,1/ebus@1/fdthree 
ttyb /pci@1f,0/pci@1,1/ebus@1/se:a 
ttya /pci@1f,0/pci@1,1/ebus@1/se:b 
keyboard! /pci@1f,0/pci@1,1/ebus@1/su@14,3083f8 
keyboard /pci@1f,0/pci@1,1/ebus@1/su@14,3083f8 
mouse /pci@1f,0/pci@1,1/ebus@1/su@14,3062f8 
设备别名在左列。设备物理地址在右列。 
如果操作系统挂起了(没有响应),并且您也不能远程登录,那您没有别的选择了,只有强行中断操作系统。
中断挂起的系统 
如果系统挂起了,可以尝试下列步骤: 
1.用Stop-a中断操作系统。如果成功,系统会停留在PROM状态。如果是使用字符终端作为系统控制台,则按Break键。

2. 用sync命令将内存的内容同步到磁盘,减少数据的丢失。结束后系统会自动重起。
在ok提示符下键入sync命令。 
ok sync 
注意 – 您也可以用Stop-a强行中断操作系统,然后键入go恢复操作系统运行。不建议使用此功能。

 

Solaris系统管理培训(3)

Solaris系统管理培训(第三章:安装Solaris操作系统)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

Software Groupings 
基本 
 包含系统运行所需的最基本的软件和设备驱动。不包括图形界面和手册页。
最终用户 
  除了基本软件外,还包括图形界面。 
开发者 
  包括编译工具、图形界面、手册页。 
完整分发和 OEM 支持 
  包含全部内容和一些OEM地硬件设备驱动。 
Installation Information Worksheet 
Acquire the following necessary information prior to your installation: 
Host name:____________________________________________________
IP address:_____________________________________________________
Name service (NIS, NIS+, DNS or None):_________________________ 
Subnet (yes or no):______________________________________________ 
Geographic location:____________________________________________ 

Time zone information:__________________________________________ 
Root password:_________________________________________________
Installation Process 
1. Insert the CD-ROM into the CD-ROM drive. 
2. Boot the release media. 
ok boot cdrom 
3. Select the appropriate language and locale for your site and click on Continue. 
4. Enter the assigned host name for the system 
5. Type the IP address 
6 . Select the type of the name service 
7. Select Time Zone 
8. Select Initial to perform an initial install and not preserve current settings 
9 . Select the software group 
10 . Set the sizes of each disk partition 
11 . Type a root (superuser) password 

Solaris系统管理培训(4)

Solaris系统管理培训(第四章:软件包管理)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

 
所有Solaris系统的软件都以包的形式出现。 
软件包包含: 
  软件包的描述文件 
  系统需求的描述文件 
  需要安装的文件 
  安装前以及安装后需要运行的脚本 
The pkgadd command 
用于安装软件包 
pkgadd [ -d [device | pathname ]] pkg_name 
# pkgadd -d /cdrom/cdrom0/s0/Solaris_2.7/Product SUNWaudio
Processing package instance from 
 
Audio applications 
(sparc) 3.6.4,REV=1.98.08.13 
Copyright 1998 Sun Microsystems, Inc. All rights reserved.
Using as the package base directory. 
## Processing package information. 
## Processing system information. 
2 package pathnames are already properly installed. 
## Verifying package dependencies. 
## Verifying disk space requirements. 
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs. 
This package contains scripts which will be executed with super-user 
permission during the process of installing this package.
Do you want to continue with the installation of [y,n,?] y 
Installing Audio applications as 
## Installing part 1 of 1. 
Installation of was successful. 

The pkginfo command 
不加任何参数用于查看系统已经安装的软件包 
# pkginfo | more 
 
application SUNWAxg Solaris XGL 3.3 AnswerBook 
application SUNWaadm Solaris 7 System Administrator Collection 
system SUNWab2m Solaris Documentation Server Lookup 
system SUNWab2r Solaris Documentation Server 
system SUNWab2s Solaris Documentation Server 
system SUNWab2u Solaris Documentation Server 
application SUNWabda Sun Ultra 5/10 Hardware AnswerBook 
application SUNWabe Solaris 7 User Collection 
application SUNWabsdk Solaris 7 Software Developer Collection

The pkginfo Command 
后面可跟一些参数,显示特定某个软件包的信息 
Command Format 
  pkginfo [ -d [ device | pathname ] ] [ -l ] pkg_name 
参数 
-d device 指定软件所在的位置,可以是目录、磁带机、软盘等等
-l 显示详细信息 
pkg_name 软件包名 
输出列 
CATEGORY 软件包的类型,是“应用软件”和是“系统软件” 
PKGINST 软件包名,如果是SUNW打头,则是SUN的产品 
NAME 软件的简要描述 
# pkginfo -d /cdrom/cdrom0/s0/Solaris_2.7/Product -l SUNWaudio 
PKGINST: SUNWaudio 
NAME: Audio applications 
CATEGORY: system 
ARCH: sparc 
VERSION: 3.6.4,REV=1.98.08.13 
BASEDIR: / 
VENDOR: Sun Microsystems, Inc. 
DESC: Audio binaries 
PSTAMP: dtbuild37s19980813171753 
HOTLINE: Please contact your local service provider 
STATUS: spooled 
FILES: 9 spooled pathnames 
2 directories 
3 executables 
4 package information files 
700 blocks used (approx) 
The pkgrm Command 
Command Format 
  pkgrm package_name 
用于删除软件包 
# pkgrm SUNWaudio 
The following package is currently installed: 
SUNWaudio Audio applications 
(sparc) 3.6.4,REV=1.98.08.13 
Do you want to remove this package? y 
## Removing installed package instance 
## Verifying package dependencies. 
WARNING: 
The package depends on the package 
currently being removed. 
WARNING: 
The package depends on the package 
currently being removed. 
WARNING: 
The package depends on the package 
currently being removed. 
WARNING: 
The package depends on the package 
currently being removed. 
Dependency checking failed. 
Do you want to continue with the removal of this package [y,n,?,q] 
如果某个文件被多个包共享,则当最后一个包被删除时才被删除。
The pkgchk Command 
用于检查已安装的软件包 
Command Format 
  pkgchk [ -p path1 [ path2...] ] 
# pkgchk SUNWaudio 
# 
# pkgchk -p /etc/group 
ERROR: /etc/group 

file size <278> expected <282> actual 
file cksum <23586> expected <24038> actual 
pkgchk命令校验包的属性和内容是否与系统记录的一致。 
这个命令能检测整个包或是某个文件。没有输出表示包已经安装,但未发现不一致。
admintool图形管理工具 
admintool是solaris图形管理工具,包括管理软件包、主机名、主机地址、打印机、串口、用户、用户组等。

 

Solaris系统管理培训(第五章:补丁维护)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

什么是Patch? 
简单的说,补丁就是一些替换现存的文件和目录的文件目录集合。补丁纠正应用程序的错误或增加功能。
Patch编号 
每个补丁都有编号。例如补丁号为101945,版本是34的话,这个补丁的目录名就是101945-34.
patchadd命令用于安装补丁: 
# cd /tmp 
# ls 
105160-01 ps_data sdt_fl8zKOI_ 
# patchadd 105160-01 
Checking installed packages and patches... 
Verifying sufficient filesystem capacity (dry run method)
Installing patch packages... 
Patch number 105160-01 has been successfully installed. 
See /var/sadm/patch/105160-01/log for details 
Patch packages installed: 
SUNWdtbas 
patchrm用于删除补丁 
# patchrm 105633-06 
Checking installed packages and patches... 
Patch 105633-06 has been backed out. 

# 
下面的命令用于检查系统的补丁情况 
# patchadd -p 
Patch: 105160-05 Obsoletes: Requires: Incompatibles:Packages: SUNWdtbas 
# showrev -p 
Patch: 105160-05 Obsoletes: Requires:Incompatibles: Packages: SUNWdtbas 

 

Solaris系统管理培训(第六章:启动过程)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

启动有四个阶段 
 Boot PROM 阶段 
 Boot program 阶段 
 Kernel 初始化阶段 
 /sbin/init 阶段 
启动过程: 
自检、显示系统信息、读取启动设备的0扇区、在启动设备寻找启动程序、加载启动程序、启动内核、运行/sbin/init。
/sbin/init程序 
 读取/etc/inittab文件。Init程序执行/sbin/rc*脚本。 
系统有多种运行级别,不同的运行级别所启动的服务不同。 
系统运行级别有8种,分别为: 
运行级别 意义 
0 进入PROM状态(OK状态) 
1 管理状态(所有文件系统都挂上的单用户模式,禁止其他用户登录)
2 多用户模式(没有网络文件共享服务) 
3 多用户模式(有网络文件共享服务) 
4 未使用 
5 退出操作系统并关机 
6 重新启动机器 
S,s 单用户模式 
who命令查看运行级别 
# who -r 
  .    run-level 3  5月 10 17:03   3   0 S 
可得到的信息:当前运行级别是3,系统启动的时间是5月10日17:03.
/etc/inittabinittab定义了: 
系统缺省运行级别 
系统进入新运行级别需要做什么 
/etc/init.d目录包含了系统的一些启动脚本 
/etc/rc1.d目录包含进入运行级别1所需要运行的一些脚本 
/etc/rc2.d目录包含进入运行级别2所需要运行的一些脚本 
... 
... 
这些目录下包含两种文件: 
以K打头,后面跟两个数字以及一些字符串:表示系统到这个运行级别时所需要停止的一些服务,系统将以stop调用这个脚本。
以S打头,后面跟两个数字以及一些字符串:表示系统到这个运行级别时所需要开始的一些服务,系统将以start调用这个脚本。
增加启动控制脚本 
1.Identify the run level for the service 
2.Determine which services are needed by the new process 
3.Change to /etc/rc#.d and identify startup script 
4.Repeat the process for the directory containing the shutdown script 
5.Create the startup (shutdown) script in /etc/init.d 
6.Create hard links to appropriate /etc/rc#.d directories

7.test 

改变运行级别 
init命令用于改变操作系统的运行级别。 
命令格式: 
init [ 0123456Ss ] 
# init 0 
INIT: New run level: 0 
The system is coming down. Please wait. 
System services are now being stopped. 
Print services stopped. 
Stopping the syslog service. 
syslogd: going down on signal 15 
Aug 14 14:54:30 snmpdx: received signal 15 
The system is down. 
syncing file systems... done 
Program terminated 
Type help for more information 
ok 
shutdown 
用于改变操作系统运行级别。 
命令格式: 
shutdown [ -y ] [ -g seconds ] [ -i init-state ] [message]
选项: 
y 系统提示时默认回答为YES 
g 过多长时间改变 
i 想要的运行级别 
message 给所有登录用户的信息 
# shutdown -y -g 0 -i 0 
Shutdown started. Mon Dec 15 15:13:57 PST 1997 
Broadcast Message from root (console) on mcmurdo Mon Dec 
15 15:13:57... 
THE SYSTEM IS BEING SHUT DOWN NOW ! ! ! 
Log off now or risk your files being damaged 
Changing to init state 0 - please wait 
ok 
halt 
进入0运行级别 
poweroff 
关闭系统并切断电源 
reboot 
重新启动系统 

 

Solaris系统管理培训(第七章:系统安全)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

UIDs(用户ID) 
UIDs用于区别文件和目录的所有者。保存在 /etc/passwd。 
GIDs(用户组ID) 
GIDs用户区别用户、文件、目录的组成员。 
/etc/passwd文件记录了系统的用户帐号的信息 
格式 
loginID:x:UID:GID:comment:home directory:login shell 
#more /etc/passwd 
root:x:0:1:Super-User:/:/sbin/sh 
daemon:x:1:1::/: 
bin:x:2:2::/usr/bin: 
sys:x:3:3::/: 
adm:x:4:4:Admin:/var/adm: 
lp:x:71:8:Line Printer Admin:/usr/spool/lp: 
uucp:x:5:5:uucp Admin:/usr/lib/uucp: 
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico 
listen:x:37:4:Network Admin:/usr/net/nls: 
nobody:x:60001:60001:Nobody:/: 
noaccess:x:60002:60002:No Access User:/: 
nobody4:x:65534:65534:SunOS 4.x Nobody:/: 
jxbcpp:x:901:410:Dave Lister:/export/home/jxbcpp:/bin/sh 
loginID 用户名 
x 隐藏的口令。加密的口令放在/etc/shadow文件中 
UID 用户ID 
GID 组ID 
comment 描述 
home directory 个人主目录 
login shell 登录后使用的shell 
/etc/shadow文件记录了系统用户的加密后口令 
格式 
loginID:password:lastchg:min:max:warn:inactive:expire: 
#more /etc/shadow 
root:LXeokt/C/oXtw:6445:::::: 
daemon:NP:6445:::::: 
bin:NP:6445:::::: 
sys:NP:6445:::::: 
adm:NP:6445:::::: 
lp:NP:6445:::::: 
smtp:NP:6445:::::: 
uucp:NP:6445:::::: 
nuucp:NP:6445:::::: 
listen:*LK*::::::: 
nobody:NP:6445:::::: 
noaccess:NP:6445:::::: 
nobody4:NP:6445:::::: 
lister:ubQhZXEMv/lyI:10336:7:90:5:30:: 
loginID 对应用户名 
password 加密后的口令。LK表示锁定帐号,NP表示无口令 
lastchg 最后更改口令的日期与1970年1月1日之间相隔的天数 
min 改变口令需要最少的天数 
max 同一口令允许的最大天数 
warn 口令到期时,提前通知用户的天数 

inactive 用户不使用帐号多少天禁用帐号 
expire 用户帐号过期的天数 
最后一个字段未用 
/etc/group文件记录了系统的用户组的信息 
格式 
groupname:password:GID:userlist 
#more /etc/group 
root::0:root 
other::1: 
bin::2:root,bin,daemon 
sys::3:root,bin,sys,adm 
adm::4:root,adm,daemon 
uucp::5:root,uucp 
mail::6:root 
tty::7:root,tty,adm 
lp::8:root,lp,adm 
nuucp::9:root,nuucp 
staff::10: 
daemon::12:root,daemon 
sysadmin::14:lister,torey 
nobody::60001: 
noaccess::60002: 
Groupname 组名 
password 口令。已经不使用 
GID 组ID 
userlist 成员列表 

一个用户可以同时属于多个组。 
id命令用于查看用户的id号(用户号) 
命令格式 
id [ options ] [ username ] 
$ id 
uid=10450(student1) gid=150(learning) 
$ id -a 
uid=10450(student1) gid=150(learning) groups=150(learning),14(sysadmin) 
不加参数显示用户所在的id号用户和主要组id号。 
-a参数显示用户的所在所有组的组id号。 
改变用户 
su命令用户改变当前的用户。 
$ su - jxbcpp 
Password: 
su命令后可以加-,也可以不跟。如果跟-,则切换到那个用户后执行用户的启动脚本,如.profile。
改变文件所有者 
chown user_name filename 

# ls -l memo 
-rw-r--r-- 1 rimmer other 0 Jul 6 18:30 memo 
# chown chris memo 
# ls -l memo 
-rw-r--r-- 1 chris other 0 Jul 6 18:30 memo 
# cd /export/home 
# chown -R chris mydocs 
-R选项把mydocs目录下所有子目录及其文件的所有者都改变为chris。
# chown -R lister:staff mydocs 
把mydocs目录的所有者改为lister,所在组改为staff。 
注:只有管理员才能改变所有者。 

/etc/default/login文件 
其中包含了CONSOLE=这一行, 
如果CONSOLE=/dev/console未注释,则root只能在控制台登录。如果注释了此行,root可以远程登录。
查看登录状态 
命令who、finger、last可以查看用户登录状态。 
? who 
查看本机登录的用户状态。显示用户名、登录的设备、登录时间以及登录的主机名字。
$ who 
rimmer pts/1 Dec 21 07:07 (nepal) 

lister console Dec 21 12:18 (:0) 
用户rimmer从机器nepal上登录。而用户lister则在本地登录。 
? finger 
显示本地和远程系统用户的详细信息。包括用户名、用户注释信息、终端名、空闲时间、登录时间、登录主机名。
$ finger bevw 
Login name: bevw In real life: bev’s account 
Directory: /home/bevw Shell: /bin/ksh 
Last login Wed Oct 21 08:07 on console from :0 
No unread mail 
No Plan. 
? last 
显示系统的最近用户登录状况。 
$ last 
rimmer pts/4 pluto Fri Dec 18 10:24 - 11:00 (00:36) 
lister pts/4 pluto Tue Dec 8 09:39 - 09:49 (00:10) 
rimmer pts/4 pluto Thu Dec 3 15:16 - 15:17 (00:00) 
rimmer console :0 Wed Dec 2 08:47 still logged in 
reboot system boot Wed Dec 2 08:44 
rimmer pts/0 pluto Tue Dec 1 17:27 - 17:28 (00:00) 
rimmer pts/3 pluto Tue Dec 1 16:13 - 16:39 (00:26) 
rimmer pts/2 pluto Tue Dec 1 15:32 - 15:38 (00:06) 
holly term/a pluto Tue Dec 1 15:12 - 08:41 (17:29) 

 

Solaris系统管理培训(第八章:用户管理)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

可以用admintool图形工具增加、更改、删除用户和用户组。 
注意: 
用户所在的组必须先于用户之前创建。 
命令行方式: 

增加用户组 
groupadd命令增加用户组 
groupadd [-g gid] group 
说明: 
g 制定组的ID号 
gid 组的ID号(不能与现有的组ID号重复) 
group 组名 
#groupadd –g 100 sun 

useradd命令增加用户组 
useradd [-u uid | -g group] | -d dir | -s shell | -c comment | -m [-k skel_dir] ] login 
说明: 
u 指定用户ID号 
g 制定所在组 
d 指定用户目录 
s 制定用户SHELL 
c 用户的注释 
m 建立用户目录 
login 用户的登录名 
#useradd –u 1233 –g sun –d /export/home/sun –c “Sun test user.” –m –s /usr/bin/sh sun 

 

Solaris系统管理培训(第九章:初始化文件管理)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

用户的初始化文件是一些命令脚本和shell参数。 
下表列出不同的shell所运行的初始化文件: 
Shell System User  Template
(Read First) (Read Second/Third) /etc/skel
Bourne /etc/profile  $HOME/.profile  local.profile
Korn /etc/profile  $HOME/.profile  local.profile
C /etc/.login $HOME/.cshrc then $HOME/.login local.cshrc local.login 
如当一个具有Bourne Shell的用户登陆系统后,系统将首先自动运行/etc/profile这个初始化脚本,然后运行用户目录下的.profile初始化脚本。
当创建一个Bourne Shell的用户时,系统会自动把/etc/skel/local.profile这个文件拷贝到用户主目录下。因此/etc/skel下包含的是一些用户初始化脚本的模板。
如何手工运行初始化脚本文件: 
Bourne and Korn Shells 
$ cd 
$ . ./.profile 
$ . ./.kshrc 

C Shell 
% source ~/.login 
% source ~/.cshrc 

 

Solaris系统管理培训(第十章:进程控制)

提供者:jzj 发表日期:2002-01-24

--------------------------------------------------------------------------------

使用ps命令显示系统正在运行的进程。 
参数: 
e 列出系统所有的进程 
f 列出详细清单 
UID:运行进程的用户 
PID:进程的ID 
PPID:父进程的ID 
C:进程的CPU使用情况(进程使用占CPU时间的百分比) 
STIME:开始时间 
TTY:运行此进程的终端或控制台 
TIME:消耗CPU的时间总量 
CMD:产生进程的命令名称 
要查找某进程: 
#ps -ef|grep process_name 

使用Kill命令给进程发送一个信号。Kill命令一般用于结束系统的某个进程。
Solaris有44个信号。每个信号有个数字和名称。如果你未制定信号,则默认为信号15,这个信号用于结束进程。
用户只能结束自己启动的进程。超级用户可以结束任何一个进程。
#find / -name test 
#ps -aef|grep find 
  root 3602 3575 0 20:13:01 pts/0  0:00 grep find 

  root 3601 3575 2 20:12:56 pts/0  0:00 find / -name test 
#kill 3601 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值