Commands Unix


solaris commands


1. /usr/bin/uname – display current OS name, versin, Architecture

2. /usr/bin/uptime – Display how long the system has been up

3. /usr/bin/prtconf – Displays out detailed hardware info.

4. /usr/bin/prstat – Display active process statistics with the top process taking the most resource.

5. /usr/platform/sun4u/sbin/prtdiag – Displays very detailes hardware info such as CPU speed, CPU chache and on what slots memory chips is installed.

6. /usr/bin/showrev – displays machine and software version info.

7. /usr/bin/w – display info on currently logged on users.

8. Adding users –
#useradd -d /export/home/username -m -s /bin/ksh
the -m option tells the useradd command to automatically create the home directory.
NOte: do not store user directory in /home as this directory is used by solaris automounter. the automountwer gives the user to login to many machines and automatically ahve their home directories mounted on that machines /home area.

9. to delete users. – /usr/bin/userdel
for eg. userdel -r – will delete the users home directory as well.

10. psrinfo -v – processor info.

11. netstat -rn – show the routing table.

12. ifconfig -a – show the network iface info.

13. explorer output
/opt/SUNWexplo/bin/explorer – it is an executable file used to generate the explorer output
/opt/SUNWexplo/etc/ – directory contains the explorer tar files.

14. passwd -sa — for checking all system users password.

Network Configuration in Solaris.
1. to set the machine’s name – /etc/nodename

2. using DNS edit: /etc/nsswitch.conf – look for line that starts with “hosts:”
add “dns” to the end of the line.
you can add the “dns” entry to the very beginning of the line, which changes the order in which solaris will do the name lookups. for eg. if you have “nis” before “dns” it will check in nis database first and try to resolve it from there and if you have files before dns it will look in the /etc/hosts files before it look in dns.

3. adding entries in /etc/resolv.conf
file: /etc/resolv.conf
nameserver ns1
nameserver ns2

4. adding machines info in /etc/hosts file.
ipaddr hostame

5. edit the following files.

6. editing the interface name files.
sun systems can have multiple network cards, and each of those cards answer to a different hostname you may also have to edit a file to assign the hostname to the main network card.. you may want a single server to respond to many hostnames. the main network interface is mainly “hme0”.
to edit interface: /etc/hostname-interface

7. to edit netmask.
###Exporting Display
##logging on server A using VNC.
1.ssh server B
2.xhost server B
3.export display server A:1.0

##for automatic color schemes.
ls –color=auto

##for time styling
ls –time-style=+%d-%m-%y\&H%M

##adding alias in .profile
alias variable=”alias name”
here “alias name” refers to any command which can be used in conjugtion.

##to show all the hidden files in one directory.
ls -d .*

##to remove empty lines using sed.
sed `/^$/d’

##password aging script in linux if chage is not working.
chage -l usernaem – most appropriate condition.
login as root.
grep the users in /etc/passwd file using:
#cut -d: -f1 /etc/passwd
#while read line do
#chage -l $users | grep “password expires” and line
#disply $users- your password will expire on

###Configuring Network.
##adding net up on command line.
#ifconfig eth0 netmask brodcast up

##adding the default gateway.
#route add default gw

##add the nameserver entries.
file: /etc/resolv.conf

#nmblookup -A -d1
#smblookup -LBC8 -I -U knopix % -w workcener name -d3

AIX commands.
#lscfg -vp | grep -p Cabinet — to check the cabinet no. on IBM/AIX

#lsdev -Cc Tape — to list the tape devices.

#rmdev -dl /dev/rmt0 — to delete rmt0 device.

#cfgmgr -v — reread the system hardware components and if iut finds any new thing. it will configure it accordingly.

#lsdev -Cc Tape — configure the tape drive.

#cfgmgr — same as above

#cat /etc/exclude.rootvg — filesystems to exclude while taking complete system backup.

#lsvg -l rootvg — list the volumme group called as rootvg

#smit mksysb — the smit interface to take the system backup

#tail smit.log — tail the log files to see smit is working fine.

#tctl -f /dev/rmt0 rewoffl -eject — this will rewind the tape and will eject the tape device.

#restore -tvf /dev/rmt0 — to list the contents of the tape device

#find ./log ./out -print | backup -ivf /dev/rmt0 | tee /tmp/log — to take backup of some files from ./log and ./out directory on tape device rmt0 while logging and printing the output on the screen.

#restore -xqdvf /dev/rmt0 — restoring the complete backup on the harddisk directory. the command must be fired from the parent directory to avoid confusions in where to restore dir. name.

########Grub.conf — How it works
####Manually loading through the bootloader.

###This will boot the windows partition.
rootnoverify (hd0,0)
chainloader +1

###booting linux fron /dev/hda3 device
root (hd0,2)
kernel /boot/vmlinuz root=/dev/hda3 -s
initrd /boot/initrd


1. ps -aef | grep pmon -> to check orcale instances running.
2. sqlplus /as sysdba
3. shutdown immediately
4. exit
5. ps -aef | grep ora
6. ps -aef | grep tltns
10. kill -9 ora9ibrn

### copies a single 1024 block from /dev/zero(a continuous stream of zero bytes) to the file new file.
dd if=/dev/zero of=new_file bs=1024 count=1

iostat -En will show the devices like c0t0d0.
product :- the last line gives the size of the disk
mount -F hsfs /dev/dsk/c0t0d0s0 /mnt

To see all of the slices on all of the disks the easiest thing is:
prtvtoc /dev/rdsk/*s2
To see all disks do this:
format /dev/null 2>&1 redirecting the cron log to /dev/null
hwclock –systohc sync date with hwclock

df -g |awk ‘{print $1}’
df -g |awk ‘{print $7}’
df -g |awk ‘{print $4}’

To Change the username and home permission of a user
groupmod -n sysadmin santosh
usermod -d /home/sysadmin -m -g sysadmin -l sysadmin santosh

vncserver -kill :1

psrinfo will give number of cpus in Sun Solar

OGL Backup
cd /oraapps/oracle/prodcomn/admin

# find ./out ./log print | backup ivf /dev/rmtn

pscp.exe -pw ‘password’ “local machine path” [email protected]:/path/to/home/

df -g refresh
while :^Jdo^Jdf -g /kcf1dr /kcfdrvg^Jsleep 2^Jclear^Jdone

stopping one spd device
setsp -T -l3

3 is SPD number.

tip -9600 /dev/ttya
tip -9600 /dev/ttyb

changing users unsuccessful login attempt using sudo
sudo chsec -f /etc/security/lastlog -s username -a unsuccessful_login_count=0

mount -t ext3 -o acl

give rwx privileges to a user which does not belong to the group
setfacl -m u:prod:rwx test
checked the privileges using

getfacl -a test

opensssl rand -base64 6
Restoration of backup
# restore -xdvgf /dev/rmtn
n-> no. of the tape drive attached.

To rewind and ejject the tape
# tctl -f /dev/rmtn rewoffl

To list the contents of the tape drive
# restore -Tl -vf /dev/rmt0

To check user account status like locked, unlocked and when the password expires etc.. use

passwd -s username

Chage -l username

Linux ubuntu

Building DVD Images Of Ubuntu Repositories

1 Preliminary Note

This tutorial was inspired by an articles I read at So many thanks to Ramon Acedo (the one who made this HowTo, originally)

The pages are not reachable from some weeks, now. I saved the page to read it off-line. So…

I found it useful. I hope it will be the same for you.

2 Introduction

This howto offers a simple way of creating DVD images of Debian or Ubuntu http/ftp repositories.

Ubuntu doesn’t offer DVDs ready to download with its main, universe, multiverse and/or restricted repositories. With the contents of this howto you can do it yourself.

Having the Ubuntu or Debian repositories on DVD can be useful for those users who don’t have access to the Internet where they have their Ubuntu installed but have access somewhere else to download the repository and build and burn the DVDs.

3 Building a local mirror

We have to install debmirror:

sudo apt-get install debmirror

Now we get the Ubuntu repositories in a local directory. In the example below we get main, universe and multiverse sections of the repository in the i386 architecture.

debmirror –nosource -m –passive – –root=ubuntu/ –method=ftp –progress –dist=dapper –section=main,multiverse,universe –arch=i386 ubuntu/ –ignore-release-gpg

You could change the options below as you prefer:

  • –host – the URL of the repository.
  • –dist – the distro of your OS (dapper, edgy, sarge, … ).
  • –section – the section you want to mirror locally.
  • –arch – the architecture of your box.

4 Separating the archive into DVD-sized directories

The repositories we got are too big (about 30Gb) to burn them to a DVD so we have to separate them into volumes.

The tool debpartial will do it for us.

sudo apt-get install debpartial

We make the directory where the volumes will reside.

mkdir ubuntu-dvd

and we make it to construct the package descriptors to every volume.

debpartial –nosource –dirprefix=ubuntu –section=main,universe,multiverse –dist=dapper –size=DVD ubuntu/ ubuntu-dvd/

Now we have to put the packages into the directories debpartial has just created. The script debcopy which also comes with the debpartial package will do it. The script needs ruby.

sudo apt-get install ruby

If everything is ok…

ruby debcopy ubuntu/ ubuntu-dvd/ubuntu0
ruby debcopy ubuntu/ ubuntu-dvd/ubuntu1
ruby debcopy ubuntu/ ubuntu-dvd/ubuntu2

Where ubuntu/ is the directory with the complete repository created with debmirror and ubuntu-dvd/* are the directories ready to host the new DVD-ready repository.
If we want to make soft links from the complete repository instead of copying the packages we can call debcopy with the option -l:

ruby -l debcopy ubuntu/ ubuntu-dvd/ubuntu0
ruby -l debcopy ubuntu/ ubuntu-dvd/ubuntu1
ruby -l debcopy ubuntu/ ubuntu-dvd/ubuntu2

Now every directory (ubuntu0, ubuntu1 and ubuntu2) fits on one DVD.

5 Making iso images

To get the directories ubuntu0, ubuntu1, ubuntu2 into an iso image ready to burn we can use mkisofs:

mkisofs -f -J -r -o ubuntu-dvd-0.iso ubuntu-dvd/ubuntu0
mkisofs -f -J -r -o ubuntu-dvd-1.iso ubuntu-dvd/ubuntu1
mkisofs -f -J -r -o ubuntu-dvd-2.iso ubuntu-dvd/ubuntu2

Now you can burn the iso images or mount them. Add them to the /etc/apt/source.list with the command:

sudo apt-cdrom add

Now we can verify the new repositories…

sudo apt-get update
sudo apt-get upgrade

… and, if I explain in the right way, you should have your box upgraded.

6 About the script ‘debcopy’

I heard about someone who can not find the script debcopy, above described.
In that case, create a new file called debcopy where you want:

gedit /your_path_to/debcopy

and copy the lines below inside it:

# debcopy - Debian Packages/Sources partial copy tool
# Usage: debcopy [-l]  
#  where  is a top directory of a debian archive,
#  and  is a top directory of a new debian partial archive.
#  debcopy searches all Packages.gz and Sources.gz under /dists
#  and copies all files listed in the Packages.gz and Sources.gz
#  files into  from . -l creates symbolic links
#  instead of copying files.
# Copyright (C) 2002  Masato Taruishi 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  GNU General Public License for more details.
#  You should have received a copy of the GNU General Public License with
#  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;
#  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
#  Suite 330, Boston, MA  02111-1307  USA
require 'getoptlong'
require 'zlib'
require 'ftools'
$link = false
def usage
  $stderr.puts "Usage: #{__FILE__} [-l]  "
   exit 1
def each (file, &block)
  fin =
  fin.each do |line|
    yield line
def each_file (file, &block)
  each(file) do |line|
    if /Filename: (.*)/ =~ line
      yield $1
def each_sourcefile (file, &block)
  dir = nil
  each(file) do |line|
    case line
    when /^Directory: (.*)$/
      dir = $1
    when /^ \S+ \d+ (\S+)$/
      yield dir + "/" + $1
def calc_relpath (source, dest)
  pwd = Dir::pwd
  Dir::chdir source
  source = Dir::pwd
  Dir::chdir pwd
  Dir::chdir dest
  dest = Dir::pwd
  Dir::chdir pwd
  src_ary = source.split("/")
  dest_ary = dest.split("/")
  return dest if src_ary[0] != dest_ary[0]
  src_ary.clone.each_index do |i|
    break if src_ary[0] != dest_ary[0]
  src_ary.size.times do |i|
def do_copy(path)
  if $link
    pwd=calc_relpath(File.dirname($dest_dir + "/" + path), $source_dir)
    File.symlink(pwd + "/" + path, $dest_dir + "/" + path)
    File.copy($source_dir + "/" + path, $dest_dir + "/" + path)
def copy(path)
  s=$source_dir + "/" + path
  d=$dest_dir + "/" + path
  if FileTest.exist?(d)
    $stats["ignore"] += 1
  if FileTest.exist?(s)
    $stats["copy"] += 1
    $stats["notfound"] += 1
    $stderr.puts s + " not found."
opts =["--symlink", "-l", GetoptLong::NO_ARGUMENT],
		      ["--help", "-h", GetoptLong::NO_ARGUMENT])
opts.each do |opt,arg|
  case opt
  when "--symlink"
    $link = true
  when "--help"
usage if ARGV.size != 2
$source_dir = ARGV.shift
$dest_dir = ARGV.shift
if $link
  $source_dir = Dir::pwd + "/" + $source_dir unless $source_dir =~ /\A\//
  $dest_dir = Dir::pwd + "/" + $dest_dir unless $dest_dir =~ /\A\//
$stats = {}
$stats["ignore"] = 0
$stats["copy"] = 0
$stats["notfound"] = 0
open("|find #{$dest_dir}/dists -name Packages.gz") do |o|
  o.each_line do |file|
    print "Processing #{file}... "
    each_file(file) do |path|
    puts "done"
open("|find #{$dest_dir}/dists -name Sources.gz") do |o|
  o.each_line do |file|
    print "Processing #{file}... "
    each_sourcefile(file.chomp) do |path|
    puts "done"
puts "Number of Copied Files: " + $stats["copy"].to_s
puts "Number of Ignored Files: " + $stats["ignore"].to_s
puts "Number of Non-existence File: " + $stats["notfound"].to_s

How to turn on rsh and rlogin on RedHat Enterprise Linux (RHEL 2.1/ 3.0)

Enable them:

Turn on these three using chkconfig on both the nodes: rexec, rsh and rlogin.

# chkconfig rexec on
# chkconfig rsh on
# chkconfig rlogin on


Restart xinetd to be sure.

# service xinetd restart


On hostA’s root home directory (usually /root), create a .rhosts file, which has hostB in it.

# cat .rhosts

Similarly, create a .rhosts on hostB’s root home directory which has hostA in it.

# cat .rhosts


Now, edit /etc/hosts.allow on hostA:

# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
ALL : hostB

Edit /etc/hosts.allow on hostB:

# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
ALL : hostA


Edit /etc/hosts.equiv on hostA to have

# cat /etc/hosts.equiv

Edit /etc/hosts.equiv on hostB to have

# cat /etc/hosts.equiv


And finally, knock off /etc/securetty (rename it or worse, purge it) on both hostA and hostB

Now you are good to go.

Disclaimer: Use at your own risk. Don’t flame me. It sure worked for me. Actual results may vary. Use ssh in place of rlogin/rsh/telnet and the like, as ssh is more secure.


Fail Login Configuration

1. Open the /etc/pam.d/system-auth file for editing.
ensure that a backup done for the file which you are editing.

2. Add the following lines:

auth required no_magic_root
account required deny=2 no_magic_root

here the value of deny implies how many login attempts should faillog wait before locking the account for login.

3. Save the file and exit.
4. Test the configuration by attempting to login as a normal user, but using a wrong password.
5. Verify the failed count increments by running the command:

faillog -u
6. To disable faillog for one particular user faillog -m -1 -u username