Selasa, 10 Desember 2013

Change Logo on Nagios

you can change your nagios logo site application on your nagios server installed
just go to the "/usr/local/nagios/share/images"
the default main logo of nagios is file with name "sblogo.png"
if you don't want to complicated just put image with same size and replace "sblogo.png" with your new custom picture

Kamis, 07 November 2013

Solaris System Administrator Notes

ADD STATIC ROUTE IN UNIX SOLARIS
#route add net 28.133.0.0/18 172.24.105.1
-add the route accross reboot-
#vi /etc/rc2.d/S69static_routes

ODS

# metastat|grep -i maint
# metastat -p (to check the controller where metadevices are originally mounted)
# format (to check the current controller)
# metastat |grep -i replace (to check the metadevices to be replaced)
(and then do the replacement)
# metareplace d0 c2t0d0s0 c1t0d0s0 (note that c1 is the new controller)
# metadb -a -c3 /dev/dsk/c1t0d0s3 (create meta database for the new controller c1)
# metastat | grep resync
# while true
>do
>metastat | grep resync
>sleep 1
>done


RSH

Enable rsh in Solaris 10
# svcadm enable svc:/network/login:rlogin
# svcadm enable svc:/network/login:rlogin

Enable rsh in solaris 8
# vi /etc/inetd.conf
- uncomment
shell stream tcp nowait root /usr/sbin/in.rshd in.rshd
- restart inetd daemon
# pkill -HUP inetd

AUTOFS

- check the files /etc/auto_master and /etc/auto.dumps file
- once changes made, u need to do 'automount -v' to pickup the config files
- on the client share the filesystem
# share -F nfs -o ro /dumps
- edit /etc/dfs/dfstab
# share -F nfs -o ro /dumps
- restart nfs
# svcadm restart nfs/server
# dfshares or exportfs (to verify nfs shares)

NFS

- mount the dir
# mount -F nfs hkgfiler2:/remedy /opt/ar/directa

- edit /etc/vfstab to mount it upon boot up
hkgfiler2:/remedy - /opt/ar/directa nfs yes rw,soft



NTP

# svcadm disable ntp
# cp /etc/inet/ntp.client /etc/inet/ntp.conf (and type-in ntp servers)
e.g.

server hkgba00001
server hkgba00002

#ntpdate -d
#svcadm enable svc:/network/ntp

DU

Check for Top directory users
# du -sk /export/home/* | sort –nr

TAR

Un-tar tar.gz file IN SOLARIS
gunzip -c file_name.tar.gz |tar xvf –
or

# gzip -d snap_sol10.tar.gz
# tar xf snap_sol10.tar


Create tar file
tar cvf dir.tar

Create create .gz
#gzip dir.tar


HBA

Check HBA info:
# fcinfo hba-port

NIC

Check network interface
# cat /etc/path_to_inst
# grep bge path_to_inst
"/pci@1f,700000/network@2" 0 "bge"
"/pci@1f,700000/network@2,1" 1 "bge"
"/pci@1d,700000/network@2" 2 "bge"
"/pci@1d,700000/network@2,1" 3 "bge"

Change network interface to auto neg “on”
# vi /platform/sun4u/kernel/drv/bge.conf

Check for network collision
# netstat –i

EEPROM

Disable system check during reboot
# eeprom diag-switch? False


PKGADD

To add a package
# pkgadd –d .

REXEC

Disable rexec in Solaris 8
# vi /etc/inetd.conf
- comment out
exec stream tcp nowait root /usr/sbin/tcpd in.rexecd
exec stream tcp6 nowait root /usr/sbin/tcpd in.rexecd

- then restart inetd daemon
# pkill -HUP inetd

SWAP

- create local swap area - in kilobytes(k), blocks(b) or megabytes (m)
# mkfile 1024m /new_swap (create 1GB swap)
- activate the swap area
# swap –a /new_swap
- verify
# swap –l

LOCALE

- set system-wide locale
# vi /etc/TIMEZONE

- set user locale
# vi .profile

LVM (Logical Volume Management)

- install lvm software
- partition disks
# fdisk partition (e.g. /dev/sdb1)

- create physical volumes
# pvcreate /dev/sdb1
# pvcreate /dev/sdc1
# pvcreate /dev/sdd1
# pvscan

- create volume group and make it available
# vgcreate /dev/sdb1 /dev/sdc1 /dev/sdd1
# vgchange –a y
# vgdisplay
# lvcreate –-size 3493G –-name
# lvdisplay
# mount /dev/

- rename a logical volume group
# vgdisplay –v
# vgchange –a n /dev/
# vgrename /dev/ /dev/
# vgchange –a y /dev/
# vgdisplay –v
# vgdisplay –v ext

- rename a logical volume
# lvdisplay /dev/ext/
# lvrename /dev/ext/ /dev/ext/
# lvdisplay /dev/ext/

- make a filesystem on the disk
# mkfs.xfs –f /dev/fhome/fanhome
# mount /dev/fhome/fanhome /home
# mount –t xfs /dev/ext/nfsdata /mnt

- add a new drive to a volume group
# vgdisplay –v (check active disks)
# fdisk to create partition
# umount /bak/backups (filesystem to extend)
# pvcreate /dev/sdf1 (prepare new partition)
# vgextend bak /dev/sdf1
# lvresize –-size 5.999T /dev/shome/home (increase size)
# mount /dev/bak/backups /bak/backups
# xfs_growfs /bak/backups


ERROR/s Encountered

Error: SOLARIS box running slow

Resolution:
# mpstat 5 5 (check usr,sys usage)
# prstat -s cpu -n 5 (list by cpu usage and top 5 processes)
# prstat -s cpu -a -n 5 (list usage per user)


Error: Veritas config daemon vxconfigd not running

Resolution:
# modinfo|grep vx
If DMP is enabled the /etc/system will have the force load entries and the driver "vxdmp"
# grep vxdmp /etc/system
forceload: drv/vxdmp

# vxdctl mode
mode: enabled

Next, run vxinstall or do a vxconfigd -k -m enable

Error: Timed out while waiting for NIS to come up

Resolution:

- logon to console
- do a “send brk” to get to “ok prompt”
- boot to single user mode
Ok> boot –s
- temporarily disable RPC service or remove /etc/defaultdomain to prevent NIS from starting at system boot
# mv /etc/rc2.d/S71rpc /etc/rc2.d/NOS71rpc or
# rm /etc/defaultdomain
# or exit to continue booting to default runlevel




Error: “Umount: I/O error” or “umount: cannot unmount /mount_point”

Resolution:

# fuser –c /file_system
# kill -9 process_id (from the above fuser command)
# lsof +D /file_system
# umount –f /file_system
# mount | grep /file_sytem

Error: No directory – logged on with (/) directory

Resolution:

- restart autofs
# /etc/init.d/autofs stop; /etc/init.d/autofs start
- re-login


Error: Media Error (hard disk with bad sectors)

Resolution:

# format
- select the disk to read test
> anal (select analyze)
> read 

Go to ok prompt from ILOM of Sun T5120

Follow below procedure to get to "ok" prompt from ILOM.

1. ssh to ILOM hostname


2. From the ILOM prompt , type the below.

--> set /HOST send_break_action=break

--> start /SP/console to get to the ok prompt.


Manual system reset from the ILOM prompt.

--> set /HOST/bootmode script="setenv auto-boot? false"

--> reset /SYS

Selasa, 29 Oktober 2013

Mount USB drive in SOLARIS 10

# rmformat
Looking for devices…
1. Logical Node: /dev/rdsk/c0t1d0p0
Physical Node: /pci@0,0/pci-ide@1f,1/ide@0/sd@1,0
Connected Device: HL-DT-ST DVDRAM GSA-H42N RL00
Device Type: DVD Reader/Writer
2. Logical Node: /dev/rdsk/c4t0d0p0
Physical Node: /pci@0,0/pci8086,d605@1d,7/storage@3/disk@0,0
Connected Device: C2931006 Flash Disk 5.00
Device Type: Removable
#mount -F pcfs /dev/dsk/c4t0d0p0:c /mnt/usb
Not that the device used in mount command is “/dev/dsk/c4t0d0p0″ and not “/dev/rdsk/c4t0d0p0″

c4t0d0p1:c” here the “:c” means Windows C Drive like access.

Sabtu, 13 Juli 2013

Howto upgrade from Centos 6.3 to Centos 6.4

Howto upgrade from Centos 6.3 to Centos 6.4

centos



We can upgrade from Centos 6.3 to Centos 6.4 by yum upgrade command.
1. Check current Centos version
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.3 (Final)
[root@localhost ~]#
2. Upgrade your server
[root@localhost ~]# yum upgrade
…………………………………………………
xorg-x11-drv-r128 x86_64 6.9.1-1.el6 base 49 k
xorg-x11-drv-rendition x86_64 4.2.5-2.el6 base 23 k
xorg-x11-drv-s3virge x86_64 1.10.6-2.el6 base 37 k
xorg-x11-drv-savage x86_64 2.3.6-2.el6 base 65 k
xorg-x11-drv-siliconmotion x86_64 1.7.7-2.el6 base 52 k
xorg-x11-drv-sis x86_64 0.10.7-2.el6 base 234 k
xorg-x11-drv-sisusb x86_64 0.9.6-2.el6 base 40 k
xorg-x11-drv-synaptics x86_64 1.6.2-11.el6 base 72 k
xorg-x11-drv-tdfx x86_64 1.4.5-2.el6 base 33 k
xorg-x11-drv-trident x86_64 1.3.6-4.el6 base 58 k
xorg-x11-drv-v4l x86_64 0.2.0-6.el6 base 14 k
xorg-x11-drv-vesa x86_64 2.3.2-4.el6 base 20 k
xorg-x11-drv-vmmouse x86_64 12.9.0-10.el6 base 17 k
xorg-x11-drv-vmware x86_64 12.0.2-3.20120718gite5ac80d8f.el6 base 30 k
xorg-x11-drv-void x86_64 1.4.0-3.el6 base 11 k
xorg-x11-drv-voodoo x86_64 1.2.5-3.el6 base 17 k
xorg-x11-drv-wacom x86_64 0.16.1-3.el6 base 236 k
xorg-x11-drv-xgi x86_64 1.6.0-18.20121114git.el6 base 117 k
xorg-x11-server-Xorg x86_64 1.13.0-11.el6.centos base 1.3 M
xorg-x11-server-common x86_64 1.13.0-11.el6.centos base 36 k
xorg-x11-server-utils x86_64 7.5-13.el6 base 159 k
xorg-x11-utils x86_64 7.5-6.el6 base 94 k
xorg-x11-xkb-utils x86_64 7.7-4.el6 base 86 k
xulrunner x86_64 17.0.3-2.el6.centos updates 14 M
yelp x86_64 2.28.1-17.el6_3 updates 813 k
yum noarch 3.2.29-40.el6.centos base 996 k
zlib x86_64 1.2.3-29.el6 base 73 k
Installing for dependencies:
device-mapper-persistent-data x86_64 0.1.4-1.el6 base 164 k
libreport-compat x86_64 2.0.9-15.el6.centos base 14 k
mesa-dri-filesystem x86_64 9.0-0.7.el6 base 44 k
mesa-dri1-drivers x86_64 7.11-8.el6 base 3.8 M
mtdev x86_64 1.1.2-5.el6 base 15 k
numactl x86_64 2.0.7-6.el6 base 69 k
samba-common x86_64 3.6.9-151.el6 base 10 M
samba-winbind x86_64 3.6.9-151.el6 base 2.2 M
xorg-x11-drv-modesetting x86_64 0.5.0-1.el6 base 21 kTransaction Summary
=====================================================================================================================================================================================================
Install 12 Package(s)
Upgrade 358 Package(s)
Total download size: 301 M
Is this ok [y/N]: y
………………………………………………………………………..
Installed:
kernel.x86_64 0:2.6.32-358.2.1.el6 kernel-devel.x86_64 0:2.6.32-358.2.1.el6 libjpeg-turbo.x86_64 0:1.2.1-1.el6
Dependency Installed:
device-mapper-persistent-data.x86_64 0:0.1.4-1.el6 libreport-compat.x86_64 0:2.0.9-15.el6.centos mesa-dri-filesystem.x86_64 0:9.0-0.7.el6 mesa-dri1-drivers.x86_64 0:7.11-8.el6
mtdev.x86_64 0:1.1.2-5.el6 numactl.x86_64 0:2.0.7-6.el6 samba-common.x86_64 0:3.6.9-151.el6 samba-winbind.x86_64 0:3.6.9-151.el6
xorg-x11-drv-modesetting.x86_64 0:0.5.0-1.el6
Updated:
NetworkManager.x86_64 1:0.8.1-43.el6 NetworkManager-glib.x86_64 1:0.8.1-43.el6 NetworkManager-gnome.x86_64 1:0.8.1-43.el6
ORBit2.x86_64 0:2.14.17-3.2.el6_3 PackageKit.x86_64 0:0.5.8-21.el6 PackageKit-device-rebind.x86_64 0:0.5.8-21.el6
PackageKit-glib.x86_64 0:0.5.8-21.el6 PackageKit-gstreamer-plugin.x86_64 0:0.5.8-21.el6 PackageKit-gtk-module.x86_64 0:0.5.8-21.el6
PackageKit-yum.x86_64 0:0.5.8-21.el6 PackageKit-yum-plugin.x86_64 0:0.5.8-21.el6 abrt.x86_64 0:2.0.8-15.el6.centos
abrt-addon-ccpp.x86_64 0:2.0.8-15.el6.centos abrt-addon-kerneloops.x86_64 0:2.0.8-15.el6.centos abrt-addon-python.x86_64 0:2.0.8-15.el6.centos
abrt-cli.x86_64 0:2.0.8-15.el6.centos abrt-libs.x86_64 0:2.0.8-15.el6.centos abrt-tui.x86_64 0:2.0.8-15.el6.centos
alsa-utils.x86_64 0:1.0.22-5.el6 authconfig.x86_64 0:6.1.12-13.el6 authconfig-gtk.x86_64 0:6.1.12-13.el6
automake.noarch 0:1.11.1-4.el6 avahi.x86_64 0:0.6.25-12.el6 avahi-autoipd.x86_64 0:0.6.25-12.el6
avahi-glib.x86_64 0:0.6.25-12.el6 avahi-libs.x86_64 0:0.6.25-12.el6 avahi-ui.x86_64 0:0.6.25-12.el6
bash.x86_64 0:4.1.2-14.el6 bfa-firmware.noarch 0:3.0.3.1-1.el6 bind.x86_64 32:9.8.2-0.17.rc1.el6.3
bind-libs.x86_64 32:9.8.2-0.17.rc1.el6.3 bind-utils.x86_64 32:9.8.2-0.17.rc1.el6.3 binutils.x86_64 0:2.20.51.0.2-5.36.el6
biosdevname.x86_64 0:0.4.1-3.el6 boost-filesystem.x86_64 0:1.41.0-15.el6_4 boost-system.x86_64 0:1.41.0-15.el6_4
bridge-utils.x86_64 0:1.2-10.el6 btparser.x86_64 0:0.17-1.el6 centos-release.x86_64 0:6-4.el6.centos.10
control-center.x86_64 1:2.28.1-38.el6 control-center-extra.x86_64 1:2.28.1-38.el6 control-center-filesystem.x86_64 1:2.28.1-38.el6
cpio.x86_64 0:2.10-11.el6_3 cpp.x86_64 0:4.4.7-3.el6 cpuspeed.x86_64 1:1.5-19.el6
cups.x86_64 1:1.4.2-50.el6_4.4 cups-libs.x86_64 1:1.4.2-50.el6_4.4 curl.x86_64 0:7.19.7-35.el6
dash.x86_64 0:0.5.5.1-4.el6 dbus.x86_64 1:1.2.24-7.el6_3 dbus-glib.x86_64 0:0.86-6.el6
dbus-libs.x86_64 1:1.2.24-7.el6_3 dbus-x11.x86_64 1:1.2.24-7.el6_3 device-mapper.x86_64 0:1.02.77-9.el6
device-mapper-event.x86_64 0:1.02.77-9.el6 device-mapper-event-libs.x86_64 0:1.02.77-9.el6 device-mapper-libs.x86_64 0:1.02.77-9.el6
dhclient.x86_64 12:4.1.1-34.P1.el6.centos dhcp-common.x86_64 12:4.1.1-34.P1.el6.centos dnsmasq.x86_64 0:2.48-13.el6
dracut.noarch 0:004-303.el6 dracut-kernel.noarch 0:004-303.el6 dvd+rw-tools.x86_64 0:7.1-6.el6
e2fsprogs.x86_64 0:1.41.12-14.el6 e2fsprogs-libs.x86_64 0:1.41.12-14.el6 ethtool.x86_64 2:3.5-1.el6
evolution-data-server.x86_64 0:2.28.3-16.el6 file.x86_64 0:5.04-15.el6 file-libs.x86_64 0:5.04-15.el6
firefox.x86_64 0:17.0.3-1.el6.centos firstboot.x86_64 0:1.110.14-1.el6 freetype.x86_64 0:2.3.11-14.el6_3.1
gawk.x86_64 0:3.1.7-10.el6 gcc.x86_64 0:4.4.7-3.el6 gd.x86_64 0:2.0.35-11.el6
gdm.x86_64 1:2.30.4-39.el6 gdm-libs.x86_64 1:2.30.4-39.el6 gdm-plugin-fingerprint.x86_64 1:2.30.4-39.el6
gdm-user-switch-applet.x86_64 1:2.30.4-39.el6 genisoimage.x86_64 0:1.1.9-12.el6 ghostscript.x86_64 0:8.70-15.el6_4.1
git.x86_64 0:1.7.1-3.el6_4.1 glibc.i686 0:2.12-1.107.el6 glibc.x86_64 0:2.12-1.107.el6
glibc-common.x86_64 0:2.12-1.107.el6 glibc-devel.x86_64 0:2.12-1.107.el6 glibc-headers.x86_64 0:2.12-1.107.el6
glx-utils.x86_64 0:9.0-0.7.el6 gnome-desktop.x86_64 0:2.28.2-11.el6.centos gnome-keyring.x86_64 0:2.28.2-8.el6_3
gnome-keyring-pam.x86_64 0:2.28.2-8.el6_3 gnome-packagekit.x86_64 0:2.28.3-7.el6 gnome-power-manager.x86_64 0:2.28.3-7.el6_4
gnome-screensaver.x86_64 0:2.28.3-24.el6 gnome-settings-daemon.x86_64 0:2.28.2-30.el6 gnome-terminal.x86_64 0:2.31.3-8.el6
gnutls.x86_64 0:2.8.5-10.el6_4.1 grub.x86_64 1:0.97-81.el6 gstreamer-plugins-base.x86_64 0:0.10.29-2.el6
gtk2.x86_64 0:2.18.9-12.el6 gvfs.x86_64 0:1.4.3-15.el6 gvfs-afc.x86_64 0:1.4.3-15.el6
gvfs-archive.x86_64 0:1.4.3-15.el6 gvfs-fuse.x86_64 0:1.4.3-15.el6 gvfs-gphoto2.x86_64 0:1.4.3-15.el6
gvfs-obexftp.x86_64 0:1.4.3-15.el6 gvfs-smb.x86_64 0:1.4.3-15.el6 hpijs.x86_64 1:3.12.4-4.el6
hplip-common.x86_64 0:3.12.4-4.el6 hplip-libs.x86_64 0:3.12.4-4.el6 httpd.x86_64 0:2.2.15-26.el6.centos
httpd-devel.x86_64 0:2.2.15-26.el6.centos httpd-tools.x86_64 0:2.2.15-26.el6.centos hwdata.noarch 0:0.233-7.9.el6
icedax.x86_64 0:1.1.9-12.el6 initscripts.x86_64 0:9.03.38-1.el6.centos.1 iproute.x86_64 0:2.6.32-23.el6
iptables.x86_64 0:1.4.7-9.el6 iptables-ipv6.x86_64 0:1.4.7-9.el6 irqbalance.x86_64 2:1.0.4-3.el6
kernel-firmware.noarch 0:2.6.32-358.2.1.el6 kernel-headers.x86_64 0:2.6.32-358.2.1.el6 kexec-tools.x86_64 0:2.0.0-258.el6
kpartx.x86_64 0:0.4.9-64.el6 krb5-libs.x86_64 0:1.10.3-10.el6_4.1 ledmon.x86_64 0:0.74-1.el6
libSM.x86_64 0:1.2.1-2.el6 libX11.x86_64 0:1.5.0-4.el6 libX11-common.noarch 0:1.5.0-4.el6
libXScrnSaver.x86_64 0:1.2.2-2.el6 libXau.x86_64 0:1.0.6-4.el6 libXcomposite.x86_64 0:0.4.3-4.el6
libXcursor.x86_64 0:1.1.13-2.el6 libXdamage.x86_64 0:1.1.3-4.el6 libXdmcp.x86_64 0:1.1.1-3.el6
libXext.x86_64 0:1.3.1-2.el6 libXfixes.x86_64 0:5.0-3.el6 libXfont.x86_64 0:1.4.5-2.el6
libXft.x86_64 0:2.3.1-2.el6 libXi.x86_64 0:1.6.1-3.el6 libXinerama.x86_64 0:1.1.2-2.el6
libXmu.x86_64 0:1.1.1-2.el6 libXpm.x86_64 0:3.5.10-2.el6 libXrandr.x86_64 0:1.4.0-1.el6
libXrender.x86_64 0:0.9.7-2.el6 libXres.x86_64 0:1.0.6-2.el6 libXt.x86_64 0:1.1.3-1.el6
libXtst.x86_64 0:1.2.1-2.el6 libXv.x86_64 0:1.0.7-2.el6 libXvMC.x86_64 0:1.0.7-2.el6
libXxf86dga.x86_64 0:1.1.3-2.el6 libXxf86misc.x86_64 0:1.0.3-4.el6 libXxf86vm.x86_64 0:1.1.2-2.el6
libblkid.x86_64 0:2.17.2-12.9.el6 libburn.x86_64 0:0.7.0-2.el6 libcom_err.x86_64 0:1.41.12-14.el6
libcurl.x86_64 0:7.19.7-35.el6 libdmx.x86_64 0:1.1.2-2.el6 libdrm.x86_64 0:2.4.39-1.el6
libexif.x86_64 0:0.6.21-5.el6_3 libgcc.x86_64 0:4.4.7-3.el6 libgomp.x86_64 0:4.4.7-3.el6
libgudev1.x86_64 0:147-2.46.el6 libical.x86_64 0:0.43-6.el6 libpciaccess.x86_64 0:0.13.1-2.el6
libproxy.x86_64 0:0.3.0-4.el6_3 libproxy-bin.x86_64 0:0.3.0-4.el6_3 libproxy-python.x86_64 0:0.3.0-4.el6_3
libreport.x86_64 0:2.0.9-15.el6.centos libreport-cli.x86_64 0:2.0.9-15.el6.centos libreport-gtk.x86_64 0:2.0.9-15.el6.centos
libreport-newt.x86_64 0:2.0.9-15.el6.centos libreport-plugin-kerneloops.x86_64 0:2.0.9-15.el6.centos libreport-plugin-logger.x86_64 0:2.0.9-15.el6.centos
libreport-plugin-mailx.x86_64 0:2.0.9-15.el6.centos libreport-plugin-reportuploader.x86_64 0:2.0.9-15.el6.centos libreport-plugin-rhtsupport.x86_64 0:2.0.9-15.el6.centos
libreport-python.x86_64 0:2.0.9-15.el6.centos libsemanage.x86_64 0:2.0.43-4.2.el6 libsmbclient.x86_64 0:3.6.9-151.el6
libsoup.x86_64 0:2.28.2-4.el6 libss.x86_64 0:1.41.12-14.el6 libssh2.x86_64 0:1.4.2-1.el6
libstdc++.x86_64 0:4.4.7-3.el6 libtalloc.x86_64 0:2.0.7-2.el6 libtdb.x86_64 0:1.2.10-1.el6
libtiff.x86_64 0:3.9.4-9.el6_3 libudev.x86_64 0:147-2.46.el6 libusb1.x86_64 0:1.0.9-0.6.rc1.el6
libuuid.x86_64 0:2.17.2-12.9.el6 libwacom.x86_64 0:0.5-4.el6 libwacom-data.noarch 0:0.5-4.el6
libxcb.x86_64 0:1.8.1-1.el6 libxml2.x86_64 0:2.7.6-12.el6_4.1 libxml2-python.x86_64 0:2.7.6-12.el6_4.1
libxslt.x86_64 0:1.1.26-2.el6_3.1 lm_sensors-libs.x86_64 0:3.1.1-17.el6 logrotate.x86_64 0:3.7.8-16.el6
lohit-telugu-fonts.noarch 0:2.4.5-6.el6 lvm2.x86_64 0:2.02.98-9.el6 lvm2-libs.x86_64 0:2.02.98-9.el6
man.x86_64 0:1.6f-32.el6 man-pages.noarch 0:3.22-20.el6 man-pages-overrides.noarch 0:6.4.1-1.el6
mdadm.x86_64 0:3.2.5-4.el6 mesa-dri-drivers.x86_64 0:9.0-0.7.el6 mesa-libGL.x86_64 0:9.0-0.7.el6
mesa-libGLU.x86_64 0:9.0-0.7.el6 microcode_ctl.x86_64 1:1.17-14.el6 mlocate.x86_64 0:0.22.2-4.el6
module-init-tools.x86_64 0:3.9-21.el6 net-snmp.x86_64 1:5.5-44.el6 net-snmp-libs.x86_64 1:5.5-44.el6
net-snmp-utils.x86_64 1:5.5-44.el6 nspluginwrapper.x86_64 0:1.4.4-1.el6_3 nspr.x86_64 0:4.9.2-1.el6
nss.x86_64 0:3.14.0.0-12.el6 nss-sysinit.x86_64 0:3.14.0.0-12.el6 nss-tools.x86_64 0:3.14.0.0-12.el6
nss-util.x86_64 0:3.14.0.0-2.el6 ntp.x86_64 0:4.2.4p8-3.el6.centos ntpdate.x86_64 0:4.2.4p8-3.el6.centos
openjpeg-libs.x86_64 0:1.3-9.el6_3 openldap.x86_64 0:2.4.23-32.el6_4 openldap-devel.x86_64 0:2.4.23-32.el6_4
openssh.x86_64 0:5.3p1-84.1.el6 openssh-askpass.x86_64 0:5.3p1-84.1.el6 openssh-clients.x86_64 0:5.3p1-84.1.el6
openssh-server.x86_64 0:5.3p1-84.1.el6 openssl.x86_64 0:1.0.0-27.el6_4.2 pam.x86_64 0:1.1.1-13.el6
pango.x86_64 0:1.28.1-7.el6_3 parted.x86_64 0:2.1-19.el6 pciutils.x86_64 0:3.1.10-2.el6
pciutils-libs.x86_64 0:3.1.10-2.el6 pcre.x86_64 0:7.8-6.el6 perl.x86_64 4:5.10.1-129.el6
perl-Git.noarch 0:1.7.1-3.el6_4.1 perl-Module-Pluggable.x86_64 1:3.90-129.el6 perl-Pod-Escapes.x86_64 1:1.04-129.el6
perl-Pod-Simple.x86_64 1:3.13-129.el6 perl-libs.x86_64 4:5.10.1-129.el6 perl-version.x86_64 3:0.77-129.el6
pixman.x86_64 0:0.26.2-4.el6 plymouth.x86_64 0:0.8.3-27.el6.centos plymouth-core-libs.x86_64 0:0.8.3-27.el6.centos
plymouth-gdm-hooks.x86_64 0:0.8.3-27.el6.centos plymouth-graphics-libs.x86_64 0:0.8.3-27.el6.centos plymouth-plugin-label.x86_64 0:0.8.3-27.el6.centos
plymouth-plugin-two-step.x86_64 0:0.8.3-27.el6.centos plymouth-scripts.x86_64 0:0.8.3-27.el6.centos plymouth-system-theme.noarch 0:0.8.3-27.el6.centos
plymouth-theme-rings.noarch 0:0.8.3-27.el6.centos plymouth-utils.x86_64 0:0.8.3-27.el6.centos pm-utils.x86_64 0:1.2.5-10.el6
policycoreutils.x86_64 0:2.0.83-19.30.el6 procps.x86_64 0:3.2.8-25.el6 psacct.x86_64 0:6.3.2-63.el6_3.3
pulseaudio.x86_64 0:0.9.21-14.el6_3 pulseaudio-gdm-hooks.x86_64 0:0.9.21-14.el6_3 pulseaudio-libs.x86_64 0:0.9.21-14.el6_3
pulseaudio-libs-glib2.x86_64 0:0.9.21-14.el6_3 pulseaudio-module-bluetooth.x86_64 0:0.9.21-14.el6_3 pulseaudio-module-gconf.x86_64 0:0.9.21-14.el6_3
pulseaudio-module-x11.x86_64 0:0.9.21-14.el6_3 pulseaudio-utils.x86_64 0:0.9.21-14.el6_3 python.x86_64 0:2.6.6-36.el6
python-ethtool.x86_64 0:0.6-3.el6 python-libs.x86_64 0:2.6.6-36.el6 ql2400-firmware.noarch 0:5.08.00-1.el6
ql2500-firmware.noarch 0:5.08.00-1.el6 quota.x86_64 1:3.17-18.el6 redhat-logos.noarch 0:60.0.14-12.el6.centos
rpm.x86_64 0:4.8.0-32.el6 rpm-libs.x86_64 0:4.8.0-32.el6 rpm-python.x86_64 0:4.8.0-32.el6
rpmforge-release.x86_64 0:0.5.3-1.el6.rf rsyslog.x86_64 0:5.8.10-6.el6 samba-winbind-clients.x86_64 0:3.6.9-151.el6
scl-utils.x86_64 0:20120927-2.el6 selinux-policy.noarch 0:3.7.19-195.el6_4.3 selinux-policy-targeted.noarch 0:3.7.19-195.el6_4.3
setup.noarch 0:2.8.14-20.el6 smartmontools.x86_64 1:5.43-1.el6 sos.noarch 0:2.2-38.el6.centos
spice-vdagent.x86_64 0:0.12.0-4.el6_4.1 squid.x86_64 7:3.1.10-16.el6 strace.x86_64 0:4.5.19-1.17.el6
sudo.x86_64 0:1.8.6p3-7.el6 system-config-users.noarch 0:1.2.106-7.el6 systemtap-runtime.x86_64 0:1.8-7.el6
tar.x86_64 2:1.23-11.el6 tcsh.x86_64 0:6.17-24.el6 tzdata.noarch 0:2013b-1.el6
udev.x86_64 0:147-2.46.el6 util-linux-ng.x86_64 0:2.17.2-12.9.el6 vino.x86_64 0:2.28.1-8.el6_3
virt-what.x86_64 0:1.11-1.2.el6 wdaemon.x86_64 0:0.17-5.el6 wget.x86_64 0:1.12-1.8.el6
wodim.x86_64 0:1.1.9-12.el6 wpa_supplicant.x86_64 1:0.7.3-4.el6_3 xkeyboard-config.noarch 0:2.6-6.el6
xorg-x11-drivers.x86_64 0:7.3-13.4.el6 xorg-x11-drv-acecad.x86_64 0:1.5.0-6.el6 xorg-x11-drv-aiptek.x86_64 0:1.4.1-4.el6
xorg-x11-drv-apm.x86_64 0:1.2.5-5.el6 xorg-x11-drv-ast.x86_64 0:0.97.0-2.el6 xorg-x11-drv-ati.x86_64 0:6.99.99-1.el6
xorg-x11-drv-ati-firmware.noarch 0:6.99.99-1.el6 xorg-x11-drv-cirrus.x86_64 0:1.5.1-2.el6 xorg-x11-drv-dummy.x86_64 0:0.3.6-2.el6
xorg-x11-drv-elographics.x86_64 0:1.4.1-2.el6 xorg-x11-drv-evdev.x86_64 0:2.7.3-5.el6 xorg-x11-drv-fbdev.x86_64 0:0.4.3-2.el6
xorg-x11-drv-fpit.x86_64 0:1.4.0-5.el6 xorg-x11-drv-glint.x86_64 0:1.2.8-3.el6 xorg-x11-drv-hyperpen.x86_64 0:1.4.1-4.el6
xorg-x11-drv-i128.x86_64 0:1.3.6-3.el6 xorg-x11-drv-i740.x86_64 0:1.3.4-5.el6 xorg-x11-drv-intel.x86_64 0:2.20.2-2.el6
xorg-x11-drv-keyboard.x86_64 0:1.6.2-7.el6 xorg-x11-drv-mach64.x86_64 0:6.9.3-4.el6 xorg-x11-drv-mga.x86_64 0:1.6.1-7.el6
xorg-x11-drv-mouse.x86_64 0:1.8.1-7.el6 xorg-x11-drv-mutouch.x86_64 0:1.3.0-4.el6 xorg-x11-drv-nouveau.x86_64 1:1.0.1-3.el6
xorg-x11-drv-nv.x86_64 0:2.1.20-4.el6 xorg-x11-drv-openchrome.x86_64 0:0.3.0-3.20120806git.el6 xorg-x11-drv-penmount.x86_64 0:1.5.0-4.el6
xorg-x11-drv-qxl.x86_64 0:0.1.0-4.el6 xorg-x11-drv-r128.x86_64 0:6.9.1-1.el6 xorg-x11-drv-rendition.x86_64 0:4.2.5-2.el6
xorg-x11-drv-s3virge.x86_64 0:1.10.6-2.el6 xorg-x11-drv-savage.x86_64 0:2.3.6-2.el6 xorg-x11-drv-siliconmotion.x86_64 0:1.7.7-2.el6
xorg-x11-drv-sis.x86_64 0:0.10.7-2.el6 xorg-x11-drv-sisusb.x86_64 0:0.9.6-2.el6 xorg-x11-drv-synaptics.x86_64 0:1.6.2-11.el6
xorg-x11-drv-tdfx.x86_64 0:1.4.5-2.el6 xorg-x11-drv-trident.x86_64 0:1.3.6-4.el6 xorg-x11-drv-v4l.x86_64 0:0.2.0-6.el6
xorg-x11-drv-vesa.x86_64 0:2.3.2-4.el6 xorg-x11-drv-vmmouse.x86_64 0:12.9.0-10.el6 xorg-x11-drv-vmware.x86_64 0:12.0.2-3.20120718gite5ac80d8f.el6
xorg-x11-drv-void.x86_64 0:1.4.0-3.el6 xorg-x11-drv-voodoo.x86_64 0:1.2.5-3.el6 xorg-x11-drv-wacom.x86_64 0:0.16.1-3.el6
xorg-x11-drv-xgi.x86_64 0:1.6.0-18.20121114git.el6 xorg-x11-server-Xorg.x86_64 0:1.13.0-11.el6.centos xorg-x11-server-common.x86_64 0:1.13.0-11.el6.centos
xorg-x11-server-utils.x86_64 0:7.5-13.el6 xorg-x11-utils.x86_64 0:7.5-6.el6 xorg-x11-xkb-utils.x86_64 0:7.7-4.el6
xulrunner.x86_64 0:17.0.3-2.el6.centos yelp.x86_64 0:2.28.1-17.el6_3 yum.noarch 0:3.2.29-40.el6.centos
zlib.x86_64 0:1.2.3-29.el6
Replaced:
libjpeg.x86_64 0:6b-46.el6
Complete!
[root@localhost ~]#
3. Check Centos version after upgrade

[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@localhost ~]#

Jumat, 12 Juli 2013

30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X

An alias is nothing but shortcut to commands. The alias command allows user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display list of all defined aliases. You can add user defined aliases to ~/.bashrc file. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.

More about aliases

The general syntax for the alias command for the bash shell is as follows.

Task: List aliases

Type the following command:
 
alias
 
Sample outputs:
alias ..='cd ..'
alias amazonbackup='s3backup'
alias apt-get='sudo apt-get'
...
By default alias command shows a list of aliases that are defined for the current user.

Task: Define / create an alias (bash syntax)

To create the alias use the following syntax:
 
alias name=value
alias name='command'
alias name='command arg1 arg2'
alias name='/path/to/script'
alias name='/path/to/script.pl arg1'
 
In this example, create the alias c for the commonly used clear command, which clears the screen, by typing the following command and then pressing the ENTER key:
 
alias c='clear'
 
Then, to clear the screen, instead of typing clear, you would only have to type the letter 'c' and press the [ENTER] key:
 
c
 

Task: Disable an alias temporarily (bash syntax)

An alias can be disabled temporarily using the following syntax:
 
## path/to/full/command
/usr/bin/clear
## call alias with a backslash ##
\c
 

Task: Remove an alias (bash syntax)

You need to use the command called unalias to remove aliases. Its syntax is as follows:
 
unalias aliasname
 
In this example, remove the alias c which was created in an earlier example:
 
unalias c
 
You also need to delete the alias from the ~/.bashrc file using a text editor (see next section).

Task: Make aliases permanent (bash syntax)

The alias c remains in effect only during the current login session. Once you logs out or reboot the system the alias c will be gone. To avoid this problem, add alias to your ~/.bashrc file, enter:
 
vi ~/.bashrc
 
The alias c for the current user can be made permanent by entering the following line:
 
alias c='clear'
 
Save and close the file. System-wide aliases (i.e. aliases for all users) can be put in the /etc/bashrc file. Please note that the alias command is built into a various shells including ksh, tcsh/csh, ash, bash and others.

A note about privileged access

You can add code as follows in ~/.bashrc:
 
# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
    alias reboot='sudo reboot'
    alias update='sudo apt-get upgrade'
fi
 

A note about os specific aliases

You can add code as follows in ~/.bashrc using the case statement:
 
### Get os name via uname ###
_myos="$(uname)"
 
### add alias as per os using $_myos ###
case $_myos in
   Linux) alias foo='/path/to/linux/bin/foo';;
   FreeBSD|OpenBSD) alias foo='/path/to/bsd/bin/foo' ;;
   SunOS) alias foo='/path/to/sunos/bin/foo' ;;
   *) ;;
esac
 

30 uses for aliases

You can define various types aliases as follows to save time and increase productivity.

#1: Control ls command output

The ls command lists directory contents and you can colorize the output:
 
## Colorize the ls output ##
alias ls='ls --color=auto'
 
## Use a long listing format ##
alias ll='ls -la'
 
## Show hidden files ##
alias l.='ls -d .* --color=auto'
 

#2: Control cd command behavior

 
## get rid of command not found ##
alias cd..='cd ..'
 
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
 

#3: Control grep command output

grep command is a command-line utility for searching plain-text files for lines matching a regular expression:
 
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
 

#4: Start calculator with math support

 
alias bc='bc -l'
 

#4: Generate sha1 digest

 
alias sha1='openssl sha1'
 

#5: Create parent directories on demand

mkdir command is used to create a directory:
 
alias mkdir='mkdir -pv'
 

#6: Colorize diff output

You can compare files line by line using diff and use a tool called colordiff to colorize diff output:
 
# install  colordiff package :)
alias diff='colordiff'
 

#7: Make mount command output pretty and human readable format

 
alias mount='mount |column -t'
 

#8: Command short cuts to save time

 
# handy short cuts #
alias h='history'
alias j='jobs -l'
 

#9: Create a new set of commands

 
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'
 

#10: Set vim as default

 
alias vi=vim
alias svi='sudo vi'
alias vis='vim "+set si"'
alias edit='vim'
 

#11: Control output of networking tool called ping

 
# Stop after sending count ECHO_REQUEST packets #
alias ping='ping -c 5'
# Do not wait interval 1 second, go fast #
alias fastping='ping -c 100 -s.2'
 

#12: Show open ports

Use netstat command to quickly list all TCP/UDP port on the server:
 
alias ports='netstat -tulanp'
 

#13: Wakeup sleeping servers

Wake-on-LAN (WOL) is an Ethernet networking standard that allows a server to be turned on by a network message. You can quickly wakeup nas devices and server using the following aliases:
 
## replace mac with your actual server mac address #
alias wakeupnas01='/usr/bin/wakeonlan 00:11:32:11:15:FC'
alias wakeupnas02='/usr/bin/wakeonlan 00:11:32:11:15:FD'
alias wakeupnas03='/usr/bin/wakeonlan 00:11:32:11:15:FE'
 

#14: Control firewall (iptables) output

Netfilter is a host-based firewall for Linux operating systems. It is included as part of the Linux distribution and it is activated by default. This post list most common iptables solutions required by a new Linux user to secure his or her Linux operating system from intruders.
 
## shortcut  for iptables and pass it via sudo#
alias ipt='sudo /sbin/iptables'
 
# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist
 

#15: Debug web server / cdn problems with curl

 
# get web server headers #
alias header='curl -I'
 
# find out if remote server supports gzip / mod_deflate or not #
alias headerc='curl -I --compress'
 

#16: Add safety nets

 
# do not delete / or prompt if deleting more than 3 files at a time #
alias rm='rm -I --preserve-root'
 
# confirmation #
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
 
# Parenting changing perms on / #
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
 

#17: Update Debian Linux server

apt-get command is used for installing packages over the internet (ftp or http). You can also upgrade all packages in a single operations:
 
# distro specific  - Debian / Ubuntu and friends #
# install with apt-get
alias apt-get="sudo apt-get"
alias updatey="sudo apt-get --yes"
 
# update on one command 
alias update='sudo apt-get update && sudo apt-get upgrade'
 

#18: Update RHEL / CentOS / Fedora Linux server

yum command is a package management tool for RHEL / CentOS / Fedora Linux and friends:
 
## distrp specifc RHEL/CentOS ##
alias update='yum update'
alias updatey='yum -y update'
 

#19: Tune sudo and su

 
# become root #
alias root='sudo -i'
alias su='sudo -i'
 

#20: Pass halt/reboot via sudo

shutdown command bring the Linux / Unix system down:
 
# reboot / halt / poweroff
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'
 

#21: Control web servers

 
# also pass it via sudo so whoever is admin can reload it without calling you #
alias nginxreload='sudo /usr/local/nginx/sbin/nginx -s reload'
alias nginxtest='sudo /usr/local/nginx/sbin/nginx -t'
alias lightyload='sudo /etc/init.d/lighttpd reload'
alias lightytest='sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -t'
alias httpdreload='sudo /usr/sbin/apachectl -k graceful'
alias httpdtest='sudo /usr/sbin/apachectl -t && /usr/sbin/apachectl -t -D DUMP_VHOSTS'
 

#22: Alias into our backup stuff

 
# if cron fails or if you want backup on demand just run these commands # 
# again pass it via sudo so whoever is in admin group can start the job #
# Backup scripts #
alias backup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type local --taget /raid1/backups'
alias nasbackup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type nas --target nas01'
alias s3backup='sudo /home/scripts/admin/scripts/backup/wrapper.backup.sh --type nas --target nas01 --auth /home/scripts/admin/.authdata/amazon.keys'
alias rsnapshothourly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotdaily='sudo  /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotweekly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias rsnapshotmonthly='sudo /home/scripts/admin/scripts/backup/wrapper.rsnapshot.sh --type remote --target nas03 --auth /home/scripts/admin/.authdata/ssh.keys  --config /home/scripts/admin/scripts/backup/config/adsl.conf'
alias amazonbackup=s3backup
 

#23: Desktop specific - play avi/mp3 files on demand

 
## play video files in a current directory ##
# cd ~/Download/movie-name 
# playavi or vlc 
alias playavi='mplayer *.avi'
alias vlc='vlc *.avi'
 
# play all music files from the current directory #
alias playwave='for i in *.wav; do mplayer "$i"; done'
alias playogg='for i in *.ogg; do mplayer "$i"; done'
alias playmp3='for i in *.mp3; do mplayer "$i"; done'
 
# play files from nas devices #
alias nplaywave='for i in /nas/multimedia/wave/*.wav; do mplayer "$i"; done'
alias nplayogg='for i in /nas/multimedia/ogg/*.ogg; do mplayer "$i"; done'
alias nplaymp3='for i in /nas/multimedia/mp3/*.mp3; do mplayer "$i"; done'
 
# shuffle mp3/ogg etc by default #
alias music='mplayer --shuffle *'
 

#24: Set default interfaces for sys admin related commands

vnstat is console-based network traffic monitor. dnstop is console tool to analyze DNS traffic. tcptrack and iftop commands displays information about TCP/UDP connections it sees on a network interface and display bandwidth usage on an interface by host respectively.
 
## All of our servers eth1 is connected to the Internets via vlan / router etc  ##
alias dnstop='dnstop -l 5  eth1'
alias vnstat='vnstat -i eth1'
alias iftop='iftop -i eth1'
alias tcpdump='tcpdump -i eth1'
alias ethtool='ethtool eth1'
 
# work on wlan0 by default #
# Only useful for laptop as all servers are without wireless interface
alias iwconfig='iwconfig wlan0'
 

#25: Get system memory, cpu usage, and gpu memory info quickly

 
## pass options to free ## 
alias meminfo='free -m -l -t'
 
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
 
## Get server cpu info ##
alias cpuinfo='lscpu'
 
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
 
## get GPU ram on desktop / laptop## 
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
 

#26: Control Home Router

The curl command can be used to reboot Linksys routers.
 
# Reboot my home Linksys WAG160N / WAG54 / WAG320 / WAG120N Router / Gateway from *nix.
alias rebootlinksys="curl -u 'admin:my-super-password' 'http://192.168.1.2/setup.cgi?todo=reboot'"
 
# Reboot tomato based Asus NT16 wireless bridge 
alias reboottomato="ssh admin@192.168.1.1 /sbin/reboot"
 

#27 Resume wget by default

The GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, and it can resume downloads too:
 
## this one saved by butt so many times ##
alias wget='wget -c'
 

#28 Use different browser for testing website

 
## this one saved by butt so many times ##
alias ff4='/opt/firefox4/firefox'
alias ff13='/opt/firefox13/firefox'
alias chrome='/opt/google/chrome/chrome'
alias opera='/opt/opera/opera'
 
#default ff 
alias ff=ff13
 
#my default browser 
alias browser=chrome
 

#29: A note about ssh alias

Do not create ssh alias, instead use ~/.ssh/config OpenSSH SSH client configuration files. It offers more option. An example:
 
Host server10
  Hostname 1.2.3.4
  IdentityFile ~/backups/.ssh/id_dsa
  user foobar
  Port 30000
  ForwardX11Trusted yes
  TCPKeepAlive yes
 
You can now connect to peer1 using the following syntax:
$ ssh server10

#30: It's your turn to share...

 
## set some other defaults ##
alias df='df -H'
alias du='du -ch'
 
# top is atop, just like vi is vim
alias top='atop'
 
## nfsrestart  - must be root  ##
## refresh nfs mount / cache etc for Apache ##
alias nfsrestart='sync && sleep 2 && /etc/init.d/httpd stop && umount netapp2:/exports/http && sleep 2 && mount -o rw,sync,rsize=32768,wsize=32768,intr,hard,proto=tcp,fsc natapp2:/exports /http/var/www/html &&  /etc/init.d/httpd start'
 
## Memcached server status  ##
alias mcdstats='/usr/bin/memcached-tool 10.10.27.11:11211 stats'
alias mcdshow='/usr/bin/memcached-tool 10.10.27.11:11211 display'
 
## quickly flush out memcached server ##
alias flushmcd='echo "flush_all" | nc 10.10.27.11 11211'
 
## Remove assets quickly from Akamai / Amazon cdn ##
alias cdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai'
alias amzcdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon'
 
## supply list of urls via file or stdin
alias cdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai --stdin'
alias amzcdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon --stdin'
 

Conclusion

This post summaries several types of uses for *nix bash aliases:
  1. Setting default options for a command (e.g. set eth0 as default option - alias ethtool='ethtool eth0' ).
  2. Correcting typos (cd.. will act as cd .. via alias cd..='cd ..').
  3. Reducing the amount of typing.
  4. Setting the default path of a command that exists in several versions on a system (e.g. GNU/grep is located at /usr/local/bin/grep and Unix grep is located at /bin/grep. To use GNU grep use alias grep='/usr/local/bin/grep' ).
  5. Adding the safety nets to Unix by making commands interactive by setting default options. (e.g. rm, mv, and other commands).
  6. Compatibility by creating commands for older operating systems such as MS-DOS or other Unix like operating systems (e.g. alias del=rm ).
I've shared my aliases that I used over the years to reduce the need for repetitive command line typing. If you know and use any other bash/ksh/csh aliases that can reduce typing, share below in the comments.

Linux / UNIX find out what other users are doing?

Q. Can you explain the command to find what users are doing on my UNIX / Linux system?
A. Both Linux and UNIX (FreeBSD/Solaris) has w command to show who is logged on and what they are doing.
The w command prints a summary of the current activity on the system, including what each user is doing.
=> The first line displays the current time of day
=> How long the system has been running
=> The number of users logged into the system
=> The load averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes.
You can also use ps command which shows you process that are running on the system.
Type w command displays information about the users currently on the machine, and their processes.

Show who is logged on and what they are doing with w command

The fields output are the user's login name, the name of the terminal the user is on, the host from which the user is logged in, the time the user logged on, the time since the user last typed anything, and the name and arguments of the current process.
$ w
Output:
radm    pS 66.90.90.102     Sun01PM  1day -bash
raj     pW 192.168.1.100.  7:42AM     5 ssh root@202.54.1.20
miku    pX a80-186-82-84.el  7:28AM    10 screen irssi
vivek   pY 196.15.193.111    4:11AM     0 nano -w hireme
rani    q0 dslbr0.bsnl.in    7:32AM    12 lynx http://slashdot.org/
jadmin  q2 dslbr5.bsnl.in    7:33AM     0 ssh jadmin@host.cyberciti.info
gad     q3 dslbr76.bsnl.in   7:40AM     0 -ksh
bencs   q5 dslbr22.bsnl.in   7:44AM     5 -zsh
vivek   q6 gw11-vsnl.in      7:47AM    11 -bash
You can use the ps command shows you processes that are running on the system:
$ ps -au | more
$ ps -au | less
So you can use both w and ps commands to find out who's doing what.

10 Example of find command in Unix and Linux

find command is one of the versatile command in UNIX and Linux  and I used it a lot in my day to day work. I believe having knowledge of find command in UNIX and understanding of its different usage will increase your productivity a lot in UNIX. If your works involve lots of searching stuff on Linux machine or if you are a java or C++ programmer and your code resides in UNIX, find command can greatly help you to look for any word inside your source file in the absence of an IDE, It is the alternative way of searching things in UNIX. grep is another Linux command which provides similar functionality like find but in my opinion later is much more powerful than grep in UNIX. Like any  other command strength of find is lies in its various options, which is worth learning, but to be frank hard to remember. If you can even able to remember all options mentioned in this article, you will be taking more advantage of find, than average developers and Linux users. If you love to read books,  you can also take a look at  A Practical Guide to Linux Commands, Editors, and Shell Programming (2nd Edition) By Mark G. Sobell, a great book and must read for any system adminstrator, security guy or developers, who works in UNIX based environment. It not only teaches about find and grep, but also several useful commands, which probably gone unnoticed by many of us

By the way, I have been sharing my experience on Unix and Linux command and its different options, usage and example and this article is in continuation of my earlier post like How to convert IP address to hostname in Linux . If you are new here you may find those tips useful for your day 2 day development and support work.




10 tips on find command in UNIX
Here I am listing down some of the way I use find in Unix or Linux box regularly, I hope this would help some one who is new in UNIX find command or any developer who has started working on UNIX environment. this list is by no means complete and just some of my favorites , if you have something to share please share via commenting.

How to run  last executed find command in Unix – Example 1
!find will repeat the last find command executed. It saves lot of time if you re searching for something and you need to execute same command again and again. In fact "!" can be used with any command to invoke previous run of that command.
k0p0nkkk@xserver ~/java : !find
find . -name "*.java"     --last find command executed
./OnlineStockTrading.java
./StockTrading.java

How to find files which has been modified less than one day, minute or hour  in Unix:
unix find command tutorialfind -mtime is used to search files based upon modification time. This is infact my favorite find command tips while looking out some production issues just to check which files have been modified recently, could be likely cause of  issue, believe me it helps a lot and many a times gives you enough hint of any problem due to intended or unintended file change. Along with –mtime, there are two more options related to time, find -atime which denote last accessed time of file and find –ctime denotes last changed time. + sign is used to search for greater than, - sign is used to search for less than and without sign is used for exact. For example find –mtime -1 will search all files which has been modified
k0p0nkkk@xserver ~/java : find . -mtime(find all the files modified exact 1 day)
k0p0nkkk@xserver ~/java : find . -mtime -1 (find all the files modified less than 1 day)
.
./StockTrading.java
k0p0nkkk@xserver ~/java : find . -mtime +1 (find all the files modified more than 1 day)
./.vimrc
./OnlineStockTrading.java
./StockTrading.java~

In this example since we have only modified StockTrading.java some time back it has shown on find –mtime -1, rest of files are not touched today so they are appearing as modified more than 1 day while there is no file which has been modified exactly one day.

How to find all the files and directories which holds the 777 permission in Unix box – Exmaple 3
find –perm option is used to find files based upon permissions. You can used find –perm 444 to get all files which allows read to owner, group and others. If you are not sure how  those 777 and 444 numbers comes up, see my post on file and directory permission in Unix and some chmod examples to change permissions in Unix.
k0p0nkkk@xserver:~/java $ find . -perm 644
./.vimrc
./OnlineStockTrading.java
I use this find command example to find out all the executable files, you can also modify it to find all the read only files or files having write permission etc by changing permissions e.g. to find all read only files in current directory : find . –perm 555  Here "." or period denotes current directory. You can replace it with any directory you want.

Example 4 – Case insensitive search using find in Unix
How to do case insensitive search using find command in Unix? Use option “-i" with name, by default find searches are case sensitive. This option of find is extremely helpful while looking for errors and exceptions in log file.
find . –iname "error" –print ( -i is for ignore )

On a different note find and grep command is also a favorite topic during Unix interview and interview often asked questions during interviews on both system admin and application developer jobs.

UNIX find command and xargs Example

Now we will see some UNIX find command example combined with xargs command, xargs can be used to do whatever witch each file found by find command for example we can delete that file, list content of that file or can apply any comment on that file.

Example 5 -  How to delete temporary files using find command in Unix?
In order to delete files you can use either –delete option of find command or use xargs in combination. Its better to create house keeping script for such task which can perform cleanup on periodic basis.
find . -name "*.tmp" -print | xargs rm –f
Use of xargs along with find gives you immense power to do whatever you want with each search result. See another example below , also its worth considering use of -print0 to avoid problems with white space in the path when piping to xargs (use with the xargs -0 option) as suggested by Ebon Elaza.

Example 6 -  How to find all text file which contains word Exception using find command in Unix ?
find . –name "*.java" –print | xargs grep “MemoryCache”, this will search all java files starting from current directory for word "MemoryCache". we can also leave -print option in all cases because its default for UNIX find command as pointed out by Ben in comments. You can further sort result of find command using Sort command in unix.
find . –name "*.txt" –print | xargs grep "Exception"

Example 7 -  Finding files only in current directory not searching on sub directories:
While using find command I realized that some time I only need to find files and directories that are new , only in the current directory so I modified the find command as follows. –type option can be used to specifiy search for only file, link or directory and maxdepth specifies how deep find has to search.
find . -maxdepth 1 -type f -newer first_file
Another way of doing it is below:
find . -type f -cmin 15 -prune

Means type file, last modified 15 minutes ago, only look at the current directory. (No sub-directories)


Example 8 – How to find files based on size in Unix and Linux
Following find example shows how you can use find –size option to find files based upon certain size. This will find all files in current directory and sub-directory, greater than some size using find command in Unix:
find . -size +1000c -exec ls -l {} \;
Always use a c after the number, and specify the size in bytes, otherwise you will get confuse because find -size list files based on size of disk block. to find files using a range of file sizes, a minus or plus sign can be specified before the number. The minus sign means "less than," and the plus sign means "greater than." Suppose if you want to find all the files within a range you can use find command as in below example of find:
find . -size +10000c -size -50000c -print

This find example lists all files that are greater than 10,000 bytes, but less than 50,000 bytes:

Example 9 – How to find files some days older and above certain size
We can combine –mtime and –size to find files which are some days old and greater than some size in Unix. Very common scenario where you want to delete some large old files to free some space in your machine. This example of find command will find which are more than 10 days old and size greater than 50K.
find . -mtime +10 -size +50000c -exec ls -l {} \;

10) You can use "awk" in combination of find to print a formatted output e.g. next command will find all of the symbolic links in your home directory, and print the files your symbolic links points to:
find . -type l -print | xargs ls -ld | awk '{print $10}'


"." says starts from current directory and include all sub directory and  "-type l" says list all links.

Hope you find this useful , please share how you are using find commands and we can benefit from each others experience and work more efficiently in UNIX.

Tip: 
$* :    $* is one of the special bash parameter which is used to expands positional parameters from position one.
if you give double quotes and expansion is done within double quotes, it only expands to a single word and corresponding value of each parameter will be separated by the first letter of the IFS environment variable defined in bash. Do let me know how do you find these find examples .

How to use find command on file names with space in Unix:

I have received lot of comments from my readers on not mentioning about find -print0 and xargs -0 on find examples, so I thought to include this as well. When we don't specify any expression after find command the default option is -print which prints the name of each found files followed by \n or newline.since we mostly pipe output of find command to xargs -print could cause problem if file name itself contain new line or any form of white space. To resolve this issue instead of -print use -print0. Difference between find -print and find -print0 is, print0 display file name on the stdout followed by a "NUL" character and then you can use xargs -0 command to process file names with null character. let's see UNIX find command example with file name having space in them:
k0p0nkkk@xserver:~/test find . -name "*equity*" -print
./cash equity trading ./equity~
You see here "cash equity trading" has space in there name
k0p0nkkk@xserver:~/test find . -name "*equity*" -print | xargs ls -l
ls: cannot access ./cash: No such file or directory
ls: cannot access equity: No such file or directory
ls: cannot access trading: No such file or directory
-r--r--r-- 1 stock_trading cash_domain trading 0 Jul 15 11:42 ./equity~
Now if we pass this to xargs, xargs treat them as three separate files.
k0p0nkkk@xserver:~/test find . -name "*equity*" -print0 | xargs ls

xargs: WARNING: a NUL character occurred in the input.  It cannot be passed through in the argument list.  Did you mean to use the --null option?

ls: cannot access ./cash: No such file or directory
ls: cannot access equity: No such file or directory
ls: cannot access trading: No such file or directory
Now to solve this we have used find command with -print0 which appends NUL character on file name but without xargs -0, xargs will not able to handle those inputs.
k0p0nkkk@xserver:~/test find . -name "*equity*" -print0 | xargs -0 ls -l
-rw-r--r-- 1 stock_trading cash_domain trading 0 Jul 21 09:54 ./cash equity trading
-r--r--r-- 1 stock_trading cash_domain trading 0 Jul 15 11:42 ./equity~
Now you can see with find -print0| xargs -0 it looks good

In conclusion always use find -print0 along with xargs -0 if you see slightest possibilities of file names containing space in UNIX or Linux.

Important point about find command in Unix and Linux:

Here are some of the important and interesting things to know about powerful find command, most of these points are contributed by various people in comments and big thanks to all of them for sharing there knowledge, you should definitely check out comments to know more about find command :
1.  find –print and find is same as –print is a default option of find command.
2.  find –print0 should be used to avoid any issue with white space in file name or path while forwarding output to xargs, also use xargs -0 along with find –print0.
3. find has an option called –delete which can be used in place of  -exec rm {} \;