KEMBAR78
Solaris basics | PDF
Prepared by – ashwinwriter@gmail.com
What is Solaris?



"Solaris" is Sun Microsystems' version of Unix Operating System, based on AT&T's System V Unix,
with a lot more features and improvements. Over the years, it has been one of the most popular
UNIX environments being used at the enterprise level.



Learning Solaris, as of learning any other flavour of UNIX, seems a daunting task for a beginner,
because of its unfriendly and cryptic commands and not knowing where to look in case some help is
needed. The best way to start learning Solaris (or any UNIX or Linux for that matter) is to understand
the principles or philosophy behind its design. Once that is understood, you can see its elegance,
power and versatility. Then understand the basic concepts, commands and tools that give you the
confidence in using Solaris. With this foundation, you can move on to learn intermediate and
advanced level commands and concepts.




Simple commands:

1. Check the process:

# ps -ef | grep 'processname'
ex-http, httpd etc.



2. check the disk space:

# df -h

3. check the OS version:

# uname -r , uname -a

4. Detec hardware problems:

# fmadm faulty

5. Add user:

# useradd name


6. Set password:

# passwd name
7. Using swat

http://localhost:901



8. make directory:

# mkdir /share (share is the name of the directory)



9.Change the owner of file to user

# chown user file



10. Change file's owner to user and group to group

#chown user.group file

Note: chown can only be used by root.




11. chomod commands:

chmod g+r file Allow group to read

chmod u+w file Allow user to write

chmod a+x file Allow everyone (user, group, and other) to execute

chmod o-r file Disallow others to read

chmod ug+r file Disallow others to read

chmod g+w,o-r file Allow group write, disallow other read

chmod u=rw file Set user permissions to read and write.




Add up the values for the rights required.

r 4

w 2

x 1
For example: converting rwxr-x--- to octal:

7 = 4+2+1 = r + w + x

5 = 4+1 = r + x (not write)

0 = no rights

So rwxr-x--- is 750 in octal




12. What is the sticky bit's purpose?

The sticky bit has a different meaning, depending on the type of file it is set on:

# sticky bit on regular files:

If an executable file is prepared for sharing, mode bit (-t) prevents the system from abandoning the swap-space image of
the program-text portion of the file when its last user terminates. Then, when the next user of the file executes it, the text
need not be read from the file system but can simply be swapped in, thus saving time.




# Sticky bit for network files:

Local paging. When applications are located remotely, set the "sticky bit “on the applications binaries, using the chmod +t
command. This tells the system to page the text to the local disk. Otherwise, it is "retrieved" across the network.




#The most common use of the sticky bit today:

The most common use of the sticky bit today is on directories, where, when set, items inside the directory can be renamed
or deleted only by the item's owner, the directory's owner, or the superuser. (Without the sticky bit set, a user with write
and execute permissions for the directory can rename or delete any file inside, regardless of the file's owner.)




Frequently this is set on the /tmp directory to prevent ordinary users from deleting or moving other users' files.

#chmod +t directory Set the sticky bit on a directory

#chmod -t directory Remove the sticky bit from a directory




13.Delete a file.

# rm /directory/file-to-be-deleted



14. To change the modification time of a file (the time displayed in a long listing of the file) of a file
called testfile to November 18, 2000, 2:30 PM, use the following command:

# touch -t 200011181430
15.find out ethernet interface name.

# inconfig -a




16. In most UNIX systems, startup scripts in /etc/rc3.d, etc, are used to start and stop services.
Solaris 10 uses a different approach.

There are two advantages to the Solaris 10 method:

The system can come up faster, because startup of various systems can be done in parallel. The system knows more about
what is going on. It can monitor processes and restart them. Services are managed by svcadm. The most common
commands are :

With Solaris 10, general purpose SMF CLI tools (such as svcadm and svcs):

# svcadm enable SERVICE

# svcadm disable SERVICE

# svcadm restart SERVICE

# svcadm refresh SERVICE




To look at services, two common commands are

svcs {lists summary of all}

svcs -l SERVICE {details on one service}




17.Enable Firewall (Ipfilter)

#svcadm enable network/ipfilter



18. SHELL COMMANDS:

Shell Commands

Most commands default to using the current directory.

pwd show the current directory, eg "pwd" may print "/home/kim"

cd change current directory, with no arguments will change to your home directory

ls shows files in current directory

ls foo shows files in directory "foo" or the file "foo"

ls *.html shows files in the current directory ending in .html

ls -l shows details of files
ls -a show all files, including files beginning with "."

tree -d show directory structure

less display a file on screen

man where to find help on any command

mount show all file systems currently mounted, or add a file system to the tree, eg "mount -t vfat /dev/fd0 /floppy

umount un mount a file system, eg "umount /dev/fd0" or "umount /floppy"

id show which groups you belong to

chmod change permissions on files




19.umount un mount a file system,

#umount /dev/fd0 or umount /floppy



20. Show Free space:

# df -h show the free space on all file systems

# du -h show how much disk space each directory uses




21. Devices:

/dev/hda = First IDE disk (master device on first IDE channel) typically this is your hard disk

/dev/hdb = the slave device on the first IDE controller

/dev/hdc = the master device on the second IDE controller (typically your CDROM)




22. Change the owner of file to user

# chown user file




23. Groups in UNIX:

Name: eg users

Number (gid): eg 100, used internally by the kernel

Defined in /etc/group

audio:x:29:kim,jason
The columns in /etc/group are:

a.Group name, eg audio

b.Encrypted group password, or 'x' if the password hash is stored in /etc/gshadow

c.Group number (gid), eg 29

d.List of user name for people who are members of this group




24. Change file's group to group.

# chgrp group file




25. Add existing user pranab to group called km.

# usermod -G km pranab




26.Delete the group:

# groupdel groupname




27. Rename group:

#groupmod -n newgroup oldgroup




These were some of very basic commands to get started, but it takes a lot of dedication and practice
to master the art of managing UNIX like operating systems.

Solaris basics

  • 1.
    Prepared by –ashwinwriter@gmail.com
  • 2.
    What is Solaris? "Solaris"is Sun Microsystems' version of Unix Operating System, based on AT&T's System V Unix, with a lot more features and improvements. Over the years, it has been one of the most popular UNIX environments being used at the enterprise level. Learning Solaris, as of learning any other flavour of UNIX, seems a daunting task for a beginner, because of its unfriendly and cryptic commands and not knowing where to look in case some help is needed. The best way to start learning Solaris (or any UNIX or Linux for that matter) is to understand the principles or philosophy behind its design. Once that is understood, you can see its elegance, power and versatility. Then understand the basic concepts, commands and tools that give you the confidence in using Solaris. With this foundation, you can move on to learn intermediate and advanced level commands and concepts. Simple commands: 1. Check the process: # ps -ef | grep 'processname' ex-http, httpd etc. 2. check the disk space: # df -h 3. check the OS version: # uname -r , uname -a 4. Detec hardware problems: # fmadm faulty 5. Add user: # useradd name 6. Set password: # passwd name
  • 3.
    7. Using swat http://localhost:901 8.make directory: # mkdir /share (share is the name of the directory) 9.Change the owner of file to user # chown user file 10. Change file's owner to user and group to group #chown user.group file Note: chown can only be used by root. 11. chomod commands: chmod g+r file Allow group to read chmod u+w file Allow user to write chmod a+x file Allow everyone (user, group, and other) to execute chmod o-r file Disallow others to read chmod ug+r file Disallow others to read chmod g+w,o-r file Allow group write, disallow other read chmod u=rw file Set user permissions to read and write. Add up the values for the rights required. r 4 w 2 x 1
  • 4.
    For example: convertingrwxr-x--- to octal: 7 = 4+2+1 = r + w + x 5 = 4+1 = r + x (not write) 0 = no rights So rwxr-x--- is 750 in octal 12. What is the sticky bit's purpose? The sticky bit has a different meaning, depending on the type of file it is set on: # sticky bit on regular files: If an executable file is prepared for sharing, mode bit (-t) prevents the system from abandoning the swap-space image of the program-text portion of the file when its last user terminates. Then, when the next user of the file executes it, the text need not be read from the file system but can simply be swapped in, thus saving time. # Sticky bit for network files: Local paging. When applications are located remotely, set the "sticky bit “on the applications binaries, using the chmod +t command. This tells the system to page the text to the local disk. Otherwise, it is "retrieved" across the network. #The most common use of the sticky bit today: The most common use of the sticky bit today is on directories, where, when set, items inside the directory can be renamed or deleted only by the item's owner, the directory's owner, or the superuser. (Without the sticky bit set, a user with write and execute permissions for the directory can rename or delete any file inside, regardless of the file's owner.) Frequently this is set on the /tmp directory to prevent ordinary users from deleting or moving other users' files. #chmod +t directory Set the sticky bit on a directory #chmod -t directory Remove the sticky bit from a directory 13.Delete a file. # rm /directory/file-to-be-deleted 14. To change the modification time of a file (the time displayed in a long listing of the file) of a file called testfile to November 18, 2000, 2:30 PM, use the following command: # touch -t 200011181430
  • 5.
    15.find out ethernetinterface name. # inconfig -a 16. In most UNIX systems, startup scripts in /etc/rc3.d, etc, are used to start and stop services. Solaris 10 uses a different approach. There are two advantages to the Solaris 10 method: The system can come up faster, because startup of various systems can be done in parallel. The system knows more about what is going on. It can monitor processes and restart them. Services are managed by svcadm. The most common commands are : With Solaris 10, general purpose SMF CLI tools (such as svcadm and svcs): # svcadm enable SERVICE # svcadm disable SERVICE # svcadm restart SERVICE # svcadm refresh SERVICE To look at services, two common commands are svcs {lists summary of all} svcs -l SERVICE {details on one service} 17.Enable Firewall (Ipfilter) #svcadm enable network/ipfilter 18. SHELL COMMANDS: Shell Commands Most commands default to using the current directory. pwd show the current directory, eg "pwd" may print "/home/kim" cd change current directory, with no arguments will change to your home directory ls shows files in current directory ls foo shows files in directory "foo" or the file "foo" ls *.html shows files in the current directory ending in .html ls -l shows details of files
  • 6.
    ls -a showall files, including files beginning with "." tree -d show directory structure less display a file on screen man where to find help on any command mount show all file systems currently mounted, or add a file system to the tree, eg "mount -t vfat /dev/fd0 /floppy umount un mount a file system, eg "umount /dev/fd0" or "umount /floppy" id show which groups you belong to chmod change permissions on files 19.umount un mount a file system, #umount /dev/fd0 or umount /floppy 20. Show Free space: # df -h show the free space on all file systems # du -h show how much disk space each directory uses 21. Devices: /dev/hda = First IDE disk (master device on first IDE channel) typically this is your hard disk /dev/hdb = the slave device on the first IDE controller /dev/hdc = the master device on the second IDE controller (typically your CDROM) 22. Change the owner of file to user # chown user file 23. Groups in UNIX: Name: eg users Number (gid): eg 100, used internally by the kernel Defined in /etc/group audio:x:29:kim,jason
  • 7.
    The columns in/etc/group are: a.Group name, eg audio b.Encrypted group password, or 'x' if the password hash is stored in /etc/gshadow c.Group number (gid), eg 29 d.List of user name for people who are members of this group 24. Change file's group to group. # chgrp group file 25. Add existing user pranab to group called km. # usermod -G km pranab 26.Delete the group: # groupdel groupname 27. Rename group: #groupmod -n newgroup oldgroup These were some of very basic commands to get started, but it takes a lot of dedication and practice to master the art of managing UNIX like operating systems.