The Joyent Linux-to-SmartOS Cheat Sheet

Modified: 02 Sep 2015 22:49 UTC

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

The following is a list of commands to help Linux users find equivalent commands in SmartOS.

Also see The Linux to SmartOS Cheat Sheet on the SmartOS wiki. This page includes information about SmartOS instances (zones).

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

Linux and SmartOS commands

Task Linux SmartOS
table keys (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 http://smartos.org
managing users useradd, usermod, userdel , adduser , chage, getent useradd, userdel, usermod, gtent, logins, /usr/sadm/bin/smuser, groupadd
list hardware configuration arch, uname, dimes (if you’re lucky), cat/var/log, 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 label fdisk -l prtvtoc
label a disk cfdisk, disk, 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/sysct.conf sysdef, getconf, cat /etc/system , ndd, abd -k
loaded kernel modules lsmod modinfo
load module modprode, insmod modload
unload module rmmod, mod probe -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* for more detail see* 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/runlevel who -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
blind process to CPU taskset (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 file dd if=/dev/zero of=filename, bs=1-24k count=desired mkfile
create/mount ISO image mkisofs, mount -o loop pathTolso, mountPoint mkisofs;DEVICE=lofiadm -a /*absolute_pathname/image.iso; mount -F hsfs -p ro, $DEVICE
ACL management getfacl, setfacl getfacl, setfacl
*NFS share definitions /etc/exports /etc/dfs/dfstab, dfshares
FNS share command /etc/init.d/nfs-server reload_(rh__ _exportfs -a share, shareall
NFS information cat /proc/mounts showmount, 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
change IP Joyent Public Cloud IP addresses are set in the Cloud Management Portal. Joyent Public Cloud IP addresses are set in the Cloud Management Portal.
ping one packet ping -c 1 hostname ping hostname packetsize 1
sniff network UUID Package Name
Image Name etherfind, tcpdump, wireshark (formerly_ethereal), etherape snoop
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
telnetd,ftp banner /etc/issue.net (telnet) , (ftp varies; can use tcp wrappers) /etc/default/telnetd, /etc/default/ftpd
set date/time (from net: nt. or other) ntp date, rdate, netdate ntpdate, rdate
auditing auditd, /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
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 -l pkgin list
add software (rh) _rpm -hiv, (rh) yum install pkg , (deb) deselect, (deb) _apt-get install _pkg, (deb) dpkg -i pkgin install
precompiled binaries* of 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 compiler cc, gcc /opt/local/bin/cc (gcc installed via pkgin)
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 dtrace, truss, sotruss
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
default syslog and messages /var/log/syslog, /var/log/messages, /usr/adm/messages, /usr/adm/messages, /var/log/maillog /var/adm/messages, /var/log/syslog
softpanorama.org/Logs/solaris_logs.shtml
system error reporting tool dmesg_(deb)_reportbug prtdiag
performance monitoring vmstat, procinfo -D, top, htop, pstree prstat, ostat, kstat, mpstat, netstat, nfsstat, trapstat, vmstat, ptree
match process to file or port lsof, netstat -atup fuser, pfiles
Wikipedia Linux 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 SmarOS image this is set up to use the GNU version. Use /usr/bin/df for the native version.
lost 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

In older SmartOS images, these commands provide information about ports and resources. Run these commands as root or with sudo.

Later images use the [SmartMachine Tools Package](SmartMachine Tools Package.html).

Command Description Example
pcp Displays the ports used by a process or the processes that use a port. /root/bin/pcp -p 80 displays all the processes that use port 80.

/root/bin/pcp -P 28068 displays all the ports that process 28068 uses. /root/bin/pcp -adisplays port and process information for all ports. | |jinf| Displays information about how your SmartMachine is using its resources. |/root/bin/jinf -cdisplays CPU usage information. /root/bin/jinf -mdisplays memory usage information. /root/bin/jinf -s` displays swap usage information. |

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 in Linux systems. prstat -Z will provide you with a summary of your SmartMachine’s status.
pgrep Returns a list of process IDs (PIDs) 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 long to a process.
pstack Displays a stack trace of the specified process.
tree 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)
warning
If the prstat display changes your terminal settings, use the reset command to return them to normal.

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](Using the Service Management Facility.html) 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 Enables all of the processes with an apache FMRI.
svcadm disable apache Disables 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