Sun Solaris Cheat Sheet
Sun Solaris Cheat Sheet
Sun Solaris Cheat Sheet
Packages
Install the gcc package pkgadd -d gcc-3.4.6-sol10-sparc-local Check to see if gcc is installed on system pkginfo SMCgcc /or/ pkginfo | grep gcc Remove the gcc package pkgrm SMCgcc Check the installation of the gcc (SMCgcc) package pkgchk SMCgcc Show revisions of packages on system showrev -p Get expected _le info and source package for a _le pkgchk -l -p /usr/sfw/bin/gcc Verify all packages (and _les) on the system pkgchk Display information about a package pkgchk -l SMCgcc Display version information about an installed package pkginfo -x SMCgcc List all patches on the system showrev -p /or/ patchadd -p List patches applied to the SUNWckr package pkgparam SUNWckr PATCHLIST _ smpatch and updatemanager can be used to manage system patches.
Devices
Scan for new devices to the system devfsadm List (verbosely) all attachment points (con_gurable hardware) cfgadm -val List all disks on system iostat -En Tape unit { X = device number, n = no rewind /dev/rmt/X n _ The /dev directory contains links to /devices _ (format) slice ags are: wm { Writeable Mountable (ie: A _lesystem) rm { ReadOnly Mountable wu { Writeable Unmountable (ie: swap)
User Management
Add a user wfavorit to system (& create home dir) using default options useradd -m wfavorit View the default settings for the useradd command useradd -D Change the default useradd setting for base directory useradd -D -b /export/home Delete the password for user wfavorit, force new password on login passwd -df wfavorit List all user accounts that do not have passwords logins -p List _le system usage of the /zones _lesystem by user quot /zones Display login information for wfavorit logins -x -l wfavorit Change the default shell to ksh for user wfavorit usermod -s /usr/bin/ksh wfavorit Modify user accounts with usermod and delete accounts with userdel. Create group accounts with groupadd, modify group accounts with groupmod, and delete groups with groupdel
Files
/etc/vfstab { Filesystem mount table /var/adm/loginlog { Log of login attempts /etc/default/* { Important default settings /etc/system { Kernel modules and con_g /var/adm/messages { Syslog location /etc/auto * { Automounter con_g _les /etc/inet/ipnodes { IPv4 & v6 host _le (read before /etc/hosts)
ZFS
De_ne a (simple) zpool called projects on a single stripe zpool create projects c0t1d0s7 De_ne a mirror zpool called datapool on stripe 7 of two disks zpool create datapool mirror c0t0d0s7 c0t1d0s7 List the zpools and usage stats zpool list Remove the zpool called datapool zpool destroy -f datapool Create the zfs heirarchy / _lesystems zfs create datapool/home List all zfs _lesystems zfs list Limit the wfavorite _lesystem to 5 Gig zfs set quota=5G datapool/home/wfavorite
OneDollarData
Tasks
_ Force the system to look for new devices on restart touch /reconfigure _ Mirror root _lesystems (c0t0d0 to c0t1d0) /, swap, /usr, and /var are on s0, s1, s3, and s4 respectively. s5 and s6 will be used for 10 meg metadb's on each disk. The steps are shown here with multiple reboots. This is to show the di_erence between each type of operation. Multiple reboots are not required. . Duplicate c0t0d0's layout onto c0t1d0 prtvtoc /dev/rdsk/c0t0d0s2 | n fmthard -s - /dev/rdsk/c0t1d0s2 . Set up two meta databases on each disk metadb -a -f c0t1d0s5 metadb -a c0t1d0s6 metadb -a c0t0d0s5 metadb -a c0t0d0s6 Note: Multiple dbs can be put in a single slice using -c option. . Encapsulate / on stripe 0 metainit -f d10 1 1 c0t0d0s0 metainit d0 -m d10 metaroot d0 lockfs -fa shutdown -i6 -g0 -y metainit d20 1 1 c0t1d0s0 metattach d0 d20 . Encapsulate /usr on stripe 3 (repeat this step for /var) metainit -f d13 1 1 c0t0d0s3 metainit d23 1 1 c0t1d0s3 metainit d3 -m d13 vi /etc/vfstab (Put metadevices in place of slices) shutdown -i6 -g0 -y metattach d3 d23 . Encapsulate swap metainit -f d11 1 1 c0t0d0s1 metainit d21 1 1 c0t1d0s1 metainit d1 -m d11 vi /etc/vfstab (Put metadevices in place of swap entry) shutdown -i6 -g0 -y metattach d1 d21 dumpadm -d /dev/md/dsk/d1 . Optional: Allow quorum at only 50% vi /etc/system (Add line: set md:mirrored root flag=1) . Setup \mirror" alias and boot-device setting in _rmware ok nvedit 0: devalias mirror /pci@1f,0/pci@1,1/ide@3/disk@1,0 1: (Ctrl-C to exit) ok nvstore ok setenv use-nvramrc? true ok setenv boot-device disk mirror (This can also be done from the OS using the eeprom command.) _ Restart the system shutdown -i6 -g0 -y _ HUP a process (myappsrv) by name pgrep myappsrv (Use this to test your REGEX _rst) pkill -HUP myappsrv _ Turn on the system locator beacon (turn o_ with -f ) locator -n _ Mount an ISO image (device /dev/lofi/1 may vary) lofiadm -a /projects/solaris10 disk2.iso mount -F hsfs -r /dev/lofi/1 /mnt umount /mnt lofiadm -d /dev/lofi/1 _ Check what _le system type is on metadevice d30 fstyp /dev/md/rdsk/d30
Networking
Show interfaces currently installed on system, speed, and duplex dladm show-dev { (ndd can be used to adjust speed and duplex) List network interfaces from the global zone only ifconfig -aZ Remove all host speci_c con_guration from the system (and restart) sys-unconfig _ Primary IP con_guration _les /etc/hostname.interface ,! IP address for interface. Alternatively use ifconfig. /etc/nodename ,! hostname for the system. Alternatively set with hostname. /etc/defaultdomain ,! System domain name. (svcadm restart domain after change) /etc/defaultrouter ,! gateway for the system. Alternatively set with route. /etc/hosts ,! Linked to /etc/inet/hosts. For IPv4 addresses only. /etc/inet/ipnodes ,! For IPv4 and IPv6 addresses. Should be in sync with hosts _le. /etc/netmasks ,! This is not a symlink to /etc/inet/netmasks. Temporarily set IP address on hme0 ifconfig hme0 plumb up 192.168.1.17 netmask 255.255.255.0 Temporarily create an alias on hme0 (hme0:1) ifconfig hme0:1 plumb up 192.168.1.18 netmask 255.255.255.0 Create permanent alias on hme0 interface echo 192.168.1.18 > /etc/hostname.hme0:1 Temporarily set the default route route add default 192.168.1.1 Permanently add the same route as above echo 192.168.1.1 > /etc/defaultrouter Turn o_ tra_c on qfe3 ifconfig qfe3 down Disable an Ethernet device (qfe3) ifconfig qfe3 unplumb List statistics on all interfaces on system netstat -i List all open ports on system netstat -an | grep LIST List all open TCP connections netstat -f inet Continuously ping a host ping -s www.tablespace.net _ Use the snoop command to capture network packets
NFS
_ Change startup parameters for the NFS daemon in /etc/default/nfs Temporarily export /src directory share /src Permanently export by putting share command in /etc/dfs/dfstab List all exported _lesystems (on local system) dfshares /or/ showmount -e Share all _lesystems listed in /etc/dfs/dfstab shareall Stop sharing all _lesystems (not just those in /etc/dfs/dfstab) unshareall List clients connected to NFS shares on this server dfmounts Soft mount the /proj directory from server paris mount -F nfs -o intr,soft paris:/proj /proj Show mount points on remote system called paris showmount -e paris
Backup Other
_ smc is a graphical system management interface. Create snapshot of /var _le system using /u01 as a repository location fssnap -F ufs -o backing-store=/u01 /var Mount the previously created snapshot on /mnt mount -o ro /dev/fssnap/0 /mnt Delete the snapshot (repository will remain) fssnap -d /var
OneDollarData