Showing posts with label Unix Commands. Show all posts
Showing posts with label Unix Commands. Show all posts

Thursday, 15 May 2014

how to uncompress a xxx.zip.enc file?

Run the following commands (filenames should be substituted for your own values):

openssl aes-256-cbc -d -in your_archive_filename.zip.enc -out your_archive_filename.zip
unzip filename.zip

Refer URL: https://auraredeye.zendesk.com/entries/24173466-Decrypting-Secure-Archives-using-Linux-tar-gz-enc

Thursday, 20 March 2014

How to install packages various unix platforms

  Example:

  Install the package.

AIX
# installp -ac -d VRTSmq6.rte.bff VRTSmq6.rte
HP-UX
# swinstall -s 'pwd' VRTSmq6
Linux
# rpm -ihv \VRTSmq6-AgentVersion
-GA_GENERIC.noarch.rpm
Solaris
# pkgadd -d . VRTSmq6

Monday, 9 December 2013

Increas Swap space in HPUX



2 ways to increase the swap space
1.   By using SAM
SAM > Disk and File Systems > Swap > Actions
You can add the Device Swap or File System Swap.
2.   By Command Line
Create the logical volume for your secondary swap:
# lvcreate -L 128 /dev/vg14

NOTE: "-L 128" is the size of desired swap

Verify the logical volume:
# lvdisplay /dev/vg14/lvol15

Use SAM to declare your new secondary swap or use the command line:
# swapon /dev/vg14/lvol15

Verify it has been added in "/etc/fstab" when using SAM, or add it manuallywhen using the command line.

Example:
/dev/vg14/lvol15 . swap defaults 0 0

Wednesday, 8 May 2013

Unix/Linux Tips and Tricks



Trick 1: Unmounting the unresponsive DVD drive
The newbie states that when he pushes the Eject button on the DVD drive of a server running a certain Redmond-based operating system, it will eject immediately. He then complains that, in most enterprise Linux servers, if a process is running in that directory, then the ejection won't happen. For too long as a Linux administrator, I would reboot the machine and get my disk on the bounce if I couldn't figure out what was running and why it wouldn't release the DVD drive. But this is ineffective.
Here's how you find the process that holds your DVD drive and eject it to your heart's content: First, simulate it. Stick a disk in your DVD drive, open up a terminal, and mount the DVD drive:
# mount /media/cdrom
# cd /media/cdrom
# while [ 1 ]; do echo "All your drives are belong to us!"; sleep 30; done

Now open up a second terminal and try to eject the DVD drive:
# eject
You'll get a message like:
umount: /media/cdrom: device is busy
Before you free it, let's find out who is using it.
# fuser /media/cdrom
You see the process was running and, indeed, it is our fault we can not eject the disk.
Now, if you are root, you can exercise your godlike powers and kill processes:
# fuser -k /media/cdrom
Boom! Just like that, freedom. Now solemnly unmount the drive:
# eject
fuser is good.

Trick 2: Getting your screen back when it's hosed
Try this:
# cat /bin/cat
Behold! Your terminal looks like garbage. Everything you type looks like you're looking into the Matrix. What do you do?
You type reset. But wait you say, typing reset is too close to typing reboot or shutdown. Your palms start to sweat—especially if you are doing this on a production machine.
Rest assured: You can do it with the confidence that no machine will be rebooted. Go ahead, do it:
# reset
Now your screen is back to normal. This is much better than closing the window and then logging in again, especially if you just went through five machines to SSH to this machine.
David, the high-maintenance user from product engineering, calls: "I need you to help me understand why I can't compile supercode.c on these new machines you deployed."
"Fine," you say. "What machine are you on?"
David responds: " Posh." (Yes, this fictional company has named its five production servers in honor of the Spice Girls.) OK, you say. You exercise your godlike root powers and on another machine become David:
# su - david
Then you go over to posh:
# ssh posh
Once you are there, you run:
# screen -S foo
Then you holler at David:
"Hey David, run the following command on your terminal: # screen -x foo."
This will cause your and David's sessions to be joined together in the holy Linux shell. You can type or he can type, but you'll both see what the other is doing. This saves you from walking to the other floor and lets you both have equal control. The benefit is that David can watch your troubleshooting skills and see exactly how you solve problems.
At last you both see what the problem is: David's compile script hard-coded an old directory that does not exist on this new server. You mount it, recompile, solve the problem, and David goes back to work. You then go back to whatever lazy activity you were doing before.
The one caveat to this trick is that you both need to be logged in as the same user. Other cool things you can do with the screen command include having multiple windows and split screens. Read the man pages for more on that.
But I'll give you one last tip while you're in your screen session. To detach from it and leave it open, type: Ctrl-A D . (I mean, hold down the Ctrl key and strike the A key. Then push the D key.)
You can then reattach by running the screen -x foo command again.

Trick 4: Getting back the root password
You forgot your root password. Nice work. Now you'll just have to reinstall the entire machine. Sadly enough, I've seen more than a few people do this. But it's surprisingly easy to get on the machine and change the password. This doesn't work in all cases (like if you made a GRUB password and forgot that too), but here's how you do it in a normal case with a Cent OS Linux example.
First reboot the system. When it reboots you'll come to the GRUB screen. Move the arrow key so that you stay on this screen instead of proceeding all the way to a normal boot.
Next, select the kernel that will boot with the arrow keys, and type E to edit the kernel line.
Use the arrow key again to highlight the line that begins with kernel, and press E to edit the kernel parameters. When you get to the screen , simply append the number 1 to the arguments .
Then press Enter, B, and the kernel will boot up to single-user mode. Once here you can run the passwd command, changing password for user root:
sh-3.00# passwd
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully

Now you can reboot, and the machine will boot up with your new password.

Trick 5: SSH back door
Many times I'll be at a site where I need remote support from someone who is blocked on the outside by a company firewall. Few people realize that if you can get out to the world through a firewall, then it is relatively easy to open a hole so that the world can come into you.
In its crudest form, this is called "poking a hole in the firewall." I'll call it an SSH back door. To use it, you'll need a machine on the Internet that you can use as an intermediary.
In our example, we'll call our machine blackbox.example.com. The machine behind the company firewall is called ginger. Finally, the machine that technical support is on will be called tech.
Here's how to proceed:
  1. Check that what you're doing is allowed, but make sure you ask the right people. Most people will cringe that you're opening the firewall, but what they don't understand is that it is completely encrypted. Furthermore, someone would need to hack your outside machine before getting into your company. Instead, you may belong to the school of "ask-for-forgiveness-instead-of-permission." Either way, use your judgment and don't blame me if this doesn't go your way.
  2. SSH from ginger to blackbox.example.com with the -R flag. I'll assume that you're the root user on ginger and that tech will need the root user ID to help you with the system. With the -R flag, you'll forward instructions of port 2222 on blackbox to port 22 on ginger. This is how you set up an SSH tunnel. Note that only SSH traffic can come into ginger: You're not putting ginger out on the Internet naked.
You can do this with the following syntax:
~# ssh -R 2222:localhost:22 thedude@blackbox.example.com
Once you are into blackbox, you just need to stay logged in. I usually enter a command like:
thedude@blackbox:~$ while [ 1 ]; do date; sleep 300; done
to keep the machine busy. And minimize the window.
  1. Now instruct your friends at tech to SSH as thedude into blackbox without using any special SSH flags. You'll have to give them your password:
root@tech:~# ssh thedude@blackbox.example.com .
  1. Once tech is on the blackbox, they can SSH to ginger using the following command:
thedude@blackbox:~$: ssh -p 2222 root@localhost
  1. Tech will then be prompted for a password. They should enter the root password of ginger.
  2. Now you and support from tech can work together and solve the problem. You may even want to use screen together!

Tuesday, 26 March 2013

X11 problem in aix



Whenever you face problem with X11 forwarding, please refer the following steps to set it right:

1)      ssh settings:
Check the following settings in the configuration file sshd_config present in /etc/ssh:

X11Fowarding yes

2)      Stop and start the ssh service:

stopsrc –s ssh
startsrc –s ssh

3)      Start the X server:

startx

4)      Logout the user and login again.

5)      When you login, issue the following command to create a Xauthority file:

Xauth

6)      Now type xclock and it will start worklng.

Monday, 25 March 2013

How to copy large files in aix

I changed the default parameters in /etc/security/limits to make the file size unlimited and it works now.

Ref: http://unix.ittoolbox.com/groups/technical-functional/ibm-aix-l/how-to-copy-large-files-in-aix-2904368 


Tuesday, 25 December 2012

How to install a package on solaris

Package can be install from CDROM, Network i.e. NFS or downloading from Internet and then add it to system, or from existing location such as /var/spool/pkg directory if frequently required packages are copied to this location.

Solaris: Adding package from CDROM
 

1) Mount cdrom
2) To add or install GNU tar package from Solaris CD use command
# pkgadd -d /cdrom/cdrom0/Solaris_9/Product SUNWgtar

Where,
-d /cdrom/cdrom0/Solaris_9/Product
: Specify package directory
SUNWgtar
: Package name


Solaris: Adding packages to spool directory and then install them
 

1) Copy package to /var/spool/pkg directory first:
# pkgadd -d /cdrom/cdrom0/Solaris_9/Product -s /var/spool/pkg SUNWgtar

Transferring package instance

Where,
-d /cdrom/cdrom0/Solaris_9/Product
: Specify package directory
-s /var/spool/pkg
: Directory in which package will get stored
SUNWgtar
: Package name


2) Install the packages copied to spool directory
 

# pkgadd SUNWgtar
Solaris: Install downloaded package
1) If your package is in .bz2 format then first uncompress it using bunzip2 command:
# bunzip2 Packagname.bz2


2) Install package:
 

# pkgadd –d Packagname
Note .bz2 extension will automatically removed by first command.
For example if your package name is SFWqt.bz2
# buzip2 SFWqt.bz2
# pkgadd –d SFWqt

Thursday, 27 September 2012

How to Repair Linux File System?

My ESX VM Linux Server haulted at single user mode ( init 1 ) , after doing a restart as a result of  file system check up failure ( fsck process).

So, how to trouble shoot it?

You will see a black screen with the following information as given below:

"This is the key: the filesystem is corrupted, probably due to an unclean shutdown. It needs to be repaired. Try entering the root password, which should

give you a '#' prompt.
Type: fsck -A -y "

My Approach to it to trouble shoot  File System corruption issue:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1.Before executing fsck, unmount all filesystems to make sure  that  no disk i/o happens.Then do fsck, then remount or just say "init 6".
2.Tips on mounting:
a.mount -o rw /  to freshly mount a disk onto / with read and write permissions to  root filesystem.
b.mount -o remount,rw  /  to  unmount,remount the disk onto / with read adn write permissions to root user or system admin.

RHEL6.2X64_Shalni: Disk name :  /dev/sda1:

So, user command :  e2fsck -f /dev/sda1  is  ok

Is shalini's machine having /dev/sda3. let me check:

e2fsck -f /dev/sda3


Reference :

So how the hell you are gonna Surviving a Filesystem Failures? Most of time fsck (front end to ext2/ext3 utility) can fix the problem, first simply run

e2fsck - to check a Linux ext2/ext3 file system (assuming /home [/dev/sda3 partition] filesystem for demo purpose), first unmount /dev/sda3 then type

following command :
# e2fsck -f /dev/sda3
Where,

    -f : Force checking even if the file system seems clean.

Please note that If the superblock is not found, e2fsck will terminate with a fatal error. However Linux maintains multiple redundant copies of the

superblock in every file system, so you can use -b {alternative-superblock} option to get rid of this problem. The location of the backup superblock is

dependent on the filesystem's blocksize:

    For filesystems with 1k blocksizes, a backup superblock can be found at block 8193
    For filesystems with 2k blocksizes, at block 16384
    For 4k blocksizes, at block 32768.

Tip you can also try any one of the following command(s) to determine alternative-superblock locations:
# mke2fs -n /dev/sda3
OR
# dumpe2fs /dev/sda3|grep -i superblock
To repair file system by alternative-superblock use command as follows:
# e2fsck -f -b 8193 /dev/sda3

However it is highly recommended that you make backup before you run fsck command on system, use dd command to create a backup (provided that you have spare

space under /disk2)
# dd if=/dev/sda2 of=/disk2/backup-sda2.img

Links:
http://www.cyberciti.biz/tips/surviving-a-linux-filesystem-failures.html
http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-superblock.html


First of all, list all the super blocks of /dev/sda1:

Following command displays primary and backup superblock location on /dev/sda3:
# dumpe2fs /dev/sda1 | grep -i superblock

Learned that, backup superblock is at 8193,24577,40961,57345,73729,204801,221185,401489:

So, let me try with alternative superblock to recognize the filesystem which ext3 written on /dev/sda1:

Command to load alternative superblock : e2fsck -f -b 8193 /dev/sda1 -  Linux

File system is fixed now on inodes,userdata,file metadata etc..


Big problem that confused me:
Now, On VMWare Linux :  how to repair /dev/mapper/VolGroup-lv_root :
check for all mount points using cat /proc/mounts


Steps I followed from Murthy Sir:

1.In single user mode # vi /etc/fstab
2.Renamed 1 2 flags  to 0 0  for logical volume which mounted on /.This tells init to ignore "FileSystem Check and FileSystem Backup".
3.use # sync  command  to flush the buffers to hard disk.
4.Then reboot using, init 6  command.
5.If it ignores Filesystem checks and comes up, it is ok to work.
6.After Linux comes up, Again check whether all filesystems are ok leaving /.
7.How to check?
8.Again vi /etc/fstab,change  0  0  to  1  2 for  /dev/mapper/VolGroup-lv_root.
9.do  sync
10.init 6

Now, your linux ios ready for working in runlevel 5.
++++++++++++++++++++++++++++++++++++++++++++++++++++

While checking hostname on linux:
1.Make sure that /etc/hosts will have last  entry of IP as the latest entry.
<IP> <FQDN> <HostName>.

2.vi /etc/sysconfig/network.
Makure Sure,
NETWORK=yes
HOSTNAME=RHEL62X64

3."Sync"
4.init 6 -> reboots to runlevel 5.

++++++++++++++++++++++++++++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Wednesday, 19 September 2012

Linux:cpio command



You may encounter  .cpio file as  the installer file for many of the oracle products.

This is the command to   extract that file:

1.First,  list  the contents of the file without extracting.

cpio  -itv  < rtd_2.2.1.1_OC4J_unix.cpio

2.Second, extract  .cpio file into a clean directory  to  see the files, you have extracted.

cpio -idmv < rtd_2.2.1.1_OC4J_unix.cpio


Make it a practice , while extracting  any cpio file.

Tweets by @sriramperumalla