November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

tcpdump

tcpdumptcpdump -nn -ni eth0tcpdump -i eth0tcpdump -i eth0 -n

tcpdump -nn -ni eth0

tcpdump -nn -ni eth0 host 192.168.1.100

tcpdump -nn -ni eth0 src host 192.168.1.100

tcpdump -nn -ni eth0 dst host 192.168.1.100

tcpdump -nn -ni eth0 src host 192.168.1.100 and dst port 80

tcpdump -nn -ni eth0 host 192.168.1.100 or host 192.168.1.101

tcpdump -i […]

VI – Search and Replace with a pathname

Find and replace with VI on a pathname is a bit tricky you ned to use escape characters.

In this case /bin/mail should be replaced with /usr/bin/mail

The command below would do it:

:%s/\/bin\/mail/\/usr\/bin\/mail/g

 

Find and Replace Example

Here is an example of find and replace with VI, this will replace every instance of […]

Rebuild corrupt RPM database

Sometimes RPM databases become corrupt. You will no longer be able to install/upgrade/remove programs using YUM or RPM command. Even RPM quey simply gets hung.This is the case when you need to repair RPM databases.

To repair do the following:

cp -rp /var/lib/rpm{,`data +%F`.bk} This command is to take a backup of ‘ /var/lib/rpm‘ […]

Netstat

HOW TO CHECK WHETHER LINUX SERVER IS UNDER DDOS ATTACK

DDOS – Distributed Denial of service attack

DDOS or DOS (Denial of service ) is an attack in the server , where the server resources become unavailable to the users. It can be typically defined as the loss of network connectivity and […]

Linux commands for Reference

find . -type f -exec grep ‘NMX_FXNG_AND_CONTRACT_DBF’ {} \;

history

history|awk ‘{print $2}’|awk ‘BEGIN {FS=”|”} {print $1}’|sort|uniq -c|sort -r

history|tail -1000|awk ‘{print $2}’|awk ‘BEGIN {FS=”|”} {print $1}’|sort|uniq -c|sort -r

-daystart This flag starts at the beginning of the day.-atime The time the file was last accessed — in number of days.-ctime The time […]

7zip

zip is a nice, cross-platform compression software, similar in purpose to WinZip or GZip. &zip can create and extract those .zip and .gz (and tar.gz) files, but it uses LZMA for its own native compression, which is a much more modern compression format. (if you’re using .rar, please stop already).

Use 7zip to create a […]

Delete old logs

#!/bin/sh #Script to remove 10 days old logs # /usr/bin/find /opt/logs -type f -mtime +10 -exec rm {} \;

Removing blank lines from a text file

Method 1: Using grep

$ grep -v ‘^$’ infile.txt > outfile.txt

Method 2: Using sed

$ sed ‘/^$/d’ infile.txt > outfile.txt

To remove blank lines from multiple files a script like the one below can be used

#!/bin/sh files=”/somefolder/*.txt” for f in $files do sed ‘/^$/d’ $f > $f.tmp mv $f.tmp $f done

GZIP COMMAND

Gzip is one of the frequent command used in linux . gzip command is use do to compression of a file for reducing size of file. This will saves the bandwidth if the file is transferring between different systems.Moreover the reduced size depends on the the content of the file, if the content is text, […]

tar

tar [-cxtzjvfpPN] file and directory …. parameters:

-c: create a compressed file parameters command (create mean); -x: parameter instructions to unlock a compressed file! -T: View file tarfile inside! Special attention to the parameters issued, c / x / t only the existence of a! Not exist! Because it is not possible at the same […]