The Linux-to-SmartOS Cheat Sheet¶

The things that make SmartOS different from other Unix-like systems generally fall in two categories:

Similar commands with different names in SmartOS.

Different procedures for accomplishing similar things in SmartOS.

The following is a list of commands to help Linux users find equivalent commands in SmartOS and SmartMachines. Note that some of these are not available within SmartMachines due to permission restrictions, and some commands, when run in a SmartMachine, return a subset of the output on the global zone in SmartOS. Also note that many commands available on Linux are also available on SmartMachines. For instance, you can use pkgin install top to install top(1) .

This list is derived from http://bhami.com/rosetta.html

We apologize for this table¶

This table was a mess in the old Confluence wiki, and the automated conversion did not go well. We'd love help with:

Cleaning this up

Updating the CSS to accomodate the width of the table

Revamping and modernizing this content

Linux and SmartOS Commands¶

TASK / OS Linux SmartOS SmartOS Virtual Instance (zone) *table key* * (rh) = Red Hat, Mandrake, SUSE,... * (deb) = Debian, Libranet,... * (fed) = Fedora * (gen) = Gentoo * (md) = Mandrake/Mandriva * (SUSE) = SUSE Joyent SmartOS You can find an open source version at Joyent SmartOS zone managing users useradd usermod userdel adduser chage getent useradd userdel usermod getent logins groupadd useradd userdel usermod getent logins 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/* arch prtconf [-v] prtpicl [-v] uname psrinfo [-v] isainfo [-v] dmesg iostat -En cfgadm -l /etc/path_to_inst arch uname psrinfo [-v] isainfo [-v] dmesg iostat -En read a disk label fdisk -l fdisk prtvtoc label a disk cfdisk fdisk e2label format prtvtoc fdisk partition a disk parted *(if you have it)* cfdisk fdisk pdisk *(on a Mac)* *(deb)* *mac-fdisk* (on a Mac)_ *(md)* _diskdrake format fmthard rmformat kernel /boot/vmlinuz* /boot/bootlx (see /etc/lilo.conf or /boot/grub/menu.lst) /kernel/genunix /platform/`uname -m`/ kernel/unix kernel modules are in /kernel, /usr/kernel, and /platform/`uname -m`/kernel Kernel module files not visible within a zone show/set kernel parameters /proc/* /proc/sys/* sysctl /etc/sysctl.conf sysdef getconf cat /etc/system ndd mdb -k[w] sysdef getconf ndd loaded kernel modules lsmod modinfo modinfo load module modprobe insmod modload add_drv devfsadm unload module rmmod modprobe -r modunload startup scripts /etc/rc* (but may vary) /etc/init.d/ SMF(5) /etc/rc* /etc/init.d/ svcadm svcs SMF(5) /etc/rc* /etc/init.d svcadm svcs start/ stop/ config services *(rh)* _service *(rh)* _chkconfig *(deb)* _sysv-rc-conf svcs svcadm svccfg svcs svcadm svccfg shutdown (& power off if possible) shutdown -Ph now shutdown -y -g0 -i0 halt poweroff shutdown -y -g0 -i5 halt shutdown -y -g0 -i5 halt run levels *=normal states *for more detail* *see* [www.phildev.net/runlevels.html](http://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 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/runlevel who -r who -r time zone info /usr/share/zoneinfo/ /etc/localtime /usr/share/lib/zoneinfo/ /usr/share/lib/zoneinfo check swap space swapon -s cat /proc/meminfo cat /proc/swaps free swap -s[h] swap -l[h] *Note: in a zone, swap is virtual* *memory size* swap -s[h] swap -l[h] bind process to CPU taskset (sched-utils) pbind psrset pbind psrset killing processes kill killall kill pkill killall *<- tries to kill everything, DO NOT USE THIS* kill pkill killall *<- tries to kill everything, DO NOT USE THIS* show CPU info cat /proc/cpuinfo lscpu psrinfo -pv psrinfo -pv memory freemem prtconf | head zonememstat prtconf | head zonememstat "normal" filesystem ext2 ext3 ReiserFS zfs zfs file system description /etc/fstab /etc/vfstab /etc/vfstab create filesystem mke2fs mkreiserfs mkdosfs mkfs zfs zpool zfs (if zone has delegated dataset) file system debugging and recovery fsck debugfs e2undel zdb create non-0-length empty file dd if=/dev/zero of=*filename* bs=1024k count=*desired* mkfile mkfile 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 management getfacl setfacl getfacl setfacl getfacl setfacl NFS share definitions /etc/exports /etc/dfs/dfstab dfshares NFS share command /etc/init.d/nfs-server reload_(rh)__ _exportfs -a share shareall NFS information cat /proc/mounts showmount nfsstat nfsstat name resolution order /etc/nsswitch.conf /etc/resolv.conf /etc/nsswitch.conf getent /etc/nsswitch.conf getent show network interface info ifconfig ethtool dladm ndd ifconfig -a netstat -in dladm ndd ifconfig -a netstat -in change IP *Joyent Public Cloud IP addresses are set in the* *[Cloud Management Portal](http://my.joyentcloud.com).* ifconfig ping one packet ping -c 1 *hostname* ping *hostname* * packetsize 1* ping *hostname packetsize* 1 sniff network etherfind tcpdump wireshark (*formerly* _ethereal) etherape snoop snoop tcpdump available from pkgin route definitions *route* *(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 /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)* Use nc instead Use nc instead set date/time (from net: ntp or other) ntpdate rdate netdate ntpdate rdate ntpdate rdate auditing auditd /var/log/faillog audit auditd auditreduce praudit audit auditd auditreduce praudit encrypted passwords in /etc/shadow *(may vary)* /etc/shadow /etc/shadow min password length /etc/pam.d/system-auth /etc/default/passwd /etc/default/passwd allow/deny root logins /etc/securetty /etc/default/login /etc/default/login firewall config iptables ipchains ipfwadm *(rh)* redhat-config- securitylevel /etc/ipf/ipf.conf /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 pkgin avail *<- list available installable software* add software *(rh)* _rpm -hiv *(rh)* yum install *pkg* *(deb)* dselect *(deb) _apt-get install _pkg* *(deb)* dpkg -i pkgin install precompiled binaries* of GPLware and freeware* [www.linux.org](http://www.linux.org/) [linux.tucows.com](http://linux.tucows.com/) [sourceforge.net](http://sourceforge.net/) [rpmfind.net](http://rpmfind.net/) (deb) [ftp.debian.org](http://ftp.debian.org/) (deb) [packages.debian.org](http://packages.debian.org/) *(gen)* [packages.gentoo.org](http://packages.gentoo.org/) *(gen)* [gentoo-portage.com](http://gentoo-portage.com/); *(md)* [easyurpmi.zarb.org](http://easyurpmi.zarb.org/) [www.sunfreeware.com](http://www.sunfreeware.com/) [www.blastwave.org](http://www.blastwave.org/) pkgin C compiler cc gcc gcc [https://download.joyent.com/pub/build/SunStudio.tar.bz2] gcc (may need to be installed via pkgin) [https://download.joyent.com/pub/build/SunStudio.tar.bz2](https://downlo ad.joyent.com/pub/build/SunStudio.tar.bz2 ) configure/show runtime linking ldconfig ldd readelf lsmod crle ldd elfdump dump pldd modinfo LD_PRELOAD crle ldd elfdump dump readelf pldd modinfo LD_PRELOAD link library path $LD_LIBRARY_PATH /etc/ld.so.conf $LD_LIBRARY_PATH $LD_LIBRARY_PATH tracing utility strace ltrace dtrace truss sotruss dtrace truss sotruss define user defaults /etc/profile /etc/security/ /etc/skel/ /etc/profile.d/* /etc/default/login /etc/profile /etc/security/ /etc/default/login /etc/profile /etc/security/ csh global .login /etc/csh.login /etc/.login /etc/.login 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](http://softpanorama.org/Logs /solaris_logs.shtml) /var/adm/messages /var/log/syslog system error reporting tool dmesg_(deb)_ reportbug fmadm fmdump prtdiag fmadm fmdump performance monitoring vmstat procinfo -D top htop pstree dtrace prstat sar ostat kstat mpstat netstat nfsstat vmstat lockstat plockstat ptree vfsstat intrstat dtrace prstat sar ostat kstat mpstat netstat nfsstat vmstat plockstat ptree vfsstat match process to file or port lsof netstat -atup fuser pfiles pfiles fuser lsof zones/containers zoneadm zonecfg zlogin zoneadm zonename Virtualization kvm/qemu kvm/qemu (each instance in a kvm branded zone) vmadm imgadm [Wikipedia](http://en.wikipedia.org/wiki/Category:Unix_variants) [Linux](http://en.wikipedia.org/wiki/Linux) [SmartOS](http://en.wikipedia.org/wiki/SmartOS) [Illumos](http://en.wikipedia.org/wiki/Illumos) [SmartOS](http://en.wikipedia.org/wiki/SmartOS) [Illumos](http://en.wikipedia.org/wiki/Illumos)

Examples of Different Use Context¶

For example, here are some common Linux commands that work differently.

Command What's different on a Smart Machine df On most SmartOS image this is set up to use the GNU version. Use /usr/bin/df for the native version. lsof SmartMachines use a different collection of tools to examine processes. See Examining processes and memory later in this topic. ping Returns whether a host responds or not. Use ping -s to get a continuous response. top top is available in /opt/local/bin , but prstat -Z provides more zone aware (and more accurate) information than top .

The Rosetta Stone for Unix is a useful resource to help you see how commands from the version of UNIX you usually work with map to other versions of UNIX.

Examining processes and memory¶

SmartOS provides a suite of tools to examine processes. You can learn more about them by looking at the proc man page.

Tool Description prstat This tool displays the active processes like top does on Linux systems. prstat -Z will provide you with a summary of your instance's status. pgrep Returns a list of process IDs (PIDs) of processes that match a pattern or meet certain conditions. pkill Kills the processes that match a pattern or meet certain conditions. pfiles Returns a list of all the open files that belong to a process. pstack Displays a stack trace of the specified process ptree Displays a process tree for all processes or a given process ls /proc Lists the process IDs of all running processes.

You can combine the results of pgrep with the other proc tools. To list all the files associated with http processes, use this command instead of lsof :

sudo pfiles $(pgrep http)

To limit the prstat display to http processes, use this command:

prstat $(pgrep -d , http)

The vmstat , mpstat , and psrinfo commands display processor and memory statistics for the physical machine. Their output is not generally useful to you as a SmartMachine operator.

Starting and stopping services¶

On other systems, you may be used to starting and stopping servers by using commands in /etc/init.d . SmartMachines use the Service Management Facility (SMF) to do this. The svcs and svcadm commands are the ones you will use most often. Some commands take a service identifier called an FMRI. You can use the svcs command to list all of the identifiers for a service.

Command Description svcs Lists all the enabled services svcs -a Lists all of the services, even those that are disabled or off line svcadm enable apache Enable all of the processes with an apache FMRI svcadm disable apache Disable all of the processes with an apache FMRI svcadm restart apache Restart all of the processes with an apache FMRI

For example, if you make changes to /etc/ssh/sshd_config , restart SSH like this:

sudo svcadm restart ssh

For more information on SMF, see this topic.