You are on page 1of 13

Sun Solaris Command Tips

All commands are specific to Sun Solaris operating system

UNIX backups/Restore

Commands to take backup of /usr /var /lib directories to tape and disk using "tar"

ANS: a) tar -cvf /dev/rmt/0 /usr /var /lib [Taking into tape ]

b) tar -cvf backup_file.tar /usr /var /lib [ Taking disk image]


Taking backup to a tape device attached to a remote system

ANS: a) tar -cv /var /usr /lib | rsh remote_hostname dd of=/dev/rm/0 obs=128

b) ufsdump 0ucf remote_hostname:/dev/rmt/0 /file_system


Extracting / Restore the contents of a tape /tar file

ANS: a) tar -xvf /dev/rmt/0 [ restore contents of a tar tape ]

b) tar -xvf filename.tar [ Restore contents of a tar file ]

c) ufsrestore f /dev/rmt/0 filename [Restore from ufsdump tape backup]

d) ufsrestore rf remote_hostname:/dev/rmt/0 filename [ Restore from remote host tape device ]

List contents of backup

ANS: a) tar -tvf /dev/rmt/0 [ List contents of a tar tape ]

b) tar -tvf filename.tar [ List contents of a tar file ]

c) ufsrestore tf /dev/rmt/0 [ list contents of a tape of ufsdump]

Processes and Processor

What are the types of priority classes supported by Solaris ?

ANS: timesharing, system and reat-time

How will you place a running process in real time class?

ANS: priocntl -s –c RT –I uid process_id_number

How will you start a process in real time class?

ANS : priocntl –c RT –e process_name

How will you bind a process to processor ?

Ans: pbind –b processor_no process_id

Network
What is the pocket size used by SQL*NET Version 2 on Solaris

Ans : Default is 2K

What is the procket size used by network layer TCP/IP in SQL*NET v2?

Ans : Default 1K

Inter process communication (IPC) tuning

What is post wait driver ?

The post wait driver reduces the overhead incurred by the more expensive use of semaphore operation for interprocess
communication.

Memory

What is the kernel parameter which controls the UNIX buffer cache on solaris ?

Ans : bufhwm ( bufhwm is the maximum amount of physical memory, in kilobytes that can be used by

I/O buffers)
While starting an oracle process , the unix system displays an erro message like "Cannot allocate more shared memory
segment for the processes" If oracle person approaches you, how will you fix this problem?

ANS: increase the value for kernel memory parameter "set semsys:seminfo_semmns" in /etc/system file. [ this is a blind way]

System configurations

How do you find out total RAM installed on your machine

Ans: $prtconf |grep size

How do you find no. of processors installed on your sun box and processing speed?

Ans: $psrinfo –v

How do you find out how many disks are available on your system?

Ans: $ format (for sysadmins)

$ iostat –E (for users – count only the disks which has disk size correctly)

System Boot Options

How do you boot sun box in single user mode?

ANS: At ok prompt type "boot -s" [ ok boot -s OR ok boot -1 OR ok boot -S ]

What are the commands to shutdown the system?

ANS: shutdown, init , halt, reboot


Devices

What is the meaning of logical name of a disk drive format like c0t0d0s0?

ANS: c0 - Controller number

t0 - SCSI bus target number

d0 - Disk number

s0 - Partition or slice number

List some of the main device types?

ANS: /dev/dsk - Disk devices

/dev/rdsk - Raw or character devices

/dev/rmt - Tape devices

/dev/term - Serial line devices

/dev/pts - Pseudo terminals

List commands to display physical devices ?

ANS: prtconf

Sysdef

Dmesg

sysinfo

Thoughtful Solutions
Creatively Implemented and Communicated
http://www.thoughtful-solutions.info/
Basic Solaris Commands
Quick Reference Card
Conventions
<CR> RETURN key
<ESC> ESCAPE key
<DEL> DELETE key
<Ctrl-X> press <Control> key and type x
italics items to be replaced by your own
requirements
Shell Commands
passwd Change password
logout End terminal session
File Hierarchy
cd dir1 Change to directory dir1
ls List files in directory
ls -l List files in detail
mkdir dir1 Create new directory dir1
rmdir dir1 Remove directory dir1
cp f1 f2 Copy file f1 to f2
mv f1 [f2…] dir1 Move files f1 to fn to directory
dir1
mv dir1 dir2 Rename directory dir1 as dir2
rm filename Delete (remove) file filename
ln file1 name Create a hard link to file1 called
name
ln -s file1 name Create a soft link to file1 called
name
pwd Show path to current directory
Getting Help
man name Show man page for command
name
man -k subject Show man pages relating to
subject
man -s# subject Show man page relating to
subject in section number #
man -s# Intro Show introductory man page for
section #
File types and Listing
file filename Classify the file
strings filename Show any ASCII strings in a file
cat filename Display contents of file to STDOUT
more filename Display contents of file one
screenful at a time
head filename Display first 10 lines of file
head -n filename Display first n lines of file
tail filename Display last 10 lines of file
tail -n filename Display last n lines of file
tail -f filename Recursively display last 10 lines of
file
cut Extract character or fields from
text
wc filename Count lines, words and characters
in file
diff f1 f2 Find differences between two files
diff3 f1 f2 f3 Find differences between 3 files
sort filename Sort file alphabetically by first
letter
uniq Report or filter out repeated lines
Redirection
STDIN Standard Input, typically the
keyboard
STDOUT Standard Output, typically the
screen
STDERR Standard Error, where errors are
sent. Typically the screen
comm > file Output of comm creates file
comm < file Contents of file used as input to
comm
comm 2> filename Error messages from comm sent to
file
comm >> filename Output from comm appended to
file
cat file <<EOF Create a document called file
data… containing data
EOF
comm1 | comm2 Output from comm1 used as input
to comm2
mkfifo name Create a named pipe called name
mknod name p Create a named pipe called name
File Security
chmod mode filename
Change security settings on file
chown user [:group] filename
Change owner [and owning group] of
file
chgrp group filename
Change owning group of file
umask mode Set default creation permissions
Symbolic modes
Mode Meaning Mode Meaning
u user r read
g group w write
o other x execute
a all u+s setuid
= assign g+s setgid
+ add +t sticky bit
- remove
Octal modes
Base directory mode is 777. Base file mode is 666
user group other
rwxrwxrwx
421421421
777
Shell Wildcards
Metacharacter
Meaning
* Any character
? Any single character
[ ] A range of characters
This work is licensed under the Creative Commons Attribution-
ShareAlike License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/2.0

Interview Question & Ans:

Sort By : Latest First | Oldest First | By Rating

Question Rating View Answer


View Answer

View Answer
What is the big difference between /dev/dsk and /dev/rdsk

What are the main differences between solaris 10 and 9? View Answer

What would a XIR signal do to a server and why would it be used? View Answer

What is sticky bit in Solaris? View Answer

What is the big difference between /dev/dsk and /dev/rdsk View Answer

What software install group do you need to select in order to load the
View Answer
compilers?

Back to Sun Solaris OS Interview Questions and Answers page Question :


What file controls global variables for system wide values for the Bourne View Answer
Shell?

Is it legal to have static initializer blocks in EJB? View Answer

How can we find RAM size in solaris server ? View Answer

Which NFS daemons are found on the NFS server? View Answer

The NVRAM is also soldered to the main logic board or motherboard. View Answer

When using the admintool, the membership list for groups is separated by
View Answer
what?

Which obp command has a premenent allais? View Answer

How would you find out what kernel parameter SHMMAX is set to by one
View Answer
command?

I have a couple of questions. 1) If in solaris 8 one server has more than one
network interface cards, how do you determine which is primary? 2)In solaris
View Answer
8 how do you determine how many Ram cards exist in a server and in which
slots are they inserted?

What is diffrence between Process and Daemon? View Answer

How to find 32 or 64 bit system instances of OS? View Answer

How do you determin which Run Level the sytem is running View Answer
What is "Piping"? View Answer

Posted by: Vincent

Contact Vincent

Single User mode: Single user mode is for trouble shooting purpose, in this mode only root user can
login to the system.
Multi User Mode: In this mode apart from root user other user can also login to the system and they
can access resources and applications of the system.

Posted by: Basha

Contact Basha

Single user
Solaris OS single-user mode with critical file systems mounted and accessible, Maintenance
Only root user can access.
Multi user
The system is supporting multiuser operations. Multiple users can access the system. All system
daemons are running except for the Network File System (NFS) server and some other network
resource server related daemons.

Posted by: C. ANTHONY FRANCIS

Contact C. ANTHONY FRANCIS

In multiuser mode NFS server & client services are available whereas in single user mode, no NFS
service is available and only root filesystem is available.

Posted by: parag pisolkar

Contact parag pisolkar


Single user mode is the maintenance mode where only systems critical files are mounted. Multiuser
mode is running the server with full network services including NFS.

Posted by: Rahul Agarwal

Contact Rahul Agarwal

Single User Mod or Run Level s or S,


Solaris OS single-user mode with critical file systems mounted and accessible.

Multi User Mode or Run Level 3,


The system is supporting multiuser operations and has NFS
resource sharing and other network resource servers
available.

Main difference between these two level is as follows.

1). Network Services will not work in Single user mode.


2). Network Services will work in Multi user mode.

Posted by: Farhan A Azam

Contact Farhan A Azam

1. Single usermode ; Is used for Administrative activities.


2, Mukti user mode ; is used for normal operations means running any applications, database etc.

Posted by: G.Umakanth

Contact G.Umakanth

In single user mode , all the system services will not be available such as NFS and other
services,moreover only a single user can login at a time, where as in multiuser mode all the services
will be available including NFS and multiple users can log in at a time. In single user mode the run
level is S where as in multiuser mode the runlevel is 3

Posted by: nawazhussain


Contact nawazhussain

In single user mode it is possible to maintin the system or trouble shooting the system.

Posted by: sv suresh

Contact sv suresh

single user mode is an administrative mode . the root user only can login. it is also known as
maintenance mode. multiuser mode is default mode in solaris bcoz all services available in this
mode. from singleusermode we cannot communicate network machines.but from multiusermode we
communicate over the network.

Posted by: premnivas

Contact premnivas

In single user, critical file system will be mounted and where as multi user mode we can access nfs
and it is default run level.

Posted by: Raja Rajan

Contact Raja Rajan

In single user mode we can perform administrative tasks and it is maintenance mode. Multi user
mode runs the server with full network and services including nfs

Posted by: fazal

Contact fazal

Single usermode ; Is used for Administrative activities.


2, Mukti user mode ; is used for normal operations means running any applications, database etc.
Posted by: wadood

Contact wadood

Single user mode use to perform the administrative task,we can only access the local file system,

Multi usermod is the defult login mode so we can access all local as well as network file file system,

Main difference is that


Network Services will not work in Single user mode.
Network Serviceses will work in Multi user mode.

Posted by: Sameer Patil

Contact Sameer Patil

single user mode: In this only root user can login to the system and critical file systems are
mounted. This can be used for trouble shooting purpose.IN this NFS not working.

Multi user mode: This is run level 3. In apart from root user other users also login and access the file
systems including NFS.

#who -r ----> this command shows we are in which run level

Solaris interview questions

By admin | April 24, 2005


1. List the files in current directory sorted by size ? - ls -l | grep ^- | sort -nr
2. List the hidden files in current directory ? - ls -a1 | grep "^\."

3. Delete blank lines in a file ? - cat sample.txt | grep -v ‘^$’ > new_sample.txt

4. Search for a sample string in particular files ? - grep “Debug†*.confHere grep uses the
string “Debug†to search in all files with extension“.conf†under current
directory.

5. Display the last newly appending lines of a file during appendingdata to the same file by some
processes ? - tail –f Debug.logHere tail shows the newly appended data into Debug.log by some
processes/user.

6. Display the Disk Usage of file sizes under each directory in currentDirectory ? - du -k * | sort Ã
¢â‚¬â€œnr (or) du –k . | sort -nr
7. Change to a directory, which is having very long name ? - cd CDMA_3X_GEN*Here original
directory name is – “CDMA_3X_GENERATION_DATA†.

8. Display the all files recursively with path under current directory ? - find . -depth -print

9. Set the Display automatically for the current new user ? - export DISPLAY=`eval ‘who am i | cut
-d"(" -f2 | cut -d")" -f1′`Here in above command, see single quote, double quote, grave ascent is used.
Observe carefully.

10.Display the processes, which are running under yourusername ? - ps –aef | grep
MaheshvjHere, Maheshvj is the username.

11. List some Hot Keys for bash shell ? - Ctrl+l – Clears the Screen. Ctrl+r – Does a
search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a Ã
¢â‚¬â€œ Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the
end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently
running process into background.

12. Display the files in the directory by file size ? - ls –ltr | sort –nr –k 5

13. How to save man pages to a file ? - man <command> | col –b > <output-file>Example : man
top | col –b > top_help.txt

14. How to know the date & time for – when script is executed ? - Add the following script
line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, “timeinfo.infÃ
¢â‚¬Â contains date & time details ie., when script is executed and history related to execution.

15. How do you find out drive statistics ? - iostat -E

16. Display disk usage in Kilobytes ? - du -k

17. Display top ten largest files/directories ? - du -sk * | sort -nr | head

18. How much space is used for users in kilobytes ? - quot -af

19. How to create null file ? - cat /dev/null > filename1

20. Access common commands quicker ? - ps -ef | grep -i $@

21. Display the page size of memory ? - pagesize -a

22.Display Ethernet Address arp table ? - arp -a

23.Display the no.of active established connections to localhost ? - netstat -a | grep EST

24.Display the state of interfaces used for TCP/IP traffice ? - netstat -i

25.Display the parent/child tree of a process ? - ptree <pid> Example: ptree 1267

26.Show the working directory of a process ? - pwdx <pid> Example: pwdx 1267

27.Display the processes current open files ? - pfiles <pid> Example: pfiles 1267

28. Display the inter-process communication facility status ? - ipcs

29.Display the top most process utilizing most CPU ? - top –b 1

30. Alternative for top command ? - prstat -a

6 Coll Interview:
Partition sizes can be set
View
manually or from what
Answer
configuration?

what command do you run after modifying the aliases file


View
make the chages active ? how do enable logging on a UFS
Answer
filesystem?

What is the difference between a probe-scsi and a probe-scsi- View


all? Answer

What field will cause the message Your password has expired to View
be displayed to the user? Answer

View
How many cpus we can connect to a spark machine in Solaris?
Answer

View
Search for a sample string in particular files?
Answer

View
Explain about kadmin command?
Answer

View
What command enables a printer?
Answer

Which of the following can be an appropriate name for a View


cluster? Answer

What would a XIR signal do to a server and why would it be View


used? Answer

Display the last newly appending lines of a file during View


appendingdata to the same file by some processes ? Answer

View
Explain about the command ls?
Answer

View
What is sticky bit?
Answer

What file controls global variables for system wide values for View
the Bourne Shell? Answer

View
What is after the VTOC on the root filesystem?
Answer

In order to save a template in /etc/format.dat, what two steps View


must occur? Answer

What flag used with patchadd will prevent a later back out by
View
preventing patchadd from backing up files? If this flag is used,
Answer
the patch cannot be removed.

How to restore a corrupted file system or trouble shoot bad View


super blocks for a FS c0t2d0s5 Answer

How would you find out what version of Solaris is currently View
running? Answer

What is difference between Process and Daemon in Solaris?

You might also like