How to list network interfaces in Solaris10

March 29, 2010

If you have a Solaris box with few NIC cards configured. You can list them as follows:

# ifconfig -a

ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
vsw0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 172.168.2.71 netmask ffffff00 broadcast 172.168.2.255
ether 0:14:4f:fa:95:15

And you’d get the output as shown above. So this is reflecting on localhost and one virtual switch vsw0. But what about other NIC cards? You can list all of the network cards at once using the following command:

ifconfig -a plumb

ifconfig -a

This will list all the network devices available on the Solaris Box. So even if you have a freshly installed Solaris machine with no interface configured, you can use the above command to list the network cards and then proceed with configuring them.


Mount cdrom manually in Solaris

March 18, 2010

It actually happens a number of times that although you’ve inserted the disc in a sparc machine but still it refuses to mount the disk. One of the workaround is to restart the vold and vomgt daemons. But even the if you don’t see your cdrom mounted, you can do it manually as mentioned below:

First find the cdrom, i.e. we need to know the x in cxtxdx.

Fire the following command to find the actual path of cdrom:

ls -al /dev/sr*

This would look like something as follows:

bash-3.00# ls -al /dev/sr*
lrwxrwxrwx   1 root     root          12 Mar  8 14:14 /dev/sr0 -> dsk/c1t0d0s2

So here my cdrom is /dev/dsk/c1t0d0sx

We’re not yet sure about the slice no. so I’ve mentioned sx in above line.

Now we’ll ltry to mount the above slice manually:

mount -F hsfs /dev/dsk/c0t1d0s2 /mnt/cdrom

hsfs mount: /dev/dsk/c1t0d0s1 is not an hsfs file system.

If this fails then we can try for another slice:

mount -F hsfs /dev/dsk/c1t0d0s0 /mnt/cdrom

And it works this time, meaning our cdrom was at s0 slice.


Package Mangement in Solaris

November 22, 2009

Here are the list of useful commands frequently used during package management.

pkgadd

Adds software packages to the system

pkgrm

Removes software packages from the system

pkginfo

Displays software package information

pkgchk

Checks the accuracy of a software package installation

So, we’ll take an example to use above commands. I’ve a package called SUNWant.Z, which I want to install.

So I use the following syntax to add a package.

pkgadd -d SUNWant.Z

To check whether your package has been installed, you can use pkginfo and grep the output to find a specific package.

pkginfo | grep SUNWant

To check the accuracy of the package, you can use pkgchk command as:

pkgchk SUNWant

To remove above package, we have the pkgrm command to use:

pkgrm SUNWant

Refer the Sun documentation for further details.


Solaris Run Levels

November 12, 2009

The run levels in Solaris are little different than what you know about run levels in Linux. So, if you come from Linux background this could be little confusing initially.

There are total 8 run levels in Solaris. Default run level is 3. At a given point of time, a system can be in only one run level.

0    Power Down State
To shut down the operating system so that it is safe to turn off power to the system. This will bring the machine to Open Boot Prompt (OK)

s or S    Single User State
To run as a single user with some file systems mounted and accessible.

1     Administrative State
To access all available file systems. User logins are disabled.

2    Multiuser State
For normal operations. Multiple users can access the system and all file system. All daemons are running except for the NFS server daemons.

3    Multiuser level with NFS resources shared
For normal operations with NFS resources shared. This is the default run level for the Solaris environment.

4    Alternative multiuser state
Currently unavailable.

5    Power-down state
To shut down the operating system so that it is safe to turn off power to the system. If possible, automatically turns off power on systems that support this feature.

6    Reboot state
To shut down the system to run level 0, and then reboot to multiuser level with NFS resources shared (or whatever level is the default in the inittab file).


How to create a Solaris Flash Archive (Flar)

October 22, 2009

A solaris filesystem can be copied into an flash archive. This archive can then be used to install the Solaris OS on another system. Installation through flar is fast and efficient.

The format of the command is as follows:

# flarcreate -n name options path/filename

name
The name that you give the archive.

options
For a description of options, see The flar Command.

path
The path to the directory in which you want to save the archive file. If you do not specify a path, flarcreate saves the archive file in the current directory.

filename
The name of the archive file.

So for example I wan to create a flar with the name Solaris9 and the filename as myarchive.flar, the command will look like as mentioned below:

# flarcreate -n solaris9 -c myarchive.flar

where -c is an option to create compressed flar.

See the manpages for more options.


How to configure telnet to login as root

September 23, 2009

By default, telnet is enabled to be access by remote logins for a non-root user. To allow a root user to access the telnet remotely you will have to explicitly allow it.

This can be done by commenting the following line in the file /etc/default/login:

# CONSOLE=/dev/console

But please understand the security threat behind this, first telnet is insecure and hence is not suggested method of remote access, instead use SSH. Besides allowing remote login for root via telnet is a big NO NO.

You’ve been warned!


Solaris 10 versions

September 21, 2009

Often the Solaris 10 versions are referred by two ways. Either by the date on which they were released or the update no. So the latest release of Solaris10 is U8 released in Oct-2009 (10/09).

But what about the rest?
Given below is a simple table mentioning the release date and its corresponding update no:

Update Release
1 01/06
2 06/06
3 11/06
4 08/07
5 05/08
6 10/08
7 05/09
8 10/09

How to mount a iso file

June 21, 2009

So you’ve a cd image in iso format and you want to accesss it. Quite simple, it consists of two parts, creating a loopback device and then mounting this block device to any mount point.

1. Creating a loopdevice using lofiadm

# lofiadm -a /export/home/cdimage.iso /dev/lofi/1

If this file already exists then simply go for /dev/lofi/2 and so on.

2. Mounting the block device to a mount point

# mount -F hsfs -o ro /dev/lofi/1 /mnt/cdrom

Here hsfs is the filesystem type for CD-ROM/DVD on Solaris platform.

Fortunately there is a quicker alternative to firing both the commands. The output of these can be achieved in a single command

# mount -F hsfs -o ro `lofiadm -a /export/home/cdimage.iso` /mnt/cdrom

Ans so now you can access the iso like a mount cdrom at the mount point.

To unmont use ‘umount’ command and the mount point.

# umount /mnt/cdrom

And so you’re done.


How to change IP address

June 20, 2009

If your solaris system has a static address assigned to it and you wish to change it, simply update the files corresponding to your version of Solaris as explained below.

Solaris 9 and below change the IP in following file

/etc/hosts

Solaris 10 till update 3

/etc/hosts

/etc/inet/ipnodes

Solaris 10 update 4 and later

/etc/hosts

In case you also want to change your gateway, change the router address in…

/etc/defaultrouter

Also ensure that you have the correct netmask mentioned in the file…

/etc/netmasks

Create the netmasks file if it does not exist.


How to Track Users on Solaris

June 20, 2009

So you want to check who have ever accessed your Solaris system. Tracking or monitoring users on a system is quite an important part of ‘Solaris Adminstrators’ role.

There are two parts to it:

- Who is currently logged in

- Who has previously accessed this machine

To the details of users who are currently logged in to the system, fire the following command:

# who

This gives the limited details of the user logged in. If you also want to know who is running what program, there is another command:

# w

But this is only about the users who currently logged in to the system. What about if they logged out some time back. Or if they used your system when you were not monitoring? No worry …

# last

This command records all login and logouts. So you may have to use more or less to control the output.

There is one more log that keeps record of user switching. So if anybody has used su command to swith to some other user it will keep a log of it under /var/adm/sulog. You can cat this file to see the output.

# cat /var/adm/sulog

SU 06/26 16:25 + syscon root-root

SU 06/26 17:39 + syscon root-root

SU 07/02 11:11 + console root-sysadmin

SU 07/02 11:19 + console root-mgreen

SU 07/07 09:11 + pts/1 sysadmin-root

SU 07/08 10:45 + pts/4 testuser-root

So if somebody logged in as root directly then it would come under last command and if someone is logging in as normal user but later switching to root with ‘su’ command you can check that in the sulog.

Now you have complete information of users logging in to your system.


Follow

Get every new post delivered to your Inbox.