Tuesday, January 11, 2011

CSF IP block removal

1) How to remove temporary ip block:
you can ckeck /var/log/lfd.log file to find whether the ip is blocked or not, by using
grep <ip> /var/log/lfd.log

If it blocked you need to do the following step to remove that block
csf -tr <blocked ip>


Then you must restart the csf firewall.
csf -r




2) How to remove permanent ip block:
you can check /etc/csf/csf.deny file to find whether the ip is blocked or not.
grep <ip> /etc/csf/csf.deny

If it blocked you need to do the following step to remove that block
csf -dr <blocked ip>

Then you must restart the csf firewall.
csf -r

Saturday, January 8, 2011

grep linux command

Find the lines that are matching for a given string from the specified file.


Syntax:


grep <option> "pattern" /path/of /file/to/be/searched


Example:


grep root /etc/passwd – The command searches for the pattern root in the file /etc/passwd and print the lines that matches the pattern.



grep -c /bin/tcsh /etc/passwd - List the number of users who use tcsh

grep -l '^#include' /usr/include/* - List header files that have at least one #include directive


Options:




-c, --count
              It prints a count of matching  lines for  each  input  file.



 -n, --line-number
              Print each line of output with the line number within its input
              file.



-o, --only-matching
              Show only the part of a matching line that matches the pattern.



-R, -r, --recursive
              Read all files under each directory, recursively; this is equiv-
              alent to the -d recurse option.



mkdir linux command

Linux command to create a new directory. mkdir command creates a new directory if it does not already exist.


Syntax


mkdir [option] new directory name


Example:


mkdir mydir - This would create a new directory called mydir.


mkdir -p /test/mydir – This would create a directory mydir in test directory and if test directory does not exists it would create test directory and then the directory mydir.


mkdir -m 444 atom - This would creates a directory 'atom' with read only permission to all.


Options:



-m, --mode
              add access permission for newly created directory.
-p, --parents
              creates the new directory in the parent directory if exist, otherwise make parent directories as needed

-v, --verbose
              It prints a message like "created directory"  for each newly created directory.

ls linux command



Ls command is used to list the contents of a directory. If no directory names are given, list the files in the current directory otherwise list the files in the given directory.



Examples

ls -l
In the above example this command would list each of the files in the current working directory and the files permissions, the size of the file, date of the last modification, and the file name or directory.

Syntax


ls [option] /path/of/directory


Options


-a, --all
do not hide entries starting with ‘.’(show all hidden files)


-l,  --file-details
use a long listing format.


-d, --directory
list directory entries instead of contents


-i, --inode
with -l, print the index number of each file


-r, --reverse
reverse order while sorting

-R, --recursive
list subdirectories recursively

-s, --size
with -l, print size of each file, in blocks

-S, --sort
sort by file size

-t, --sort
sort by modification time

-v, --sort
sort by version

-X, --sort
sort alphabetically by entry extension

-1, --line
list one file per line

Thursday, January 6, 2011

FTP linux directory structure

ProFTPD:

Program :/usr/sbin/proftpd

Init Script :/etc/rc.d/init.d/proftpd

Conf: /etc/proftpd.conf

Log: /var/log/messages, /var/log/xferlog

FTP accounts file – /etc/proftpd/username – all ftp accounts for the domain are listed here


Pure-FTPD:

Program : /usr/sbin/pure-ftpd

Init Script :/etc/rc.d/init.d/pure-ftpd

Conf: /etc/pure-ftpd.conf

Anonymous ftp document root – /etc/pure-ftpd/ip-address

ssh, perl, php directory structure

SSHD:

Program :/usr/local/sbin/sshd

Init Script :/etc/rc.d/init.d/sshd

/etc/ssh/sshd_config

Log: /var/log/messages



Perl:

Program :/usr/bin/perl

Directory :/usr/lib/perl5/5.6.1/



PHP:

Program :/usr/local/bin/php, /usr/bin/php

ini file: /usr/local/lib/php.ini – apache must be restarted after any change to this file

mysql directory structure

Program : /usr/bin/mysql

Init Script : /etc/rc.d/init.d/mysql

Conf : /etc/my.cnf, /root/.my.cnf

Data directory – /var/lib/mysql – Where all databases are stored.

Database naming convention – username_dbname (eg: john_sales)

Permissions on databases – drwx 2 mysql mysql

Socket file – /var/lib/mysql/mysql.sock, /tmp/ mysql.sock