The Solarum Solaris Reference
This reference is a collection of things that have come in handy for me in times past. These are the basics that I had to learn early on, plus still have to look up once in a while just to make sure I remember it right. This should serve as a quick reference for admins new and old alike. If you need to know something that isn’t here, or if you have something you think should be added, let me know. As of the time of posting (2007.12.18) this is the first draft, I’ll be adding more and editing as time goes on, this will be a “living” document.
Contents:
Local Filesystems
How do I automatically answer yes to all questions generated by fsck?
How do I format a new filesystem?
How do I manage NFS shares?
How do I manage the mount table?
Networking
How can I control how domain name lookups are performed?
How do I change the hostname and/or IP address?
How do I manage known TCP/IP subnets?
How do I manage the hosts file?
How do I manage the Internet super-server daemon (inetd)?
How do I manage network protocols?
How do I manage network service names and associated ports?
How do I set the default NIS/NIS+ domain?
How do I set the default router or gateway?
How do I set the DNS servers?
How do I set the IPv4 address to be used at boot?
How do I stop Solaris from acting as a router?
Misc Stuff
How do I add a new user account?
How do I apply a patch?
How do I force a reconfigure on boot?
How do I designate users that are NOT allowed to connect via FTP?
How do I install a Solaris package file?
How do I manage pluggable authentication?
How do I manage power settings?
How do I manage the list of system shells?
How do I manage the overall runlevel configuration?
How do I manage the rpc.bootparamd file?
How do I manage the syslod daemon configuration?
How do I set a custom message for before and then after a user logs in?
How do I set system wide (and per user) trusted hosts?
How do I view detailed system information?
How do I view EEPROM settings?
How do I view or change kernel parameters?
What if I forget the root password?
Where are the startup scripts located for different runlevels?
Where can I find user account information, as in where is it stored?
Local FilesystemsHow do I automatically answer yes to all questions generated by fsck?
Use the fsck command with the -y operand. For example, if you are running fsck on a UFS partition that is c0t0d0s0, the command would look like this:fsck –F ufs –y /dev/rdsk/c0t0d0s0
How do I format a new filesystem?
Use the newfs (new filesystem) command. For example, if you are formatting a partition that is c0t0d0s0, the command would look this this:
newfs –v /dev/rdsk/c0t0d0s0
How do I manage NFS shares?
Edit the file: /etc/dfs/dfstab, and enter all the shares that you want to share out via NFS. If the NFS server is already running, you will need to stop and start it in order to make it see the new shares. You can use the share command to see what is currently being shared by the NFS server.
How do I manage the mount table?
Edit the file: /etc/vfstab, in there you will find existing mount entries, and this is where you would add new ones. Be careful when editing this file, if you make a mount entry and for whatever reason it won’t mount (typo, etc.), the system will not boot properly. It will stop at single user mode waiting for you to login as root to fix it.
NetworkingHow can I control how domain name lookups are performed?
Edit the file: /etc/nsswitch.conf, specifying what source should be used for lookups (host files, NIS, NIS+, or DNS), and in what order it should be used.
How do I change the hostname and/or IP address?
Edit the file: /etc/hostname.interface if the hostname is changing.
Edit the file: /etc/inet/hosts (possibly /etc/hosts), and specify the appropriate IP address for the hostname set in /etc/hostname.interface.
Check the files: /etc/net/*/hosts to make sure there are no hostname or IP references that need to be updated.
Edit the file: /etc/defautrouter, and update the IP address of the default router or gateway if needed.
Edit the file: /etc/resolv.conf, and update the DNS information if needed.
**For Solaris 10 there is another file called /etc/ipnodes, and it needs to be modified as well when changing the IP address.
How do I manage known TCP/IP subnets?
Edit the file: /etc/inet/netmasks, and enter appropriate subnet information. If you have an Ethernet interface configured but don’t have the subnet entered in /etc/netmasks, the subnet will be wrong when the system boots causing communication problems. Normally /etc/netmasks has what was entered during the install, so you probably don’t have to worry about it unless you are changing the IP address.
How do I manage the hosts file?
Edit the file: /etc/inet/hosts, in most cases /etc/hosts is a link to this file. If it isn’t, it should be.
How do I manage the Internet super-server daemon (inetd)?
Edit the file: /etc/inet/inetd.conf, this is the inetd configuration file. Most things will be commented out, un-comment a line to have it start when inetd starts.
How do I manage network protocols?
Edit the file: /etc/inet/protocols
How do I manage network service names and associated ports?
Edit the file: /etc/inet/services
How do I set the default NIS/NIS+ domain?
Edit the file: /etc/defaultdomain, and enter the appropriate domain name.
How do I set the default router or gateway?
Edit the file: /etc/defaultrouter, and enter the appropriate IP address.
How do I set the DNS servers?
Edit the file: /etc/resolv.conf, and enter the appropriate Internet domain name, name server and search order.
An example of resolv.conf looks like this:
domain mydomain.com nameserver 192.168.0.1 search mydomain.com
How do I set the IPv4 address to be used at boot?
Edit the file: /etc/hostname.interface, and enter the appropriate hostname or IP address. The interface portion of the file name should match the interface you are configuring (hme0, ce0, etc.).
How do I stop Solaris from acting as a router?
Create the file: /etc/notrouter, it will prevent in.routed or in.rdiscd from starting at boot time.
Misc StuffHow do I add a new user account?
Use the useradd command, like so: useradd –d homedir -m –u UID –g GID –c “comment” –s shell username
There are several options you can use with the useradd command, here are a few that are most useful to me:
- -d – This specifies the user’s home directory.
- -m – This tells useradd to create the user’s specified home directory if it doesn’t exist, use with -d.
- -c – This specifies the comment, so you can add a text string here like the users name or department, etc.
- -s – This specifies the user’s shell, so you can set it to something other than the default if necessary.
- -u – This specifies the user’s UID, and usually I don’t use this unless I have a specific need to set a specific UID.
- -g – This specifies the user’s GID (group ID), in other words it specifies what primary group the user is in.
- -G – This specifies what secondary groups the user is in.
This is an example of how I might create a new account for Bob Jones in the Accounting department:
useradd -d /usr/jonesb -m -g accounting -G users -c “Bob Jones – Accounting” -s “/bin/bash” jonesb
How do I apply a patch?
Use the patchadd command, like this: patchadd [options] patchfile
Be warned, the -d option is great for pkgadd as it specifies the source directory … however, with patchadd it tells patchadd not to store backout information which is BAD, don’t do it.
How do I force a reconfigure on boot?
This can be done one of two ways, either create (touch) the file /reconfigure and restart the server, or from the openboot prompt, give it the boot -r option. From the command prompt in Solaris, you can accomplish the equivalent of a boot -r by issuing the reboot command like this: reboot — -r. Sometimes I do both just because I can, so an example of the commands would be:
touch /reconfigure reboot -- -r
How do I designate users that are NOT allowed to connect via FTP?
Edit the file: /etc/ftpusers, any user listed here will NOT be able to connect to the system via FTP. At a minimum, you should have root and any other system/non-user account in here.
How do I install a Solaris package file?
Use the pkgadd command, like this: pkgadd –d pkgfile. The -d option tells pkgadd to look for the package file relative to where you are when you run the pkgadd command. So, you can give it the explicit path, use a ./, and more to make sure you point it to the right place. For example, if you want to install Netscape and it’s in the /tmp directory, the commands would look like this:
cd /tmp pkgadd -d SUNWnsb
How do I manage pluggable authentication?
Edit the file: /etc/pam.conf
How do I manage power settings?
Edit the file: /etc/power.conf
How do I manage the list of system shells?
Edit the file: /etc/shells
How do I manage the overall runlevel configuration?
Edit the file: /etc/initab
How do I manage the rpc.bootparamd file?
Edit the file: /etc/bootparams
How do I manage the syslog daemon configuration?
Edit the file: /etc/syslog.conf
How do I set a custom message for before and then after a user logs in?
Edit the files: /etc/issue for the message displayed before user login, and /etc/motd for the message displayed after user login.
How do I set system wide (and per user) trusted hosts?
Edit the files: /etc/hosts.equiv, and ($HOME/.rhosts)
How do I view detailed system information?
Use the command: /usr/sbin/prtconf –vb
You can also use /usr/sbin/prtdiag for more and different information and diagnostics.
How do I view EEPROM settings?
Use the command: /usr/sbin/eeprom
How do I view or change kernel parameters?
Edit the file: /etc/system **Be Careful! Major brickage can occur if you mess this up!!!
Examples of common settings are:
set noexec_user_stack=1 # disable execution in stack set noexec_user_stack_log=1 set maxuprc = 128 # maximum no. of user process set sys:coredumpsize = 0 # prevent core dump
What if I forget the root password?
This has happened to all of us at one time or another, here is what you can do:
Insert a Solaris CD-Rom, then from the open boot prompt run boot –s cdrom (this tells the server to boot from the CD-Rom and enter single user mode)
Find the root disk and partition with format command if you don’t already know, let’s assume that c0t0d0s0 is what we want in this case and mount it:
mount /dev/dsk/c0t0d0s0 /mnt
Now edit /mnt/etc/shadow and blank out the root password, it will be the hash found after the root username. When you reboot you can login without one or set a new one. Be sure to edit the /etc/shadow on both disks if you have a mirror.
Where are the startup scripts located for different runlevels?
In the directories: /etc/rc(S | 1 | 2 | 3 | 5 | 6).d
Most of the time, you will find yourself working in /etc/rc2.d and /etc/rc3.d
Where can I find user account information, as in where is it stored?
Examine the files: /etc/passwd, /etc/shadow, /etc/group. The file /etc/passwd stores user account information like userid, group, shell, comment, etc. The file /etc/shadow stores the password hash for all users and should ONLY be readable by root. The file /etc/group holds the list of all groups and who are members of what groups. You can also use a couple commands (as root) like “logins” and “passwd -sa” to see information about users on the system.
Last update: 2007.12.18
Pingback: Solarum’s Solaris Reference | Solarum - Information For Everyone
Pingback: Solaris Reference added to the download section | Solarum - Information For Everyone