SmartOS 与 Linux 有何不同?

 

既然说SmartOS和Linux类似,那在使用时到底有什么不同呢?SmartMachine和其他类Unix系统不同之处主要在于两类:

  • 命令类似,但在SmartOS中用不同的名字
  • 完成类似的任务,但在SmartOS中有不同的实现过程

这里列出一个命令列表,用来帮助Linux用户找到在SmartOS中与Linux对等的命令。

Linux and SmartOS 命令对比列表

任务 / 操作系统LinuxSmartOS
表中某些键值的含义
(rh) = Red Hat, Mandrake, SUSE,... 
(deb) = Debian, Libranet,... 
(fed) = Fedora  
(gen) = Gentoo  
(md) = Mandrake/Mandriva 
(SUSE) = SUSE
Joyent SmartOS 

开源版本可参见链接 http://smartos.org
管理用户
managing users
useradd 
usermod 
userdel 
adduser 
chage  
getent
useradd 
userdel 
usermod 
getent 
logins 
/usr/sadm/bin/smuser 
groupadd
列举硬件配置信息
list hardware configuration
arch 
uname 
dmesg (if you're lucky) 
cat /var/log/dmesg 
/proc/* 
lshw 
dmidecode 
lspci 
lspnp 
lsscsi 
lsusb 
lsmod 
(SUSE) hwinfo 
/sys/devices/*
prtconf -v 
arch -k 
psrinfo -v 
isainfo -v 
dmesg 
iostat -En 
prtfru 
cfgadm -l 
/etc/path_to_inst
read a disk labelfdisk -lprtvtoc
label a diskcfdisk 
fdisk 
e2label
format 
prtvtoc
磁盘分区
partition a disk
parted (if you have it) 
cfdisk 
fdisk 
pdisk (on a Mac) 
(deb) mac-fdisk (on a Mac)_ 
(md) _diskdrake
format 
fmthard
kernel/boot/vmlinuz* 
/boot/bootlx 
(see /etc/lilo.conf or /boot/grub/menu.lst)
/kernel/genunix 
/platform/`uname -m`/ 
 kernel/unix 

show/set kernel parameters/proc/* 
/proc/sys/* 
sysctl 
/etc/sysctl.conf
sysdef 
getconf  
cat /etc/system 
ndd 
adb -k
loaded kernel moduleslsmodmodinfo
load modulemodprobe 
insmod
modload
unload modulermmod 
modprobe -r
modunload
启动脚本
startup scripts
/etc/rc* (but may vary) 
/etc/init.d/
/etc/rc* 
/etc/init.d/ 
 svcadm 
svcs
启动/停止/配置 服务
start/ stop/ config services
(rh) _service 
(rh) _chkconfig 
(deb) _sysv-rc-conf
svcs 
svcadm 
终止或关机
shutdown (& power off if possible)
shutdown -Ph now  
shutdown -y -g0 -i0 
halt 
poweroff
shutdown -y -g0 -i5
run levels 
*=normal states  
更多细节可参见 
www.phildev.net/runlevels.html
(set in /etc/inittab) 
0: halt 
s,S,1: vendor-dependent 
1: single-user 
2-5*: multiuser 
6: reboot
0: firmware monitor 
s,S: single-user 
1: sys admin 
2: multiuser 
3*: share NFS 
4*: user-defined 
5: power-down if possible 
6: reboot
show runlevel /sbin/runlevelwho -r
时区信息
time zone info
/usr/share/zoneinfo/ 
/etc/localtime
/usr/share/lib/zoneinfo/
检查交换空间
check swap space
swapon -s 
cat /proc/meminfo 
cat /proc/swaps 
free
swap -s 
swap -l
bind process to CPUtaskset (sched-utils)pbind
“正常”的文件系统
"normal" filesystem
ext2 
ext3 
ReiserFS
zfs (OpenSolaris)
文件系统描述
file system description
/etc/fstab/etc/vfstab 
创建文件系统
create filesystem
mke2fs 
mkreiserfs 
mkdosfs 
mkfs
zfs 
文件系统调试和恢复
file system debugging and recovery
fsck 
debugfs 
e2undel
fsck 
fsdb 
clri
create non-0-length empty filedd if=/dev/zero of=filename 
bs=1024k count=desired
mkfile
创建/挂载 ISO 镜像
create/mount ISO image
mkisofs 
mount -o loop pathToIso 
mountPoint
mkisofs;DEVICE=`lofiadm -a /absolute_pathname/image.iso` ; mount -F hsfs -o ro 
$DEVICE
ACL managementgetfacl 
setfacl
getfacl 
setfacl
NFS share definitions/etc/exports/etc/dfs/dfstab 
dfshares
NFS share command/etc/init.d/nfs-server reload_(rh)__ _exportfs -ashare 
shareall
NFS informationcat /proc/mountsshowmount 
nfsstat
name resolution order/etc/nsswitch.conf 
/etc/resolv.conf
/etc/nsswitch.conf 
getent
显示网络接口信息
show network interface info
ifconfig 
ethtool
dladm 
ndd 
ifconfig -a 
netstat -in 
dladm 
修改IP
change IP
Joyent 公共云IP地址在云管理平台中设置Joyent 公共云IP地址在云管理平台中设置
ping one packetping -c 1 hostnameping hostname  packetsize 1
监听网络
sniff network
etherfind 
tcpdump 
wireshark (formerly _ethereal) 
etherape
snoop
route definitionsroute 
(rh) /etc/sysconfig/network 
(rh) /etc/sysconfig/static-routes 
(deb) /etc/init.d/network 
(deb) /etc/network
/etc/defaultrouter 
/etc/notrouter 
/etc/gateways 
in.routed 
netstat -r 
route add
telnetd, ftpd banner/etc/issue.net (telnet) 
(ftp varies; can use tcp wrappers)
/etc/default/telnetd 
/etc/default/ftpd
设置日期/时间
set date/time
 
(from net: ntp or other)
ntpdate 
rdate 
netdate
ntpdate 
rdate
auditingauditd 
/var/log/faillog
audit 
auditd 
auditreduce 
praudit
加密后的密码在
encrypted passwords in
/etc/shadow (may vary)/etc/shadow
最小密码长度
min password length
/etc/pam.d/system-auth/etc/default/passwd
允许/禁止 root 登录
allow/deny root logins
/etc/securetty /etc/default/login
防火墙配置
firewall config
iptables 
ipchains 
ipfwadm 
(rh) redhat-config- 
securitylevel
/etc/ipf/ipf.conf
显示已安装的软件
show installed software
(rh) _rpm -a -i 
(rh) _rpm -qa  
(rh) yum list installed 
(deb) dselect 
(deb) aptitude 
(deb) dpkg -l 
(gen) _ls /var/db/pkg/* 
(gen) _eix -I
pkgin list
安装/添加软件
add software
(rh) _rpm -hiv  
(rh) yum install pkg 
(deb) dselect 
(deb) _apt-get install _pkg 
(deb) dpkg -i 
pkgin install 
预编译的二进制版本
(GPLware and freeware)
www.linux.org
linux.tucows.com
sourceforge.net
rpmfind.net
(deb) ftp.debian.org
(deb) packages.debian.org
(gen) packages.gentoo.org
(gen) gentoo-portage.com
(md) easyurpmi.zarb.org
pkgsrc.joyent.com/sdc6/ 
www.sunfreeware.com
www.blastwave.org
C 编译器
C compiler
cc 
gcc
/opt/SUNWspro/ 
bin/cc
configure/show  runtime linking 

ldconfig 
ldd 
lsmod
crle 
ldd 
pldd 
modinfo 
LD_PRELOAD
链接库路径
link library path
$LD_LIBRARY_PATH 
/etc/ld.so.conf
$LD_LIBRARY_PATH 
跟踪工具
tracing utility
strace 
ltrace
truss 
sotruss 
dtrace
定义用户默认配置
define user defaults
/etc/profile 
/etc/security/ 
/etc/skel/ 
/etc/profile.d/*
/etc/default/login 
/etc/profile 
/etc/security/
csh global .login/etc/csh.login/etc/.login
默认的 syslog 和 信息
default syslog and messages
/var/log/syslog 
/var/log/messages 
/usr/adm/messages  
/var/log/maillog
/var/adm/messages 
/var/log/syslog 
softpanorama.org/Logs/solaris_logs.shtml
system error reporting tooldmesg_(deb)_ reportbugprtdiag
性能监测
performance monitoring
vmstat 
procinfo -D 
top 
htop 
pstree
prstat 
ostat 
kstat 
mpstat 
netstat 
nfsstat 
trapstat 
vmstat 
ptree 


match process to file or portlsof 
netstat -atup
fuser 
pfiles 
维基百科
Wikipedia
LinuxIllumos

 

不同使用语境(Use Context)的例子

比如,一些常见的Linxu命令的工作过程有些不同。, here are some common Linux commands that work differently.

命令在SmartMachine上有何不同
df在大多数SmartOS镜像,它是使用的 GNU 版本。可以用 /usr/bin/df 来运行 native 版本
lsofSmartMachine 使用不同的命令集来检查进程,下面会谈及。
ping返回host主机是否有响应,使用 ping -s 返回持续的响应
toptop 在 /opt/local/bin 里面,但 prstat -Z 提供比 top 有关资源池更多且更准确的信息

 Rosetta Stone for Unix 是一个有用的资源,可以帮你看看你经常使用的UNIX版本和其他的UNIX版本(包括Mac)有何不同,并如何对应。

检查进程和内存


在旧的SmartOS镜像中,这些命令提供了端口和相关资源的信息,使用root或sudo可运行它们。
新的镜像使用的是 SmartMachine 工具包(Tools Package)

命令描述例子
pcp显示被进程使用的端口们,或者进程们使用哪个端口/root/bin/pcp -p 80 显示所有使用80端口的进程  
/root/bin/pcp -P 28068 显示进程28068使用的所有端口  
/root/bin/pcp -a 显示所有端口的端口及进程信息
jinf显示你的SmartMachine正如何使用它的资源/root/bin/jinf -c 显示CPU的使用信息  
/root/bin/jinf -m 显示内存使用信息  
/root/bin/jinf -s 显示交换空间使用信息

以下是SmartMachine 工具包(Tools Package)

 

ToolDescription
sm-cpuinfoCollect information from the system on CPU usage.
sm-create-dbSetup and create a MySQL or PostgreSQL database.
sm-create-dbuserSetup and create a MySQL or PostgreSQL database user.
sm-create-vhostSetup and install a virtual server.
sm-install-drupalSetup and install a Drupal Content Management System (CMS).
sm-install-wordpressSetup and install a WordPress blog.
sm-list-dbsGenerate a list of installed databases from MySQL or PostgreSQL.
sm-list-dbusersGenerate a list of database users from MySQL or PostgreSQL.
sm-list-timezonesGenerate a list of supported timezones.
sm-lsofShow the mapping between processes and ports.
sm-meminfoCollect information from the system on memory usage.
sm-pcpDetermine the mapping for processes and ports.
sm-prepare-imagePrepare a SmartMachine to serve as the basis for a SmartMachine image.
sm-rebootReboot the SmartMachine.
sm-rebuild-pkgsrcUpgrade the pkgsrc repository to the 2012Q1 release.
sm-remove-dbRemove a MySQL or PostgreSQL database.
sm-remove-dbuserRemove a MySQL or PostgreSQL database user.
sm-set-hostnameSet the hostname for a SmartMachine.
sm-set-timezoneSet the timezone for a SmartMachine.
sm-shutdownShutdown the SmartMachine.
sm-summaryCollect information from the system on various properties of the SmartMachine.
sm-tune-mysqlAutomatically tune a MySQL database.

 

 

SmartOS 提供了一个工具套件来检查进程,可以在 proc 的 man page 中学习到更多内容。

工具描述
prstat这个工具显示活动的进程列表,类似Linux中的 top 命令  
prstat -Z 将为提供你的SmartMachine状态的摘要信息
pgrep根据指定的条件或模式返回进程的进程ID(PID)列表,一般是用来判断程序是否正在运行。
pkill根据指定的条件或模式中止进程
pfiles返回属于某个进程的所有打开文件列表
pstack显示指定进程所有的线程的调用栈
ptree显示所有进程或指定进程的进程树
ls /proc列举所有正在运行的进程ID

你可以将 pgrep 的结果和其他 proc 工具合并显示。比如,显示与 http 进程相关的所有文件,可以使用如下命令来替代 lsof:

$ sudo pfiles $(pgrep http)

若要限制 prstat 显示 http 进程,可以使用命令:

 

$ prstat $(pgrep -d , http)
注意:如果 prstat 显示改变了你的终端设置,可以使用 reset 命令返回到正常状态

 

对于 vmstat, mpstat 和 psrinfo 命令,主要显示物理机中处理器和内存的统计信息。这些输出一般来说对于SmartMachine的管理员才有用。

 

启动和停止服务

在其他系统中,你也许习惯使用命令在 /etc/init.d 来启动或停止服务。
SmartMachines 使用 Service Management Facility 来做到这些。

命令 svcs 和 svcadm 是你经常会使用到的。有些命令把 service identifier 叫做FMRI(Fault Management Resource Identifier)。
你可以使用 svcs 命令列举一个服务所有的 identifier 。

命令描述
svcs列举所有已启用的服务
svcs -a列举所有服务,即使有些已经被禁止或offline
svcadm enable apache使用apache FMRI 启用Apache进程
svcadm disable apache使用apache FMRI 禁止Apache进程
svcadm restart apache使用apache FMRI 重启Apache进程

比如,如果你想更改 /etc/ssh/sshd_config 后重启SSH,可以这样做:

 

$ sudo svcadm restart ssh
  • No labels