SysAdmin Blog, TechTips and Reviews

Unix Basic Commands and Interview Questions/Answers



Useful commands to extract packages

May 18th, 2012 by elizar

Useful commands to extract packages:

To extract a *.tar file: tar xvf package.tar
To extract a *.cpio.Z file: zcat package.cpio.Z | cpio -idmV
To extract a *.gz file:  gunzip package.gz
To extract *.tar.gz file: guznip package.tar.gz; tar xvf package.tar
To extract *.dstream.Z file: uncompress package.dstream.Z; pkgtrans package.dstream . all
To extract *.zip file: unzip package.zip

yeah sure, citi’g gonna give me a memo for this

Filed under Uncategorized having 4 Comments »

How To Detach Mirror in Solaris – Script

April 13th, 2012 by elizar

How to detach mirror disks in Solaris? Assuming we us SVM, we normally do this like this, manually:

metastat -c d0 (verify disk components)
eeprom bood-device (further verify the boot disk)
synch;
metadetach rootdev detachdevice

or put it a script for repetitive use and to avoice typo mistakes:


cat detach_mirror.ksh
#!/bin/ksh

rootdev=`df -k /|tail -1|awk '{print $1}'|cut -d"/" -f5`
bootdisk=`eeprom boot-device|cut -d"=" -f2|awk '{print $1}'`

if [[ $bootdisk = "disk" || $bootdisk = "disk0" ]]; then
detachdev=`metastat -p $rootdev|tail -2|grep -v "t0d0"|awk '{print $1}'`
elif [[ $bootdisk = "disk1" ]]; then
detachdev=`metastat -p $rootdev|tail -2|grep -v "t1d0"|awk '{print $1}'`
elif [[ $bootdisk = "disk2" ]]; then
detachdev=`metastat -p $rootdev|tail -2|grep -v "t2d0"|awk '{print $1}'`
else
echo "Unknown disk to detach"
exit
fi

echo "boot-disk is $bootdisk"
echo "root device is $rootdev"
echo "\nmetastat -p $rootdev"
metastat -p $rootdev

echo "\ncommands:"
echo "sync; metadetach $rootdev $detachdev"
echo "sleep 10"

detachdiskname=`metastat -p $detachdev|awk '{print $NF}'`
echo "mkdir /a"
echo "mount /dev/dsk/$detachdiskname /a"
echo "cp -p /a/etc/vfstab /a/etc/vfstab.md"

#echo awk '$1=="/dev/md/dsk/'$rootdev'" {print "/dev/dsk/'$detachdiskname'\t/dev/rdsk/'$detachdiskname'\t"$3"\t"$4"\t"$5"\t"$6"\t"$7; next} {print}' /etc/vfstab
echo "awk '\$1==\"/dev/md/dsk/$rootdev\" {print \"/dev/dsk/$detachdiskname\\\t/dev/rdsk/$detachdiskname\\\t\"\$3\"\\\t\"\$4\"\\\t\"\$5\"\\\t\"\$6\"\\\t\"\$7; next} {print}' /etc/vfstab" \> /a/etc/vfstab
echo "egrep -v \"rootdev.*md|MDD root info\" /etc/system > /a/etc/system"

echo "\ncd /"
echo "umount /a"
echo "rmdir /a"

Filed under Script, Solaris having No Comments »

Mounting Remote Filesystem To Local Solaris UNIX Box – NFS

March 27th, 2012 by elizar

Quick post on NFS and sharing filesystem from one server to another.

Key files and commands for this activity:

  • /etc/dfs/dfstab
  • share (command)
  • shareall

The only problem I got in following the below instruction is Permission denied on the shared directory/filesystem from the remote Solaris server.

Temporary fix chmod to 777.. check for security later :)

To be able to share a remote filesystem you have to share the remote filesystem.

To share the remote filesystem you need to modify
the /etc/dfs/dfstab file with

share -F nfs -o rw /var/tmp/oracle

also modify the /etc/dfs/sharetab with

/var/tmp/oracle nfs rw

then issue
shareall

make sure nfs daemon are running of the server
you could check by isseing

ps -ef | grep nfs

if it is not running you could start nfsd by issuing /etc/init.d/nfs.server start

svcadm enable nfs

on the client side, that is the side with no disk space
you need to mount the remote filesystem you could do this by issuing

mount (remote server):/usr/local /mount_point

Note:
/var/tmp/oracle will be the filesytem you intend to share eg / /usr/local, /var, /export/home

so if you intend to share /usr/local your /etc/dfs/dfstab will look like

share -F nfs -o rw /usr/local

and /etc/dfs/sharetab will look like

/usr/local nfs rw

Filed under Commands, Solaris 10 having No Comments »

NGINX 1.1.16 – Next Powerful Web Server since Apache?

March 5th, 2012 by elizar

When we say open source web server, I immediately associate myself with the Apache Project. Honestly, I dont even think of anything else but apache.. Heck, when you say Web Server, its almost synonymous to Apache if you’ve been eating and breathing Unix.

Today I found out about NGINX which is apparently a good web server in it self and currently in its 1.1.16 version and still being developed.

Igor Sysoev, the developer of NGINX has released version 1.1.16 of his web server software. The project aims to provide a stable, high performance alternative to more traditional competitors such as Apache HTTP Server or Microsoft’s IIS (Internet Information Services).

The new development version comes with features such as a “from” parameter for the “disable_symlinks” directive, an increased limit for simultaneous subrequests and the ability to return 307 redirection messages. Bugs fixed include segmentation faults and build problems.

More details on this release can be found in the change log. The software is available to download for Windows and Linux (RHEL, CentOS, Ubuntu, Debian), and source code is made available under a 2-clause BSD licence.

Filed under Apache, Tools having 1 Comment »

Open Source Video Audio Decoder Encoder Transcoder – HandBreak 0.9

March 2nd, 2012 by elizar

Currently I am using a commercial software for doing all my video (audio) requirements for editing and publishing video and audio content on my websites and all over the internet. What I am using is Camtasia version 7. There is also a free one called Camstudio but it feels limiting in my personal opinion.

For this one, another open source video and audio transcoder that you and myself may want to try out. It is called “HandBreak“.

Check out the milestone/change log for HandBreak.

The HandBrake developers have released version 0.9.6 of the open source, cross-platform video transcoder software. The new version brings many improvements to the video and audio libraries used for both decoding and encoding.

Aside from those library updates and bug fixes, HandBrake 0.9.6 adds support for Blu-ray audio decoding and video encoding to MPEG-2. Other changes on Windows include a redesigned preview window and the dropping of QuickTime support, while on Linux there is a new advanced audio options section with gain, audio track names, compression and sample rate. The option to set a target size for HandBrake output has been removed and, according to the developers “isn’t coming back – Don’t bother complaining on the forums”.

On Mac OS X, DVD decryption with VLC 2.0 no longer works, as HandBrake can no longer rely on VLC for circumventing the CSS copy protection. The developers say that libdvdcss is the preferred method for decrypting DVDs and users should install a separate package to enable it.

A detailed change log can be found on the HandBrake site. The software is available for download on Windows, Mac OS X and Linux (Ubuntu and Fedora) and is licensed under the GPLv2.

Filed under Open Source having No Comments »

How Do you Find and Replace Expressions in VI Editor

February 29th, 2012 by elizar

One and for all, let’s do this again.. how do you do the find and replace function of the Vi editor? I keep on coming back to Google for the syntax but at least I know that there is an ‘s’ in the beginning of the command and a ‘g’ at the end (for Global search). :)

Anyway, a little background before i copy paste the information here. I first taught myself how to use Vi during my ‘first’ job as a systems engineer in NEC TNCSi. Actually, my UNix foundation was all from NEC. Not that they train me how to be a unix admin, but I learned and taught myself how to do it. I read books that were lying around there and build samba servers, qmail and email servers and stuff until I got the ropes, the ins and outs of the UNix environment (Actually, I was using Linux – Redhat).

How Do You Find and Replace Text in Vi?

To perform a global search and replace in vi, use the search and replace command in command mode:

:%s/search_string/replacement_string/g

The % is a shortcut that tells vi to search all lines of the file for search_string and change it to replacement_string. The global ( g ) flag at the end of the command tells vi to continue searching for other occurrences of search_string . To confirm each replacement, add the confirm ( c ) flag after the global flag.

For this latest usage, i need to change the shell for all the users who are using /bin/ksh to a safeword sid shell.

remember to use the ‘slash’ character if you are filtering actually backslash.. You do not want to misinterpret the ‘/’ character by vi.

so, that’s

:%s/\/bin\/ksh/\/bin\/sid/g

Filed under Commands, Linux, Solaris, Unix having No Comments »

Gnome 3.4 Beta 1 – What’s Up?

February 27th, 2012 by elizar

I could not remember the first time I ever used the first ever desktop environment in the Linux OS.

Back in the pre- Fedora dys when Redhat was still freely available, two well known desktop available to linus was the K Desktop and Gnome.

I am in love with Gnome then and I beilive ot is still the one i prefer today, even though I an no longer active in the Linux community.. Solaris grab all my attention.

Now, Gnome 3.4 Beta 1 is almost out…

The GNOME 3.4 Beta 1 release is ready for testing and it brings updates to main components, such as GNOME Contacts, GNOME Control Center, GNOME Desktop, GNOME Disk Utility, GNOME Panel, GNOME Screensaver, GNOME Session, GNOME Settings Daemon, GNOME Shell, GNOME System Monitor, GNOME Themes Standard, Mousetweaks, and GNOME User Docs.
Moreover, the following apps were updated: NetworkManager (including network-manager-applet), Baobab, Empathy, Evince, Yelp, Nautilus, and Eye of GNOME.

The GNOME 3.4 Beta 1 release is ready for testing and it brings updates to main components, such as GNOME Contacts, GNOME Control Center, GNOME Desktop, GNOME Disk Utility, GNOME Panel, GNOME Screensaver, GNOME Session, GNOME Settings Daemon, GNOME Shell, GNOME System Monitor, GNOME Themes Standard, Mousetweaks, and GNOME User Docs.

Moreover, the following apps were updated: NetworkManager (including network-manager-applet), Baobab, Empathy, Evince, Yelp, Nautilus, and Eye of GNOME.

Last but not least, here are the core libraries that were updated in GNOME 3.4 Beta 1: at-spi2-atk, at-spi2-core, clutter, clutter-gst, cogl, folks, glib, glibmm, gmime, gstreamer, gtk+, gtksourceview, libcroco, libgee, libgnomekbd, libsoup, mutter, and pygobject.

The GNOME 3.4 development cycle will continue with a second Beta release on March 7th and the GNOME 3.4 Release Candidate version on March 21st.

The final release of GNOME 3.4 will be available on March 28th, 2012, followed by the first point release on April 18th, GNOME 3.4.1.

Filed under Linux having No Comments »

java script mouse click change image – saving for future use

February 13th, 2012 by elizar

I want this to be added on my Make money online blog later

Filed under Uncategorized having No Comments »

VxVM vxassist ERROR V-5-1-5455 Operation requires a disk group

January 27th, 2012 by elizar

On this post we will take a closer look at this veritas volume manager error when trying to display the available disk space in an existig datagroup. The error is “VxVM vxassist ERROR V-5-1-5455 Operation requires a disk group

This is a draft post as I currently have no answer yet.. Weird thing is, the vxassist command works on one server and not in the other.. which is spitting out the error in subject.

Take this example:

Working server:


# vxdg list
NAME STATE ID
datadg1 enabled 1169455228.81.sgtjcpb1
datadg2 enabled 1169455429.95.sgtjcpb1
# vxassist -g datadg1 maxsize layout=concat
Maximum volume size: 390506496 (190677Mb)
# vxassist -g datadg2 maxsize layout=concat
Maximum volume size: 676767744 (330453Mb)
# vxassist -g datadg1 maxsize layout=raid5
Maximum volume size: 270483456 (132072Mb)
# vxassist -g datadg2 maxsize layout=raid5
Maximum volume size: 375160832 (183184Mb)

Looks fine right? But when I tried the same syntax on the other sever, I got this:

# vxdg -g sysdg free
DISK DEVICE TAG OFFSET LENGTH FLAGS
sysdg05 emcpower5s2 emcpower5 16777216 2029952 n
sysdg06 emcpower3s2 emcpower3 16777216 2029952 n
sysdg07 emcpower4s2 emcpower4 167772160 2020352 n
# vxassist -d sysdg maxsize layout=concat
VxVM vxassist ERROR V-5-1-5455 Operation requires a disk group
#

I suspect it has something to do with the Veritas VX version or the OS it is running. Will investigate further and let you know.

UPDATE.. saw the error after 5 minutes.. saw it? I found “d” error.

(ufsrestore) Make Bootable – Recovering the Root or /usr File System

January 17th, 2012 by elizar

This is some kind of a followup from the first post about ufsdump – how to backup solaris filesystem

1. Replace and partition the disk if it has failed.

2. Because the system cannot be booted from the boot disk, boot from the CD-ROM and re-create the failed file system by issuing the newfs command:

newfs /dev/rdsk/

is the name of the raw disk partition that contains the corrupted file system.

3. Check the new file system by using fsck:

fsck /dev/rdsk/

4. Mount the new file system on a temporary mount point:

mount /dev/dsk//mnt

5. Change to the /mnt directory:

cd /mnt

6. Write protect the tapes so that you don’t accidentally overwrite them.

7. Load the tape and issue the following command:

ufsrestore rf /dev/rmt/0

The entire content of the tape is restored to the file system. All permissions, ownerships, and dates remain as they were when the last incremental tape was created.

8. Verify that the file system is restored:

ls

9. Remove the restoresymtable file that is created and used by ufsrestore to checkpoint the restoration:

rm restoresymtable

10. Change to the root (/) directory:

cd /

11. Unmount the newly created file system:

umount /mnt

12. Check the new file system with fsck:

fsck /dev/rdsk/

The restored file system is checked for consistency.

13. If you are recovering the root (/) file system, create the boot blocks on the root partition by using the installboot command:

installboot /usr/platform/’uname-I’/lib/fs/ufs/bootblk\
/dev/rdsk/

The installboot command installs the boot blocks onto the boot disk. Without the boot blocks, the disk cannot boot.

14. Insert a new tape into the tape drive and back up the new file system:

ufsdump 0uf /dev/rmt/n /dev/rdsk/

A level 0 backup is performed. You should immediately make a backup of a newly created file system because ufsrestore repositions the files and changes the inode allocation.

15. Reboot the system with a reconfiguration reboot:

# shutdown -y -g0 -i0
ok boot -r

The system is rebooted.

Extra Notes on UFSrestore

When you restore files in a directory other than the root directory of the file system, ufsrestore re-creates the file hierarchy in the current directory. For example, if you restore to /home files that were backed up from /users/bcalkins/files, the files are restored in the directory /home/users/bcalkins/files.

When you restore individual files and directories, it’s a good idea to restore them to a temporary directory such as /var/tmp. After you verify that you’ve retrieved the correct files, you can move them to their proper locations. You can restore individual files and directories to their original locations; however, if you do so, you should be sure that you do not overwrite newer files with older versions from the backup tape.

You should not forget to make regular backups of your operating system. Losing all the customization you dosuch as adding user accounts, setting up printers, and installing application softwarewould be disastrous. Whenever you make modifications that affect the root (/),/usr, /opt, or other operating system directories, you should bring down the system into single-user mode and perform a level 0 dump.

Filed under Solaris, Solaris 10 having No Comments »

« Previous Entries

I was here...