Archive for the 'Linux Support' Category

SBDavid

Renaming Files

Renaming Files

To rename all files in a directory and add a new extension the xargs command can be used:

ls | xargs -t -i mv {} {}.renamed

xargs reads each item from the ls ouput and executes the mv command. The ‘-i’ option tells xargs to replace ‘{}’ with the name of each item. The ‘-t’ option instructs xargs to print the command before executing it.

SBDavid

Simple implementation of NAT

Simple implementation of NAT

Internal network connects to the internet with a dynamic public IP address.

iptables –t nat –A POSTROUTING –i eth0 –o ppp0 –j MASQUERADE

nat:

This table is consulted when a packet that creates a new connection is encountered. It consists of three built-ins: PREROUTING (for altering packets as soon as they come in), OUTPUT (for altering locally-generated packets before routing), and POSTROUTING (for altering packets as they are about to go out).

Repairing MyISAM mySQL Tables and Databases:

Repairing MyISAM mySQL Tables/Databases.
Please note that we assume your mySQL data directory is /var/lib/mysql

cd /var/lib/mysql/DBNAME
myisamchk -r *.MYI
SBDavid

Using Netstat

To find out the largest number of established connections you can simply use something like

netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 1

To see the list of the top 10

netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn | head -n 10

To view all

netstat -an | grep ‘ESTABLISHED’ | awk ‘{print $4}’ | cut -d: -f1 | uniq -c | sort -rn
SBDavid

Disable ping request to the server

Disable ping request to the server

Diable ping using the following type:

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

or

As superuser, add the following lines to /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 1

Then run the following command to cause the change to take effect immediately:

sysctl -p

This change will persist following a reboot.

« Prev - Next »