Saturday, December 27, 2008

Renaming multiple files in Linux or unix boxes

I thought it was simple to do this. But I couldn't get rename command to work. I tried several methods found in google, quoted below, but at last it was the for loop and the regexes which came to help.


To rename all the files in a folder to .bak extension

for i in `ls -l | awk '{print $9}'`; do mv $i $i.bak; done

Simpler,

for i in `ls -1A` do mv $i $i.bak ; done

rename 's/\.bak$//' *.bak

Is said to remove the .bak extensions , though it didnt work for me.

To change all upper case file name to lowercase try this

rename 'y/A-Z/a-z/' *

Below command did help me to remove the .bak extensions on a series of files in a folder.

for f in *.bak ; do mv "$f" "${f%.bak}"; done

Wednesday, December 24, 2008

Recovering from corrupted RPM database

When accessing the yum command, the error we got was similar to this.

error: rpmdb: damaged header #67 retrieved -- skipping.
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.main(sys.argv[1:])
File "/usr/share/yum-cli/yummain.py", line 82, in main
base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 206, in getOptionsConfig
errorlevel=opts.errorlevel)
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 132, in doConfigSetup
self.conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 598, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 667, in _getsysver
hdr = idx.next()
StopIteration

Solution is straight enough, to repair the RPM database. So how do we repair the RPM database. The straight forward method is to, remove the /var/lib/rpm/__db* and the run

rpm --rebuilddb
I believe I discussed this issue earlier in this blog itself. But that didn't fix in the first go and had to reissue the command again. And that time it did fix it.

Another solution to fix the issue is using the db_dump and db_load from the db4-utils package. This process involve re-building master package metadata file /var/lib/rpm/Packages

mv Packages Packages-BAKUP
db_dump Packages-BAKUP | db_load Packages
rpm -qa
rpm --rebuilddb

/usr/lib/rpm/rpmdb_verify Packages

That should fix it. Check out http://people.redhat.com/berrange/notes/rpmrecovery.html for yet another solution. Complicated and may not need it.

Saturday, December 20, 2008

Default Plesk Page on Windows machines

Issue was that the domain name was not in the Inetmgr (IIS configuration :-P)

D:\Program Files\SWsoft\Plesk\admin\bin>websrvmng.exe --reconfigure-vhost --vhos
t-name=domainname.com
The system cannot find the file specified. (COM Error 80070002) at add(photo.vis
imaker.com, 219.220.243.241, D:\inetpub\vhosts\domainname.com.com\httpdocs\photo)

resulted in the above error.

Solution was to create a photo folder and run it again. It did fix the issue.

Thursday, December 11, 2008

Resetting Hypervm Slave password - remote_authentication_failed

HyperVMs pass had to be reset on a slave server due to the "remote_authentication_failed" error when accessing the slave node in the slave server.

If you are receiving this error, and when you can't reset the password on the slave server from hypervm, you can manually do this on the slave server using the following commands:

lphp.exe ../bin/common/resetpassword.php slave 'put_your_pass_here'


Now there will be situations where, you still not be able to do it. In this situation, get the slave password from the master node, by logging to shell and then entering these commands there

ls -l /usr/bin/hypervmdb

Make sure that it is having 755 permissions. Or else give it.

echo "select nname, realpass from pserver" | hypervmdb

It will show you a output similar to

nname realpass
localhost ~password1
66.14.29.130 !pass2
9.212.25.156 !pass3
23.1.142.215 +pass4
141.22.16.203 !pass5
212.121.45.109 pass6

Take the pass from that list and reset the password using the command I mentioned above (ofcourse in slave). It should work.

Tuesday, September 23, 2008

Finding spammers in the Plesk server having mailenable as mail server

Yup. Finding spammers in the Plesk server having mailenable as mail server is a easy(?) task, if you know what you are doing. I am never a good windows admin, but I understand something. Often now a days, I find windows permissions to be more cumbersome than Linux, making me using the Sysinternal's (now Microsoft's) swiss knife tools every time.

So here the issue was that, my client was not able to identify the spammer. I enabled Debugging (which was off) and then logging level was increased.

regedit and went to the below location to add a debug logging level.

[HKEY_LOCAL_MACHINE\SOFTWARE\Mail Enable\Mail Enable\Connectors\SMTP]
"Debug Logging Level"=dword:0000000a

And finally disabled the admin user of the default domain in mailenable. They were sending 1 email per 10 secs and that that details logging helped. Confirmed from mailenable.msc -> System -> localhost -> Connectors -> SMTP -> queue

Sunday, September 21, 2008

cPanel postgresql update sql statements

A Update statement from a postgresql db user created from the cpanel interface will result in an error similar to below.

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission denied for relation listing in /home/username/public_html/pg_error.php on line 4

The only solutions (may be due to security aspects) available now, if you dont want to login as postgresql user and give the user more permissions is to use the cpanel username and password to update the database.

Wednesday, August 20, 2008

Plesk Windows 2003 - One website asking for password

This post is actually associated with the last post I made. But instead of editing the last post, I decided to go with a new post, since the issue happened before. After I change the password of an account, website on accessing on a browser, keeps on asking for username and password. It can be fixed by executing the following command from the cd %plesk_bin% directory.

websrvmng --update-anon-password --domain-name=domainname.com

Plesk Windows 2003 - 530 FTP user cannot login

Plesk Windows 2003 - 530 User username cannot log in. A plesk user after a server move was not able to log in.

My first attempt was to change the password which resulted in the error as below

Error: Unable to activate/deactivate domain: User or role 'username2' does not exist in this database.


As you can see that didn't fix the issue. Now I went on to change the username which resulted in the below error

Error: Unable to update hosting preferences: Unable to rename FTP user: ftpmng --rename-user failed: User "username1" doesn't exist


So that put me in the track. Before entering to the plesk database and manually updating it on, I gave it a try to use the following command (which worked!) and saved me from further hassles.

"%plesk_bin%\ftpmng.exe" --reconfigure-all

Tuesday, August 19, 2008

IIS 6.0 ASP or ASP.NET 404 Page Not found error

First of all, before telling about the issue, let me apologize to the blogger god for blogging about Windows issues too, on a Unix only blog. I currently support a windows client as well. It is a learning process and I must say that I am enjoying that too.

Okay the issue was this

I am moving a domain from a Plesk 7.6 installed server to Plesk 8.4 installed server - a relatively new one. Everything except the domain contents are moving. I didn't try to fix at the source. Instead I tarred the httpdocs and moved to the new server and extracted it there. And there began the permission issue, as expected.

Issues
--------

* Permission issue was making the website to ask for the password. Ran the Plesk permission fix from the Plesk reconfigurator and it did fix the issue.

* Once that permission was fixed, came another issue which was returning 404 on a asp page which is actually there. I asked the Sergey's google, but it was saying many things but all answers were addressing the serverwide issues, like Allowing the ASP in Web Service Extension and so on, which was already enabled.

My issue was domain specific. So had to do something with the IIS and the website in specific. Made sure that it had permissions for all users, just as any other website. So not any permission issue. And after two hours of scratching, I found that it was because there was nothing configured to process the files with .asp extension.

Steps to follow is this

1. Start -> Run -> inetmgr
2. Websites -> domain.com -> Right Click permissions
3. Home Directory --> Application Settings --> Configuration
3. Add -> Executable -> C:\WINDOWS\System32\inetsrv\asp.dll and LIMIT the verbs to GET,HEAD,POST,TRACE.

And voila that fixed the issue. Now some database connectivity is missing. Let me go back and work on that.

Thursday, June 19, 2008

cPanel compiling apache - No method to auto repair package system

My friends who use cPanel as their control panel, let me advise you first and foremost, don't use WHM to do sysadmin tasks. It will mess up the system once in a while and will leave you in dark. Similar situation happened with my friend, who was trying to compile PHP enabling the experimental PDO support through WHM. It messed up and all he could see was


!! No method to auto repair package system !!

!! Please visit http://www.cpanel.net/support/could_not_ensurepkgs.htm for help with this error. !!

!! Restoring original working apache !!


Apache stopped working. Examined a bit around 15 minutes to find out the solution. I was blindly looking around the httpd.conf and other similar configuration. But it was when I ran /scripts/easyapache, I could sniff the issue.

cPanel was not able to update the packages and problem lied in the yum updating the PDO package.A "ps -auxww | grep yum" told me the same. Process was having the status of T (or stopped). I continued the process by passing the signal 18 to it and everything and niffy after that "kill -18 PID"

Friday, May 02, 2008

SFTP and the Received message too long 1534226287 in a VPS

One of my clients, whom I act as a trainer and an admin, had an issue recently regarding the sftp. He created a vps (Lxlabs' HyperVM) named testvm with vpsid 120. The main hardware node IP be 192.168.0.1 . And the VPS IP be 192.168.0.101. He was trying to sftp testvm@192.168.0.1.

sftp testvm@192.168.0.1 was failing giving the message "Received message too long 1534226287" ;

It was a bit confusing for me, since it was a VPS and the shell assigned was /usr/bin/lxopenvz and I was not sure of the proper rc file it reads before switching the control to the vps. All I know was the shell is not verifying whether the $TERM is dump or not. And 1534226287 was translated to [roo (Decimal --> HEX --> ASCII)

So it was PS1 which is polluting the sftp stream. Spent 1 hour or so figuring out how to make it check the value of $TERM. And it was then I thought of trying the sftp root@192.168.0.101 (the VPS IP) and that worked. haha..

Client only needed to sftp to the VPS. He was not specific about sftping to root@VPS_IP or testvm@HN_IP. Spent one hour for just because of my absent mindedness. I should be more smart :-P

Monday, January 21, 2008

CyberQuiz aka IT quiz

Quizzing again.. A few information on IT industry in quiz format.

What is Wikiality.com

It is an Internet Encyclopedia dedicated to the Honorable Professor Dr. Stephen T Colbert, D.F.A and his creation truthiness

With which cyber major has Mayo Clinic set up a collaborative research facility "The Medical Imaging Informatics Innovation Centre (MI3C)" to improve the quality of patient care ?

IBM

What is 'Stevenote' ?

The colloquial term used for the keynote speeches by Steve Jobs, generally given at Apple events

Name the former CTO of the One Laptop Per Child Foundation who has started a new company called Pixel Qi to commercialize the technology for low priced laptops for poor children


Mary Lou Jepsen

With whom is Google jointly developing televisions that display internet content such as photos and videos


Panasonic

Who developed Postscript in 1985


Adobe

What 'spider' term is used for "the use of a table or structured list of URLs for Web sites (or words that hyperlink to Web sites) in order to help locate them ?

Arachnotaxis

The BlackBerry Pearl 8100 won the first BlackBerry to do way with what ?

A trackwheel. It was replaced by a miniature trackball.

What does Wikipedia define as "the act of taking a task traditionally performed by an employee or contractor and outsourcing it to an undefined generally large group of people in the form if an open call"

Crowdsourcing

In the context off spam what is spinging

Pinging from a splog to make recipients think that content of interest has been updated though that may not be the case.

Thursday, January 17, 2008

Where all standard deletion fails...

Long time, since I updated the blog eh ? A good..a bit challenging one, till I remembered the command, debugfs.

Issue

Location : One of my clients' VPS.
Concern : One of his vps clients is not restarting properly. Stucks at initializing the vzquota. Error message when doing 'vzctl start 738' is below


Starting VE ...
Initializing quota ...
vzquota : (error) quota check : lstat `photos.friendster.comphotos6968532886961_494183449s.jpg': No such file or directory
vzquota init failed [1]


Diagnosis

I couldn't find any files with the name photos.friendster.comphotos6968532886961_494183449s.jpg inside the vps, or when looking at /vz/private/738. Then did a

find . -name "*494183449s.jpg" inside the /vz/private/738. It returned me location as ./.trash/lsm/photos.friendster.comphotos6968532886961_494183449s.jpg

/me so happy. Ran
rm -f ./.trash/lsm/photos.friendster.comphotos6968532886961_494183449s.jpg
worked fine. But the problem persisted . Reason was though it didnt give any errors, it actually didnt delete the file. Ran a ls -l inside the directory lsm which showed output where it was question marks everywhere except for the name. AFAIK, name of a file is also stored in the directory info in the FS.

[root@vpsit lsm]# ls -l
total 0
?--------- ? ? ? ? ? photos.friendster.comphotos6968532886961_494183449s.jpg


So how can I fix this and make the vps start ? "rm -f filename" was not working.. neither a bigger command, "find . -exec rm -rf {} \;" nor even rm -rf /.trash or rm -rf /.trash/lsm. The directory delete was not working, since it was not empty. Tried unlink also.

[root@vpsit lsm]# find . -exec rm -f {} \;
rm: cannot remove `.' or `..'
find: ./photos.friendster.comphotos6968532886961_494183449s.jpg: No such file or directory


Then tried to turn off quota for vps ..so executed the vzquota off command and got the o/p as below

vzquota off 738
vzquota : (error) Can't open quota file for id 738, maybe you need to reinitialize quota: No such file or directory


So didnt want to initialize the quota by command, since it wont work for sure, just as in case when it starts the vps.

Temporary fix: turn off disk_quota parameter in /etc/sysconfig/vz and started the vps. Turned on the parameter later.

Permanent fix: you can't use fsck to fix this, on a live server. Not when you have to run the fsck in / itself. So fsck was not an option here. So next choice went to debugfs

here is what I did with debugfs

debugfs -w /dev/hda1
cd /vz/private/738/.trash/
unlink lsm


gone..and the issue is fixed. I dont see a proper solution anywhere in web for this ???? question marked cases of file deletion and hence this post.

I am tired of freelancing. Need to find some salaried job..Till next time..cya..