Archive for the ‘Advanced Commands’ Category

h1

write a message to a particular user through terminal

April 21, 2010

We use wall to broadcast any message to all users logged in at any point of time through terminal

We can use ‘write’ command to send or write a message to a particular user through terminal.


root@server1056 [/root]# w
18:23:38 up 22 days, 17:03, 3 users, load average: 0.47, 0.22, 0.12
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 1x.3x.7x.53-sta 17:48 0.00s 0.06s 0.06s -bash
root pts/3 12x.16x.6x.138 16:14 40:29 0.19s 0.19s -bash
obama pts/4 adsl-7x-4x-1x-18 Mon18 47:18m 0.00s 0.01s sshd: obama [priv]


root@server1056 [/root]# write obama pts/4

hey bud, please call me, I lost your no. since my cell was stolen.

root@server1056 [/root]#

After typing “write obama pts/4” as the command hit enter key once,

then type your message and hit your enter key once to push the message.

then hit ctrl+d to exit out of the write session.

Advertisements
h1

Error: Missing Dependency: perl(Convert::ASN1) is needed by package samba

April 1, 2010

Error
root@server276 [~]# yum -y install samba samba-client samba-common
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: hpc.arc.georgetown.edu
* base: mirror.trouble-free.net
* extras: ftp.lug.udel.edu
* rpmforge: apt.sw.be
* updates: mirror.clarkson.edu
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package samba.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
–> Processing Dependency: perl(Convert::ASN1) for package: samba
—> Package samba-client.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
—> Package samba-common.i386 0:3.0.33-3.15.el5_4.1 set to be updated
—> Package samba-common.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
–> Finished Dependency Resolution
samba-3.0.33-3.15.el5_4.1.x86_64 from updates has depsolving problems
–> Missing Dependency: perl(Convert::ASN1) is needed by package samba-3.0.33-3.15.el5_4.1.x86_64 (updates)
Error: Missing Dependency: perl(Convert::ASN1) is needed by package samba-3.0.33-3.15.el5_4.1.x86_64 (updates)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.

Soln

root@server276 [~]# wget http://dag.wieers.com/rpm/packages/perl-Convert-ASN1/perl-Convert-ASN1-0.21-2.el5.rf.noarch.rpm
root@server276 [~]# rpm -Uvh perl-Convert-ASN1-0.21-2.el5.rf.noarch.rpm
Preparing… ########################################### [100%]
1:perl-Convert-ASN1 ########################################### [100%]
root@server276 [~]# yum -y install samba samba-client samba-common
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: hpc.arc.georgetown.edu
* base: mirror.trouble-free.net
* extras: ftp.lug.udel.edu
* rpmforge: apt.sw.be
* updates: mirror.clarkson.edu
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package samba.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
—> Package samba-client.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
—> Package samba-common.i386 0:3.0.33-3.15.el5_4.1 set to be updated
—> Package samba-common.x86_64 0:3.0.33-3.15.el5_4.1 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Installing:
samba x86_64 3.0.33-3.15.el5_4.1 updates 16 M
samba-client x86_64 3.0.33-3.15.el5_4.1 updates 5.7 M
samba-common i386 3.0.33-3.15.el5_4.1 updates 8.7 M
samba-common x86_64 3.0.33-3.15.el5_4.1 updates 8.8 M

Transaction Summary
==============================================================================================================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 40 M
Downloading Packages:
(1/4): samba-client-3.0.33-3.15.el5_4.1.x86_64.rpm | 5.7 MB 00:03
(2/4): samba-common-3.0.33-3.15.el5_4.1.i386.rpm | 8.7 MB 00:03
(3/4): samba-common-3.0.33-3.15.el5_4.1.x86_64.rpm | 8.8 MB 00:02
(4/4): samba-3.0.33-3.15.el5_4.1.x86_64.rpm | 16 MB 00:04
————————————————————————————————————————————————————–
Total 2.7 MB/s | 40 MB 00:14
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : samba-common 1/4
Installing : samba-common 2/4
Installing : samba-client 3/4
Installing : samba 4/4

Installed:
samba.x86_64 0:3.0.33-3.15.el5_4.1 samba-client.x86_64 0:3.0.33-3.15.el5_4.1 samba-common.i386 0:3.0.33-3.15.el5_4.1
samba-common.x86_64 0:3.0.33-3.15.el5_4.1

Complete!
root@server276 [~]#

h1

Install Latest postgresql using yum from pgsqlrpms

September 29, 2008

##################################################

[root@server ~]# yum erase postgresql postgresql-server
[root@server ~]# wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-4.noarch.rpm
[root@server ~]# rpm -ivh pgdg-centos-8.3-4.noarch.rpm
[root@server ~]# yum install postgresql postgresql-server
[root@server ~]# chkconfig postgresql on
[root@server ~]# service postgresql initdb
[root@server ~]# chkconfig postgresql on && service postgresql start

[root@server ~]# /usr/bin/postgres –version
postgres (PostgreSQL) 8.3.4
[root@server ~]#

Set port and the interface to bind to

#########################################

vi /var/lib/pgsql/data/postgresql.conf

# – Connection Settings –

listen_addresses = ‘*’
port = 5432

h1

NMAP

September 23, 2008

echo ” ========== Installing NMAP network Scanner ================= ”
echo “…………………………………………………………………………………………………………………..”
echo “…………………………………………………………………………………………………………………..”

echo “Cleaning old nmap installation, if any ”

yum -y remove nmap
echo “…………………………………………………………………………………………………………………..”
echo “Install beings ”
yum -y install nmap

if [ -f /usr/bin/nmap ]
then

echo ” Nmap successfully installed”
sleep 2
echo ” Testing Nmap ”
echo ” ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
sleep 3
/usr/bin/nmap localhost -v
sleep 5
else
echo ” Nmap faield to install”
fi

echo ” =========== Install NMAP network Scanner process completed  ===============”
echo “…………………………………………………………………………………………………………………..”
echo “…………………………………………………………………………………………………………………..”
echo “…………………………………………………………………………………………………………………..”

h1

MySQL ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

August 25, 2008

The other day I got this error on one of our servers. Fantastico module in cpanel was showing the error: Unable to connect to mysql database.  While mysql service was running fine, the root user was unable to login to mysql database. I initially tried to reset the mysql root password like https://rhcelinuxguide.wordpress.com/2008/08/08/reset-mysql-root-password/   but that did not help.  The real issue was permission on the folder /var/lib/mysql/mysql .  It is supposed to be 711 , while it was  751.  That fixed it.

==================================================================

root@server1 [~]# mysql
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
root@server1 [~]#

root@server1 [/var/lib/mysql/mysql]# ls -lhd /var/lib/mysql
drwxr-x–x 179 mysql mysql 12K Aug 25 01:44 /var/lib/mysql/

root@server1 [/var/lib/mysql/mysql]# chmod  711 /var/lib/mysql/mysql

root@server1 [/var/lib/mysql/mysql]# ls -lhd /var/lib/mysql/mysql
drwx–x–x 2 mysql mysql 4.0K Aug 25 01:32 /var/lib/mysql/mysql/

root@server1 [/var/lib/mysql/mysql]# service mysql restart
Shutting down MySQL..

[  OK  ]
Starting MySQL                                             [  OK  ]
root@server1 [/var/lib/mysql/mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a-community MySQL Community Edition (GPL)Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer. 

mysql> quit
Bye
root@server1 [/var/lib/mysql/mysql]#

==================================================================
Worked for me !
If above steps does not work, you can try this:
root@server1 [~]# /etc/init.d/mysqld stop
root@server1 [~]# safe_mysqld –skip-grant-tables &
root@server1 [~]# mysql
root@server1 [~]# USE mysql
mysql>  UPDATE user SET password=password(“new root passwd”) WHERE user=”root”;
mysql> flush privileges;
mysql> exit 

root@server1 [~]# killall mysqld mysql

root@server1 [~]# /etc/init.d/mysqld start

You can check the root mysql password in /root/.my.cnf  ( assuming you have set it up)

Sample /root/.my.cnf
#######################

root@server1 [~]# cat /root/.my.cnf
[client]
user=”root”
pass=”V1<)4K5.8″
root@server1 [~]#

h1

Virtuozzo Upgrade : Upgrading from Virtuozzo3 to Virtuozzo4

August 18, 2008

Upgrading from Virtuozzo 3 to Virtuozzo 4
================================

First of all refer to :  http://www.parallels.com/en/products/virtuozzo/easy-upgrade/ for detailed explanation. When I decided to upgrade, there was not much available except the above docs. I used the inbuilt vzup2date for the upgrade purpose.

First of all apply all updates on your current Virtuozzo 3 using vzup2date , by selecting udate for virtuozzo 3.0.x only. Once updates are applied, it also does a kernel upgrade. It will finally ask if you want to reboot. Just select finish, and dont reboot. It is better to reboot manually, so that you can swith back to old kernel, in case the new kernel panics or hang up during boot.

Step 1
===================================================

[root@vpsMainNode virtuozzo]# vzup2date

Apply all updates on your current Virtuozzo 3.
Select option reboot manually and dont hit the reboot option, just select finish.

Next,

Edit /etc/grub.conf  and change the option

default=0 to default=1 , so that the current kernel is selected in grub , instead of the new kernel , that was just installed.

Next we configure grub to boot the new kernel only for the next reboot. If the reboot does not go well and the system does not boot properly, do a hard reset ( ask your DC, if

reqd. ) and you will successfully boot into the last working kernel.

[root@vpsMainNode virtuozzo]# grub shell
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB  version 0.95  (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported.  For the first word, TAB
lists possible command completions.  Anywhere else TAB lists the possible
completions of a device/filename.]

grub> savedefault –default=0 –once
grub> quit

[root@vpsMainNode virtuozzo]#

Reboot the server. If all goes fine, and the server comes up with the new kernel, edit /etc/grub.conf  and change the option

default=1 to default=0

Next,

Run vzup2date again and select updates for Virtuozzo 3 , and go next , next to finish install ( select option manual reboot )
[root@vpsMainNode virtuozzo]# vzup2date

If all Virtuozzo 3 are already applied, you will see no more update available message.

Now that Virtuozzo 3 has all its latest stuff in its version, we will update Virtuozzo 3 to Virtuozzo 4.

Run vzup2date again,
[root@vpsMainNode virtuozzo]# vzup2date

This time, select Virtuozzo 4 for upgrades, do the usual next , next to apply updates. ( select option manual reboot )

This process will take some time depending on speed. Usually 20 to 60 minutes.

Again this will install a newer kernel, so

Next we configure grub to boot the new kernel only for the next reboot. If the reboot does not go well and the system does not boot properly, do a hard reset ( ask your DC, if

reqd. ) and you will successfully boot into the last working kernel.

[root@vpsMainNode virtuozzo]# grub shell
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB  version 0.95  (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported.  For the first word, TAB
lists possible command completions.  Anywhere else TAB lists the possible
completions of a device/filename.]

grub> savedefault –default=0 –once
grub> quit

[root@vpsMainNode virtuozzo]#

Reboot the server. If all goes fine, and the server comes up with the new kernel, edit /etc/grub.conf  and change the option

default=1 to default=0

Voila !   you have upgraded your server from Virtuozzo 3 to Virtuozzo 4. You will see that all nodes will work properly, start the nodes, if any active node is down in the usual

way.

[root@vpsMainNode virtuozzo]# vzctl start VE_ID

Note VE_ID is now also called as CT_ID ( container ID )

You will find that the Service VE ( now called as Service Container )  will fail to start. If not, then fine. You have nothing left to do , except running a vzup2date again and

apply any newer updates for one more time. If any new kernel is installed , then modify grub.conf as already discussed, while rebooting.

In case Service VE ( now called as Service Container )  fails to start or does not start, you will be unable to access your virtuozzo control panel.

Note , I destroyed old Service VE and recreated it, if for any reason, you want backup of old service , you might chose to make a backup of it.

Here is what I did to install the service CT
###############################################
[root@vpsMainNode virtuozzo]# vzctl destroy 1
[root@vpsMainNode virtuozzo]# cd /root/
[root@vpsMainNode virtuozzo]# wget http://download.parallels.com/virtuozzo/virtuozzo4.0/linux/iso/lin-i386.iso
[root@vpsMainNode virtuozzo]# mkdir /mnt/iso
[root@vpsMainNode virtuozzo]# mount -o loop lin-i386.iso /mnt/iso
[root@vpsMainNode virtuozzo]# vzsveinstall -D /mnt/iso -s xx.yy.zz.IP

[root@vpsMainNode virtuozzo]# vzlist -a | grep CT
CTID      NPROC STATUS    IP_ADDR         HOSTNAME
1         77 running   xx.yy.zz.IP  ServiceCT
[root@vpsMainNode virtuozzo]#

[root@vpsMainNode virtuozzo]# lsof  -i :4643
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE NODE NAME
vzaproxy  531   root    4u  IPv4 10286471       TCP *:4643 (LISTEN)
vzcp      591   root    4u  IPv4 10286403       TCP *:4643 (LISTEN)
vzcp      595 apache    4u  IPv4 10286403       TCP *:4643 (LISTEN)
vzcp      596 apache    4u  IPv4 10286403       TCP *:4643 (LISTEN)
vzcp     3004 apache    4u  IPv4 10286403       TCP *:4643 (LISTEN)
[root@vpsMainNode virtuozzo]#

[root@vpsMainNode virtuozzo]# vzctl  restart 1
Restart Container
Stopping Container …
Container was stopped
[  OK  ] down vzagent: [  OK  ]
[  OK  ] vzagent: [  OK  ]
Container is unmounted
Starting Container …
Starting vzagent: [  OK  ]
Starting vzagent: [  OK  ]
Container is mounted
Setting devperms 20006 dev 0x7d00
Adding IP address(es): xx.yy.zz.IP
Hostname for Container set: ServiceCT
File resolv.conf was modified
Container start in progress…

[root@vpsMainNode virtuozzo]# vzlist  -a | grep CT
CTID      NPROC STATUS    IP_ADDR         HOSTNAME
1         77 running   xx.yy.zz.IP  ServiceCT
[root@vpsMainNode virtuozzo]#

[root@vpsMainNode log]# cd /root/
[root@vpsMainNode ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             9.9G  4.1G  5.3G  44% /
/dev/sda1             494M   81M  388M  18% /boot
none                  4.0G     0  4.0G   0% /dev/shm
/dev/sda3             448G  267G  158G  63% /vz
/dev/sdb1             459G  123G  313G  29% /backup
/root/lin-i386.iso    582M  582M     0 100% /mnt/iso

[root@vpsMainNode ~]# mkdir /root/virt4_source
[root@vpsMainNode ~]# cp -r /mnt/iso/* /root/virt4_source/
[root@vpsMainNode ~]# umount /mnt/iso

[root@vpsMainNode ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             9.9G  4.7G  4.8G  50% /
/dev/sda1             494M   81M  388M  18% /boot
none                  4.0G     0  4.0G   0% /dev/shm
/dev/sda3             448G  267G  158G  63% /vz
/dev/sdb1             459G  123G  313G  29% /backup
[root@vpsMainNode ~]#

Congrats !!! , now that you have got the Service Container Up and Running, time to explore/enjoy the new looks in Virtuozzo 4 control panel.

h1

Reset MySQL Root Password

August 8, 2008

[root@dedicated08 ~]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 31792 mysql 3u IPv4 434089 TCP *:mysql (LISTEN)
[root@dedicated08 ~]# kill -9 31792
[root@dedicated08 ~]# /etc/init.d/mysql start
Mysql Started

[root@dedicated08 ~]# mysql
Access denied for user ‘root’@’localhost’ (using password: NO)

[root@dedicated08 ~]# /etc/init.d/mysql stop

[root@dedicated08 ~]# mysqld_safe –skip-grant-tables &

[root@dedicated08 ~]#
[root@dedicated08 ~]# mysql -u root
mysql>
mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where
User=’root’;
mysql> flush privileges;
mysql> quit

NEW-ROOT-PASSWORD above is whatever password you want to set.

[root@dedicated08 ~]# # /etc/init.d/mysql stop
[root@dedicated08 ~]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 31792 mysql 3u IPv4 434089 TCP *:mysql (LISTEN)
[root@dedicated08 ~]# kill -9 31792
[root@dedicated08 ~]# fuser -k /usr/bin/mysqld_safe ( in
case you see mysql process is still running )

[root@dedicated08 ~]# vi /root/.my.cnf
[root@dedicated08 ~]# cat /root/.my.cnf
[client]
user=”root”
pass=”NEW-ROOT-PASSWORD”
[root@dedicated08 ~]#

[root@dedicated08 ~]# service mysql restart

[root@dedicated08 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.21-standard-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> quit
Bye
[root@dedicated08 ~]#