21 September 2012

HOW TO RECOVER UBUNTU PASSWORD


Why would you want to reset a password..........?

1.)   Someone gave you a computer with Ubuntu installed on it but not the password for the user account.
2.)   You just installed Ubuntu and forgot what password you selected during the installation process.
3.)   You have too many passwords in your life and can't keep track of them all. Well, then certainly you are at right place to find a solution to the problem, i.e. to  reset your Ubuntu user account password, regardless of what reason you have for resetting it.

STEP 1)   First, you have to reboot into recovery mode.

If you have a single-boot (Ubuntu is the only operating system on your computer), to get the boot menu to show, you have to hold down the Shift key during bootup.
If you have a dual-boot (Ubuntu is installed next to Windows, another Linux operating system, or Mac OS X etc and you choose at boot time which operating system to boot into), the boot menu should appear without the need to hold down the Shift key as shown below.

STEP 2)   From the boot menu, select recovery mode, which is usually the second boot option.





STEP 3)   After you select recovery mode and wait for all the boot-up processes to finish, you'll be presented with a few options. In this case, you want the Drop to root shell prompt option so press the Down arrow to get to that option, and then press Enter to select it.
In recent versions of Ubuntu, the filesystem is mounted as read-only, so you need to enter the follow command to get it to remount as read-write, which will allow you to make changes:

[user@linux ~]$ mount -o rw,remount /

If you have forgotten your username as well, type
[user@linux ~]$ ls /home

You will see a list of the users on your Ubuntu installation. Select a user and enter the following commands
[user@linux ~]$ passwd <username>

where username is the username you want to reset.You'll then be prompted for a new password.Type the password and hit Enter when you're done. You'll be prompted to retype the password. Do so and hit Enter again.Now the password should be reset. 
  
 

STEP 4)   Type exit to return to the recovery menu.

[user@linux ~]$exit

After you get back to the recovery menu, select resume normal boot, and use Ubuntu as you normally would .





 Note: Recovery mode makes me root user. Isn't that a security risk?

Well, if you have several people using your computer, you can put small obstacles in their way by setting a root password, setting a Grub password, or setting a BIOS password. Still, anyone who has physical access to your computer and a little know-how practically has root access anyway. He can boot a live CD and mount your partition or even just physically remove the hard drive from your computer and put it in another computer. There's a certain amount of trust you automatically give anyone by allowing him to sit at your computer.

14 September 2012

REMOVE 32 bit PACKAGES FROM 64bit(CENTOS)

CentOS follows the upstream source in this respect, and the x86_64 installation by default will install ix86 32-bit packages on a 64-bit installation for compatibility purposes. Many server system administrators (and some desktop users) want a pure 64-bit system and so remove all 32-bit packages. This can be accomplished as follows:

yum remove \*.i\?86

To keep any 32-bit packages from being installed in future updates, edit your /etc/yum.conf and add the line:

exclude = *.i?86

Be aware that 32-bit applications, including some browser plugins that may only be available in 32-bit versions, will no longer work after this procedure.

You may also want to do this:

yum reinstall \*

The reason is that sometimes the /usr/share/ items (shared between BOTH packages) get removed when removing the 32-bit RPM packages.

13 September 2012

RPM MANAGEMENT TIPS



REBUILD THE RPM FROM SRPM
============================

The pre-requisite packages required are ---

[user@linux ~]$yum groupinstall "Development Tools" 

[user@linux ~]$yum install yum-utils

OR

you can install only rpm-build.For CentOS most SRPMs targetted to be rebuilt on CentOS also need certain rpmbuild build macros and helper scripts, which are contained in package: redhat-rpm-config

[user@linux ~]$yum install redhat-rpm-config

[user@linux ~]$yum install rpm-build

The quickest way to rebuild the SRPM is to use the rpmbuild --rebuild command. This command will unpack the SRPM file into the specfile and the source files, and then it will build the RPM from the instructions on the specfile

[user@host ~]$ rpmbuild --rebuild /tmp/mypackage-1.0.0-1.src.rpm

If no error occurs, you can find mypackage-1.0.0-1.i386.rpm file under the ~/rpmbuild/RPMS/<architecture of your system> directory (for 64 bit it is x84_64 if 32 bit then it is i386). For more details read here


CHECK WHAT PACKET OWNS A PARTICULAR FILE
===========================================

[user@host~]$rpm -qf filename

[user@host~]$rpm -qf /usr/bin/crontab

cronie-1.4.4-7.el6.x86_64


CHECK WHAT CONFIGURATION FILE EXISTS FOR A PACKAGE
=====================================================

[user@host~]$rpm -qc packagename

CHECK IF THE FILES INSTALLED BY A PACKAGE ARE STILL IN THE SAME STATE AS THEY WERE WHEN INSTALLED
==============================================================================================

[user@host~]$rpm -qs packagename

This command will display all of the files installed by the package with a notation of "normal," "replaced," "not installed" and so on.

BASH SCRIPTING


CREATE INFINITE WHILE LOOP WITH EMPTY EXPRESSION
==================================================

#!/bin/bash

while :
do
echo "infinite loops [ hit CTRL+C to stop]"
done

OR

#!/bin/bash
chekpt=5

while [ "$chekpt" -lt 6 ]
do

echo "infinite loops [ hit CTRL+C to stop]"

done


CREATE A FILE WITH PRESENT DATE -TIMEGROUP
============================================
 
#!/bin/bash

filename=`/bin/date +%d%m%y%H%M%S`

/bin/touch /tmp/$filename