Solaris Interview Questions and Answers - Freshers & Experienced

Explain the types of installations in Solaris

There are several ways to install Solaris. They are

- Solaris Installation Program – This is a general way of Solaris installation through a CD/DVD-ROM.

- Solaris Installation Program over Network – Installing Solaris from server that has access to Solaris disc images.

- Custom Jumpstart Installation – This method is a command line interface that can implicitly install or upgrade several systems using the profile created.

- Solaris Flash Installation – This installation enables to use a common reference of the Solaris OS on a master system.

- WAN Boot – This installation enables to boot and install over a wide area network by using HTTP.

- Solaris Live Upgrade – This method is used to upgrade the system while current operating environment is running.

- Solaris Zones – After installing Solaris OS, Zones are configured and installed. The global zone is the instance of the operating environment currently running.

How to add your own run control script in server?

- Create a script for example file1
- Copy this file to /etc/init.d

# cp file1 /etc/init.d
# chmod 0744 /etc/init.d/file1
# chown root:sys /etc/init.d/file1
# ln /etc/init.d/file1 /etc/rcn.d/S100file1
# ln /etc/init.d/file1 /etc/rcn.d/K100file1

What are the RAID levels in Solaris?

RAID means Redundant Array of Inexpensive/Independent Disks.

There are Six RAID levels

- RAID Level 0
- RAID Level 1
- RAID Level 2
- RAID Level 3
- RAID Level 4
- RAID Level 5
- RAID Level 6

Here only level 0, 1 and 5 are used extensively, only few storage systems support level 2, 3 and 4.

What are NFS daemons?

- Automountd - It handles mounting and unmounting requests using autofs service.

- Lockd - It is used for file locking for both nfs server and clients.

- Mountd - It handles mount requests and also provides information about mounting nfs shares.

- Nfsd - It enables file system exporting and file access requests from remote clients. It is used at run level 3.

- Nfslogd - This daemon provides operational logging information.

- Nfsmapid - It provides information mapping from a User identification or Group identification to string representation or vice versa.

- Statd - It is in use with logd to provide crash and recovery information.

How many run levels are there and what are they?

There are eight run levels in Solaris. They are

Run levelState
0power down
s or Ssingle User
1Administrative
2Multi-User
3Multi-use with NFS
4Alternative Multi-user
5Power down
6Reboot

How do you copy files from remote system using FTP?

Firstly, change the directory on the local system to the required path in which the file is to be copied.
$ cd <dir name>
Establish ftp connection.
$ ftp <remote system name>
Now, move to the source directory.
ftp> cd < source directory>
Make sure that the user has read access rights for the source files.
ftp> ls –l
Set the type to binary format.
ftp> binary
To copy a single, multiple files, use get, mget respectively.
ftp> get <file name>
ftp>mget <filename1> <filename2>……<filename?>
Terminate the ftp connection.
ftp> bye

What does pkgadd command do?

- It installs a signed or unsigned software package.
- Removes any existing packages installed with the same name as of that we are adding.

Add package to the system using pkgadd.
Syntax:
pkgadd –a admin_file –d device-name pkgid

Verify if the package is installed successfully
#pkgchk –v pkgid

Example:
pkgadd -d /cdrom/cdrom0/solaris10/product SUNwaudio

The above example is to install the package from cdrom

Explain how to kill a process.

1.Become a superuser or root user to terminate the process of the another user.
2.Obtain the PID of the process to be terminated.

Syntax:
$ps –fu

Example:
$ps –fu abc
abc 325 322 3 jan 12 ? 11:04 /usr/openwin/bin/sun

The process ID is displayed in the first column of the output.

Terminate the process using kill command.
$ kill pid
Default signal number is -15 {SIGKILL}
-9 {SIGTERM}

Verifying if the process is terminated or not.
$pgrep <pid>

How do you remove a swap space?

- To remove unneeded swap space, become a super or root user.

- Remove the swap space
# /usr/sbin/swap –d /path/filenames

- Edit the /etc/vfstab file and delete the entries from swap file

- Retain the disk space so that we can use it
#rm /path/filename

- Verify if the swap file is available or not.
#swap –l.

What are NIS daemons?

NIS services are provided by five daemons and managed by service management facility (SMF).

- Ypserv – Server Process
- Ypbind – Bind Process
- Ypxfrd – High speed map transferring
- Rpc.yppasswdd – NIS password update
- Rpc.ypupdated – Modifies mappings

How do you break the root password?

Enter in to the single use mode.
ok boot cdrom –s
# mount /dev/dsk/c0t0d0s0 /a
# cd /a/etc
# TERM = vt100
# export TERM
# vi shadow
Here, remove the roots encrypted password string then save and exit.
# cd/
# umount /a
# init6
This will restart the system and now the root login can be entered without password.

Explain the difference between PID and PPID with example.

A collection of system programs and user generated programs is called Process.
- Every process contains two ID’s.

PID – Process ID
Syntax:
$ ps [-efc]
-ef – full information about executed process
-c – process schedule information

PPID – Parent processs ID
Example:
ps –ef
Output: root 12066 12036 19:44 pts/2
Here, 12066 is PID and 12036 is Parent Process ID.

How to login to a remote host with Solaris secure shell?

- Start a Solaris secure shell session by using "ssh command" followed by name of the remote host.
Local Host # ssh RemoteHost
- Here an authentication is to be given for initial connections to remote hosts.
- If we cannot confirm the authentication of remote host, type no and contact system administrator.
- If we can confirm the authentication, then type Yes and continue to the next step
- Now, authenticate yourself to ssh.
- When prompted, type the passphrase, account and password.
- Transactions can be made on the remote host by encrypted commands.
- Terminate the ssh connection.

Which command is used to backup and restore Solaris file system?

- Backup file system can be done by using ufsdump command.
ufsdump [options] [arguments] [file names]

Example:
#init 0
ok boot –s
# ufsdump 0ucf /dev/rmt/0 /

- Restoring files can be done by using ufsrestore command.
Ufsrestore ta [archive name] ./path/filename ./path/filename

Example:
# ufsrestore tf /dev/rmt/0
# (to bring system to run level 3)

List out a few performance monitoring tools.

Vmstat
This command is used to know virtual memory statistics
$ vmstat n
n – Interval in seconds
$ vmstat –s {to know the system events since the last boot}
$ vmstat –S {to show the swapping statistics}
$ vmstat –i {to show the interrupts per device}

Iostat
This command is used to display the statistics about disk input and output.
$ iostat 5
$ iostat –xtc { to show extended disk statistics}

df
This command is used to know the free space on the mounted disk.
$df –k {to show the disk space in kilobytes}

What is sticky bit?

- Permission that protects the files in a directory is called sticky bit.
- If a file is set with a sticky bit, then it can only be deleted or renames by the owner of the file or directory.
- The sticky bit prevents a user from deleting the files of the others.
- Octal value of the sticky bit is 1 .
- Sticky bit is implicitly set in general but should be set manually in case of TMPFS file system.
drwxrwxrwt 7 root sys 528 jan 27 12:32 /tmp

How does a solaris cluster work?

A typical solaris cluster configuration comprises of the following components:

Hardware components:
- Servers with local storage
- Share storage
- Cluster interconnects
- Public network interfaces
- Administrative workstation

Software components:
- Solaris running on each node
- Solaris cluster software dunning
- Data services.

The server in a cluster use private interconnects to communicate with each other. These interconnects are responsible for carrying the cluster information. The information carried is also known as the heartbeat. This heartbeat lets the servers in the cluster monitor the health of other servers hence ensuring that every other server is alive in the cluster. In case of a server failure the heartbeat of that server disappears and the server is not considered to be the part of the cluster. The term used to isolate the failed server is known as fail-over. The clusters are characterised by the high rate of availability.

What are the differences between the command line and graphical user interface?

- The CLI or the command line interface allows a user to type commands into a terminal or console window to interact with the operating system. The user has to enter the command or a series of command for each task that the user wants to be performed.

- The GUI or the graphical user interface on the other hand uses graphics in tandem with the keyboard and a mouse to give the user an easy to use interface to use the program. The GUI provides the user with windows, menus, buttons, scrollbars etc to enbale the users to interact with the operating system.

- The most common types of GUI interfaces provided by Solaris is the CDE (Common Desktop Environment ) and the GNOME desktop. Both the GUIs provide similar functionality to the user to use the operating system.

How can a user login to Solaris? What is the login shell?

- The Solaris platform is a very secure platform and it requires the user to enter his login information prior to starting any work in the operating system. Before a user login to his account the screen would show the following prompt:
hostname console login: Rohit

- On pressing return the user is asked to enter the password for his account. In order to prevent the password from being detected by someone else the system does not show the password on the display screen. When a user issues a command to the operating system via the terminal or the GUI the user is actually providing the information to the command interpretation system also known as the shell. The shell takes all the user inputs and makes sure they are executed properly by the OS. The default shell for Solaris system is the Bourne shell.

There are various other shells supported by Solaris such as:
- GNU Bourne shell
- C shell
- Korn shell etc.

When the user initially logs into the system and the sees the command prompt , it means that the shell program has been initiated. This shell is called the login shell.

How can the output be redirected to some other action process in place showing it in the screen?

- Solaris allows the user to redirect the output of an operation to a file or something else if required. For ex.
$ date > sample.file
$
The above command upon execution would cause the output of the date command to redirect to a new file sample.file.

- Another type of requirement is that the user might want to use the output of a particular operation to act as the input of another operation. This can be achieved in Solaris by making use of the pipe (|). A set of commands which are tied up together like this are called pipelines.

An example depicting the use of the pipes:
$ date | lp
request id is jetprint-46

How can the user in solaris check the status of processes?

Once the system interprets a command the system simply creates an independent process with a unique PID assigned to that process. To keep the track of each process the system uses the PID. In case the user wants to find out the processes that are currently running on the system the user can use the ps command.

The ps command on execution displays the:
- PID of the processess.
- The terminal from which a process was started
- The cpu time that the process has used so far.

The variable meanings:
- O : this implies that the process is running on a processor.
- S : This implies that the process is currently sleeping and waiting for an event to complete.
- R: This implies that the process is in the run queue.
- I : Implies the process is being created.
- Z: Implies the process is zombie ie. It has terminated.
- T: implies that the process is stopped as the parent was tracing it.
- X: The process is waiting for more primary memory.

Discuss the two modes of the vi editor in solaris.

The two modes of operation of the vi editor are the entry and command mode. The drawback for first time vi users is that it does not distinguish between the two modes visually.

- Entry mode: This mode is used to enter text into a file. The vi is by default in the command mode. In order to enter text into a file the user has to type the vi insert command ‘i’. This changes the mode of vi from command to entry mode.

- Command mode: Every time the vi editor is opened it launches the command mode by default. In case the user is entering text and is one with it all he needs to do is press the esc button and the user is back at the command mode. The command mode allows the user to enter and execute a vast range of commands. Most of the commands consists of one or more letter with an optional number. Most commands does not require the return key to be pressed to execute. But the commands preceded by a colon require the return key to be pressed to execute.

How can searches be refined?

The searches can be made to be more refined by using string indicators.

Some of the characteristics are:
- Beginning of line:
- End of line
- Beginning of word
- End of word
- Wild-card characters

- To be able to match strings at the beginning of a line, start the search string with a caret symbol “ ^ “ For ex : /^Search

- If the user wants to search the end of a line the search string can be ended or appended with the dollar sign $. For ex /search\.$

- In order to be able to match the beginning of a word the user needs to type \< at the beginning of the string. In case the user want to match the end of a word, specify the \> symbol at the beginning of a string.

What do you understand by mail aliases?

The mail aliases is a selection of user names that have been grouped together under a single name. Aliases are helpful to the user in case he has to send mails to same group again and again. There are two locations where the user can setup mail aliases:

- The .mailrc file
- The /etc/aliases file.

The differences between setting up the mail aliases in the .mailrc file and /etc/aliases file are as follows:

- The .mailrc does not require root permissions to be enabled to modify it, but the aliases folder requires root permission for modification.
- The .mailrc can be used to name all the recipients on one line whereas the aliases folder does not allow that.
- The .mailrc file does not require commas between names the file in aliases folder require commas.

How can a user login to another system on his network remotely?

The rlogin command gives the user the ability to log in to other unix machines on the network. In order to be able to login to another system the user needs to execute the following command:

$ rlogin machinename
machinename is the name of the previous machine. On doing so the user may be required to enter the password for the remote machine.

For ex. The code snippet of logging in to a machine:
venus$ rlogin starbug -l user2
Password:
Last login: Wed Nov 1 13:08:36 from venus
Sun Microsystems Inc. SunOS 5.9 Generic February 2002
venus$ pwd
/home/user2
venus$ logout
Connection closed.
venus$

How can abiword be compiled for Solaris using gcc?

The abiword is a basic word processor which can be used in Solaris. To compile the abiword, the user can use Sun's cc and GNU gcc by following these steps ( compiling with gcc):

- The user needs to change the craible CC to gcc. He also needs to change the option -mt to pthreads
- The configuration option used is : ./configure --with-libiconv="path_of_libiconv" -with-libpng="path_of_libpng" CC=gcc
- The UT_ICONV should be set to “conts”
- There is a conflict due to the parameters (const void *, const void *); the user needs to set them to int (*dcomp) (const dirent **, const dirent **); to prevent any conflicts from occurring.
- The parameters passed on to alphasort are : int alphasort(const void *d1, const void *d2); This needs to be changed to int alphasort(const dirent **d1, const dirent **d2);

How can a user access a dos-format disk in Solaris?

First the user needs to use the volume management utility “volcheck”. This causes the Solaris to poll disk drives. The disk drives are not polled automatically in Solaris. By typing in mount in the command line the user would get the following output:
/floppy/unnamed_floppy on /vol/dev/diskette0/unnamed_floppy read/write
on Wed Jan 20 09:05:44 1999

In case, the user wants to unmount using the volume management utility the user needs to type in eject. Another way to mount the disk drive is by using the mount option. The command for mounting a disk drive is:
mount -F pcfs /dev/diskette /mnt

Prior to using this command the user needs to stop the volume management utility. This can be done by : "/etc/init.d/volmgt stop". If the volume manager is not stopped before mounting the user will get the device busy error. In case, the user wants to restart the volume manager utility the user needs to use the command : "/etc/init.d/volmgt start".

How can a user boot in solaris as root if the password is non functional?

To regain the control of the solaris system as root user can be done by applying the following steps:

- Mount the installation cd into an optical drive and the installation diskette into the floppy drive.
- The system is not to be booted using the floppy and setting the cd-rom as the boot device.
- Now the user needs to type in “b -s” into the command line which would send the user to the root shell.
- Once in the root shell the following commands need to be entered which would create a directory called hdrive inside the /tmp directory. After the directory creation the hard disk partition with this folder needs to be mounted:
mkdir /tmp/hdrive
mount /dev/dsk/c0t0d0s0 /tmp/hdrive #SCSI; for ATAPI, omit "t0"

- Now the TERM variable needs to be defined:
TERM=at386
export TERM

- The user now needs to load the /tmp/hdrive/etc/shadow file:
vi /tmp/hdrive/etc/shadow

- Change the first line of the shadow file:
root::6445::::::

- The editor needs to be quit using the ! override command:
:wg!

- Reboot the system. The user would be allowed to login as root without any login password.

What do you understand by IRQ assignments?

The interrupt request registers are used to handle interrupts coming from different internal and external devices. Multiple PCI devices can share an IRQ but multiple ISA devices cannot support multiple devices. The IRQs are numbered 0 to 15.

Some of the IRQ numbers are:

- IRQ - Assignment
- IRQ 0 - System Timer
- IRQ 1 - Keyboard
- IRQ 2 - Programmable Interrupt Controller; gateway to IRQs 9 - 15.
- IRQ 3 - COM2 (ttyb) I/O Base 2F8h (usually a ISA modem)
- IRQ 4 - COM1 (ttya) I/O Base 3F8h (usually a serial mouse)
- IRQ 5 - Usually a secondary printer, NIC, or sound card
- IRQ 6 - Diskette Controller
- IRQ 7 - Parallel Printer; sometimes used for a sound card
- IRQ 8 - CMOS Real-Time Clock
- IRQ 9 - Sometimes used for a sound or network card
- IRQ 10 - No assingment
- IRQ 11 - Sometimes used for PCI Video
- IRQ 12 - PS/2-style Mouse
- IRQ 13 - Math Coprocessor Exception
- IRQ 14 - Primary ATAPI Disk controller
- IRQ 15 - Secondary ATAPI Disk controller

The IRQ number 10 has no assignment: Such IRQs are usually the target of various cards such as the scsi, sound and network cards. The IRQs form the backbone of a computer operating system. It is responsible for the maintaining the flow of processes.

How can a user increase the number of pseudo-ttys?What is their use?

By default, the number of pseudo-ttys is 48. The user can define as many pseudo ttys as required by him. More than 3000 pseudo ttys are supported by the system. The pseudo ttys are not associated to any physical hardware. They are used to simulate the functioning of a real tty. A user can add pseudo ttys by editing the /etc/system and adding the following lines

* System V pseudo terminals
set pt_cnt =
Halt the system and boot -r
The pseudo tty is created using the mkdev ptty command

A user should not add unnecessary pseudo ttys as they just waste memory space. A pseudo-tty can be used for various purposes, a good example of its usage is in the networking domain, the pseudo ttys are used to login to a remote device. The pseudo tty is represented by two software devices which appear in form of a listing of /dev as the ptyp and ttyp. The ttyp is considered to be the master and the ptyp is considered to be a slave.

What can be done to protect the system from overflow exploits?

An overflow occurs when a program writes to the memory address which is outside the intended data structure. The data structure in such cases is usually a fixed length buffer. It results in the corruption of the data. The default behaviour of the solaris kernel is to map the system stack RWX. A non-executable stack gets in the way of the certain classes of security bug exploits. A feature was added that would enable the administrators to disable the ‘X’ protection from a stack. To enable this the user needs to add the following to the /etc/system:

- Foil certain classes of bug exploits
set noexec_user_stack = 1
- Log attempted exploits
set noexec_user_stack_log = 1

To be able to use this feature certain prerequisites are necessary such as hardware support, also 32 bit applications which are being run on a 64 bit kernel do not work.

What can be a reason for the Solaris system slowing down? How can it be rectified?

A Solaris system can start performing slowly when there is a kernel memory leak. A memory leak occurs when a process that consumes memory of a system is unable to release the memory being used by it back to the system. In reference to object oriented programming a memory leak occurs when an object is stored in the memory and it is not accessible to the running code. There can be two possible reasons of memory leak in solaris:

- Bug: A bug exists in the volume management device driver. Whenever this driver is unloaded it results in a memory leak. This bug specifically affects systems that are not running vold. Vold is triggered when the kernel unloads unused device drivers. This bug can be fixed by applying a patch that is available for both sparc ans x86 platforms.

- NFS cache: Memory leak can be caused when the NFS client caches cache in excess. To rectify this problem the user needs to add “set nrnode=1000” to the /etc/system save it and reboot the system. The general rule that is followed while setting the value is to assign around 25 nodes per megabyte of memory available.

What causes the rpc.ttdbserverd process to be CPU bound? How can it be rectified?

The rpc.ttdbserverd is the tooltalk database server used by Solaris. This is rpc based. The purpose of this server is for the creation and management of database files maintained under the TT_DB directories. This server becomes CPU bound due to the existence of corrupted entries in the TT_DB directories. This problem can be rectified by stopping the running rpc.ttdbserverd process, and manually removing all the local TT_DB directories present. Once this is done the rpc.ttdbserverd process can be restarted using the inetd. The TT_DB directories would be created automatically on restart. Unless specified, by default the directories are created in the top directory of the file system. In case, the user wants to specify a particular path he can do so by using the "/etc/tt/partition_map" to tell ttdbserverd where to create the directories.

Another possible reason for rpc.ttdbserverd to be CPU bound is the exhaustion of filedescriptors. This can easily fixed by increasing the number of filedescriptors that rpc.ttdbserverd begines with.

What are the ways in which replication agreements between directory structures be arranged?

The different ways in which the replication agreements between directory structures can be arranged are:

- Multi-Master server - There are two or more master directory servers in this type of environment. All the servers which are master can perform all the LDAP operations such as read, write & searches. This can lead to synchronization issues in the directories between the directory servers. It is always better to have separate directories for separate servers.

- Single master replication: In this type of environment there are two servers, the master server and a replica server. The master server can perform all the LDAP operations which are read, bind, compare and write. The replica server on the other hand cannot perform write operations. For write operations the replica server requests the master server. In such a setup the synchronization issues do not occur. Instead the problem can occur when the master server stops functioning.

- Floating-master server: This model is similar to the single master replication model. The only difference is that the replica server cannot perform write operations while the master server is running. But in case the master server stops functioning the replica server can perform write operations.

Write the steps involved in creating and executing a program to implement the “case” command.

The steps involved are as follows:
- Login as an ordinary user.
- Open the text editor.
- Open the terminal window.
- Type the following script:

#!/bin/sh
echo “ What is your car model? \c”
read car
case”$mycar” in
Ford)
echo “An American car”
echo “Made in Detroit”
;;
Mercedes)
echo “ Are you sure you own one?”
;;
*)
echo “Never heard car”
esac

- Save the script with a name testscript.
- Type command in terminal chmod 777 testscript.
- Type ./myscript21

How can threads be created in a solaris environment? Write an example

The function thr_create() function can be used for the creation of a thread. The syntax for the creation of a thread is:

int thr_create(
NULL,
0,
void *(*funct)(void *),
void *arg,
0,
thread_t *ID);

When the function thr_thread() is called it creates a child thread. This will execute concurrently with the parent thread.

Code:
#include <stdio.h>
#include <thread.h>

void *count(void *JunkPTR)
{
   int *valuePTR = (int *) JunkPTR; /* convert to integer ptr. */
   int value = *valuePTR; /* then take the value */

   printf("Child: value = %d\n", value);
}

void main(void)
{
   thread_t ID1, ID2;
   int v1 = 1;
   int v2 = 2;

   thr_create(NULL, 0, count, (void *) (&v1), 0, &ID1);
   thr_create(NULL, 0, count, (void *) (&v2), 0, &ID2);
   printf("Parent\n");
   sleep(2);
}

The above code on execution would create two threads. Both the threads would be a copy of the count() function.
OS Synchronization Interview Questions and Answers
OS Synchronization - In this series, we have covered all about OS Synchronization and answered the questions that might be asked during an interview.
Process Management Interview Questions and Answers
OS Process Management - In this series, we have covered all about OS Process Management and answered the questions that might be asked during an interview.
OS Multiprocessing Interview Questions and Answers
OS Multiprocessing - In this series, we have covered all about OS Multiprocessing and answered the questions that might be asked during an interview.
Post your comment

You may like