Monday, 30 September 2013

Command to enable/disable ICMP PING

Ping command is basically working on sending an Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response.

echo “0″ >> /proc/sys/net/ipv4/icmp_echo_ignore_all

Many server provider and host  disabled the PING command to secure the server, refer to the following command to disable the PING command.

echo “1″ >> /proc/sys/net/ipv4/icmp_echo_ignore_all

Backup of mysql database using cron job.

To generate the backup of mysql database using cron job refer following three format as per your requirement.

1) Cron job to generate  database backup in  .sql format

* * * * * /usr/bin/mysqldump -u databaseusername databasename -ppassword > /path of database database.sql

2) Cronjob to compress database backup in .bz2 format

* * * * * /usr/bin/mysqldump -u datbaseusername databasename -pdatbasepassword|bzip2 -c > /path of database database.bz2

3)  Cronjob to compress database backup in .gz format

* * * * * /usr/bin/mysqldump -u databaseusername databasename -ppassword|gzip > /path of databasedatabase.gz

Core Files in Linux

A core file created when ever a program terminates unexpectedly and its also useful for determining what caused the termination. In many Linux server by default they do not produce core files when programs crash or terminates unexpectedly.

On  most of the Linux server core file size limitation is set to 0.You can check the core file size limit set in server by using following command.

root@test [~]# ulimit -c
1000000

In above command core file size limit is 1000000 if output occur empty then it means core file size limit haven’t set on server and you can set it as

root@test [~]# ulimit -c 1000000

or

root@test [~]# ulimit -c unlimited

If you want to test core file limit is working on your server or not? then run following command

kill -s SIGSEGV $$
This above command will crashes your shell and produces core file in the current directory. as core.*

If core file is taking lots of disk space on server and you want to disable it then follow the steps one by one.

root@test [~]#which httpd

/usr/sbin/httpd

root@test [~]#pico /usr/sbin/httpd

And following line in /usr/sbin/httpd

ulimit -c 0

And then restart the Apache server

How to generate the New Password from shell (SSH)?

If you use SSH, use mkpasswd command for creating passwords, always set the strong password, so that you won’t face the hacking issue because hackers always run the brute force attacks to crack the password therefore strong password always help to secure the server from the such attacks

root@redhat[~]#mkpasswd -l 10 -d 5 -C 3 -s 2
L]4P@GhaYdV6ii3

Flush RAM memory In Linux.

root@redhat [~]# free -m
total       used       free     shared    buffers     cached
Mem:        2025       1863        162          0        522        992
-/+ buffers/cache:        349       1676
Swap:         4996          0       4996


Now flush RAM memory.

root@redhat [~]# echo 1 > /proc/sys/vm/drop_caches

Once again check memory usage and check difference.

root@redhat [~]# free -m
total       used       free     shared    buffers     cached
Mem:          2025        353       1671          0          0         28
-/+ buffers/cache:        324       1700
Swap:         4996          0       4996

Rebuild the RPM database.




If you are facing the problem with the rpm then you can simply update the rpm database by using the following command from the shell.The following command allow you to recover the corrupt rpm database.

rm -f /var/lib/rpm/__db*
rpm --rebuilddb

How to delete - (Hypen)file names?

On most servers hackers upload files in -file format and many peoples are not sure about how to delete -files. You can refer following command to any file which started with “hyphen -”.

root@redhat.com[root]#rm -rf ./-hackscripts/