Wednesday 22 February 2012

Solaris - Useful commands

This page will grow as I find commands that are useful........

Creating:

Create a group:
# groupadd -g 100 appsup
(Creates a group called appsup with a group ID number of 100)

Check user account:
# cat /etc/passwd

Create a new user:
# useradd - u 1000 -g 100 -d /export/home/newuser -s /usr/bin/bash -c "A new user" -m newuser
(Add a new user with the user ID of 1000, belonging to the group 100, with a home area /export/home/newuser, the default shell of bash, a account description of "A new user", with a username of newuser.

Changing a user account password
# passwd newuser
You will then be prompted to enter a new password, twice.

Changing ownership user and group ownership of a folder:
# chgrp dba /<folder>
# chown dbauser /<folder>

Queries:

To check RAM:
# prtconf -v
OR
# prtconf | head -3 |grep Mem

Check number of CPUs
# psrinfo -vp

Directory size query:
# du -hks /directory1/directory2


To check the version of Solaris:
# cat /etc/release

To check the run level:
# who -r

Check groups:
# cat /etc/groups

Mount Points: 

Creating a NFS mount point:
# mkdir /mp
# mount -F nfs <nfs-server-name>:/vol/mount_point /mp


Mounting and Unmounting an ISO

Mounting:
# mkdir /dvd
# mount -F hsfs -o ro `lofiadm -a /mp/sol-10-u10-ga2-sparc-dvd.iso` /dvd
(All credit for this one goes to http://www.tech-recipes.com/rx/218/mount-an-iso-image-on-a-solaris-filesystem-with-lofiadm/)

Unmounting:
# umount /mnt
# lofiadm -d /<dir>/sol-10-u10-ga2-sparc-dvd.iso

Mounting USB drive

Check that the volfs services are running
# svcs -a | grep volfs
or
# svcs volfs
If the service is enabled then carry on, if not then enable the service
# svcadm enable volfs
Plug in the device
Check that it is mounted
# mount
/rmdisk/unnamed_rmdisk on /vol/dev/dsk/c9t0d0/unnamed_rmdisk:c read/write/setuid/devices/rstchown/hidden/nofoldcase/noatime/timezone=0/dev=16c1003 on Wed Sep 26 12:55:43 2012
Another check (media)
# volcheck -v
media was found


Dismounting USB drives

Check if anything is mounted
# mount
On the system I was using it popped up as
# /rmdisk/unnamed_rmdisk on /vol/dev/dsk/c9t0d0/unnamed_rmdisk:c read/write/setuid/devices/rstchown/hidden/nofoldcase/noatime/timezone=0/dev=16c1003 on Wed Sep 26 12:55:43 2012
Unmount the device
# umount /rmdisk/unnamed_rmdisk
Check media
# volcheck -v 
no media was found

Dismounting a local DVD drive


# cd / (make sure you not in the DVD path)
# umount /cdrom/cdrom0
# eject

Finding files

Finding files (search for a file in the current directory and below):
# find . -type f -name 'explorer'

Finding files (search for a file at the root level and below):
# find / -type f -name 'explorer'

Finding files (search for a file in the /etc directory):
# find /etc -type f -name 'explorer'

Jumpstart - OS install command

Get to the <ok> prompt and type the following:
# <ok> boot net - install


Logical Domains


Check version of LDOM
# pkginfo -l SUNWldm

No comments:

Post a Comment