Delete Files With Inode Number in Unix or how to delete files with special characters

You can use rm command to delete file.Sometimes, files are created with special characters like control characters and you will not be able to delete them, as you won’t be able to input them via a keyboard.

These files are not that easy to delete. Inode numbers comes in handy at this time.

You can find the inode value by using the following command.

geobaby@geo-desktop:~/Desktop$ ls -li
3539141 -rwxrwxrwx 2 geobaby geobaby    4096 2013-05-31 16:36 %$#%  ^%^??#$@#
3153532 -rwxrwxrwx 1 geobaby geobaby 3274861 2013-04-30 17:06 DSCF2091.JPG
3146249 -rwxr-xr-x 1 geobaby geobaby     476 2013-02-22 16:58 gnome-terminal.desktop

Next, use find command to remove the file.

find . -inum [inode-number] -exec rm -fi {} \;

And here it will be:

find . -inum 3539141 -exec rm -fi {} \;

The file will be removed.

Remove ^M characters in vi editor at end of lines

Sometimes on editing files in linux or windows, ^M (Control M) character appears at the end of lines in vi editor.

You can use sed command to remove the CTRL M characters.

$ sed -e “s/^M//” file > filenew
To enter ^M, type CTRL-V, then CTRL-M (use the CTRL keys).

You can do this in vi also.

Inside vi editor, in ESC mode, type the following

:%s/^M//g

Press Enter and you are done.

JSP and Tomcat version

The below code will help you to find the JSP, tomcat and servlet versions installed in your server or domain.

Working with server: <%= application.getServerInfo() %><br>
Servlet Specification: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %> <br>
JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().get SpecificationVersion() %><br>

Create a test page checkjsp.jsp with above code in your domain. Check the test page by using browser “http://yourdomainname/checkjsp.jsp“. It will show the tomcat version, JSP and servlet version in your domain.

Your Internet Address has changed since the beginning of your Mail session. To protect your security, you must login again

If you are unable to login into Webmail , and you are getting an Error: “Your Internet Address has changed since the beginning of your Mail session. To protect your security, you must login again.”

To fix this problem, you may do the following:

1)You can turn off ‘checkip’ feature in Horde server-wide.

2)Edit the /usr/share/psa-horde/config/conf.php file in the Plesk server and the change the following lines.

$conf[‘auth’][‘checkip’] = true;
to
$conf[‘auth’][‘checkip’] = false;

Please note that this modification cannot be configured per user basis and will affect all the webmail users in the server.

change password expiry in zimbra mail account

To change the password expiry time for a zimbra mail account, please follow the steps below.

[zimbra@geo ~]$ zmprov ma geo@geobaby.in zimbraPasswordMaxAge 36500

This modifies the value. To see if the new value is set, use the command:

[zimbra@geo~]$ zmprov ga geo@geobaby.in zimbraPasswordMaxAge
# name geo@geobaby.in
zimbraPasswordMaxAge: 36500

This can also be done from admin panel, goto account >> edit >> advanced >>  Maximum password age (Days).

http://www.zimbra.com/forums/administrators/35696-password-expiry-email-notification.html

How to mount SFTP share in Linux machine

This could be implemented using both FUSE and SSHFS.

Download both from  http://fuse.sourceforge.net/sshfs.html

1. Install FUSE

package: fuse-x.tar.gz

Extract and install
#tar xvf fuse-x.tar.gz
#cd fuse-x
#./configure
#make
#make install

After successful installation, install SSHFS

package: sshfs-fuse-x.tar.gz

Extract and install
#tar xvf sshfs-fuse-x.tar.gz
#cd sshfs-fuse-x
#./configure
#make
#make install

Now we can use sshfs to mount sftp share. Before mounting, create mount point where the share to be mounted.

#mkdir /mnt/sftpshare

Mount command:  sshfs <username>@<sftpserver IP/host>:/<sftp_share_path> /<mountpoint>

Eg:
#sshfs testuser@192.168.1.2:/home/testuser /mnt/sftpshare/

This will prompt for password if user configured any password.

NOTE:  If you want to avoid prompting for password,then you should configure key based ssh login between these servers.

Verify the mounted partition using df command.

To mount this share directory in boot time, add the following entry in /etc/fstab

sshfs#testuser@192.168.1.2:/home/testuser     /mnt/sftpshare          fuse                   defaults        0 0

NOTE:     For unmounting this partition,we can use fusermount command as below
#fusermount -u /mnt/sftpshare/

Reference: http://www.coretimer.com/howtos/how-to-mount-sftp-share-in-remote-linux-machine/

Dump Mysql Tables

Often you have encountered problems while importing large databases via phpmyadmin. In that case, you can dump the mysql tables by using the following command.

for T in `mysql -N -B -e ‘show tables from database_name’`; do echo $T;    mysqldump database_name  $T > database_name_$T.gz ;    done

Now you can restore the tables one by one through phpmyadmin.