Posts

Showing posts from 2013

Searching Files with grep

grep prints lines from files which match a pattern For example, to find an entry in the password file /etc/passwd relating to the user ‘nancy’: $ grep nancy /etc/passwd  grep has a few useful options: - i stands for upper/lower case (optional in your case) -r searches through files in specified directories, recursively -l prints just the names of files which contain matching lines(  stands for "show the file name, not the result itself`. ) -c prints the count of matches in each file -n numbers the matching lines in the output -v reverses the test, printing lines which don’t match R stands for recursive. Patter  Matching Use grep to fid patters, as we as simple  strings   Patters are expressed as reguar expressios grep -Ril "text-to-find-here" /   Certain punctuation characters have special  meaning   For example this might be a better way to search for acy’s etry i the password fie: $ grep ’ˆacy’ /etc/passwd   Th

How to enable TUN/TAP for OpenVZ server

SolusVM requires the TUN/TAP kernel module to be loaded for the TUN/TAP feature to work properly. To enable the TUN/TAP kernel module run this on the host node: Code: Select all #modprobe tun To check if it’s loaded run: Code: Select all # lsmod | grep tun If you see an output the module is loaded i.e: Code: Select all tun                    17536  0 Too automatically load the module on boot run these commands on the host node: Code: Select all echo modprobe tun >> /etc/rc.modules chmod +x /etc/rc.modules OpenVZ supports VPN inside a container via kernel TUN/TAP module and device.  To allow VPS #205 to use the TUN/TAP device the following should be done: #205 – VPS id. Replace 205 with your VPS id. Make sure the tun module has already loaded on the Node. [root@Node /]#  lsmod | grep tun If not listed, then load the tun module with the below command [root@Node /]# modprobe tun [root@Node /]#  lsmod | grep tun   tun    

How to view the mail queue and its messages in postfix

Here you can see how you mange postfix in linux plesk server. mailq is a very simple command that will show the messages awaiting delivery. # mailq # /usr/local/psa/admin/sbin/mailqueuemng Yet another helpful command to view more information on the emails in the queue. From this command you will receive a random id before the mail information is given. Example: 4AC531488D76 (4, D)   Return-path: lfklxmuy@domain.co.uk   From: lfklxmuy@domain.co.uk   To: willi.klippert@gmx.de   Subject: =?utf-8?Q?Was_schnellt_in_die_H=C3=B6he=2C_wenn_Sie_dieses_Angebot_nutzen=3F?=   Date: Thu, 24 Oct 2013 06:43:43 -0500 (CDT)   Size: 1478   Message-Id: <20131024114343.4AC531488D76@echo.netpivotal.com> Timestamp: 1382615023   Queue time: 1382615023   Envelope Recipients (D): 4AC0C1480643 (4, D)   Return-path: xujk@domain.co.uk   From: xujk@babywishes.co.uk   To: lars-paulsen@12move.de   Subject: =?utf-8?Q?Was_schnellt_in_die_H=C3=B6he=2C_wenn_Sie_dieses_Angebot_nutzen=3F?=

Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6

[root@server2 html]# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm Retrieving http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm warning: /var/tmp/rpm-tmp.E0T3tz: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing...                ########################################### [100%]    1:epel-release           ########################################### [100%] [root@server2 html]#   rpm -Uvhhttp://rpms.famillecollet.com/enterprise/remi-release-6.rpm Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm warning: /var/tmp/rpm-tmp.xd9I2b: Header V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY Preparing...                ########################################### [100%]    1:remi-release           ########################################### [100%] [root@server2 html]# yum install nginx* Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile epe

Managing iptables through CSF

Csf is most popular firewall in linux we will recommend it in cPanel. It's easy to use. You can enable or disable CSF safely without losing your firewall configuration. To disable CSF: csf -x To enable CSF: csf -e Managing Ports CSF can open or close ports to any and all IP addresses. This is useful when you have changed your port configuration from the standard port numbers. Simply edit the following file, using a file editor: /etc/csf/csf.conf Find the following lines, and add the port numbers you wish to open: # Allow incoming TCP ports TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,26" # Allow outgoing TCP ports TCP_OUT = "20,21,22,25,37,43,53,80,110,113,443,587,873" Blocking ports is as simple as removing the port numbers from the list. To ensure that the change takes effect, be sure to restart CSF using the following command: csf -r It is also possible to block entire countries. Be warned, however, that so

Linux monitoring tool that administrators use every day.

netstat Netstat, like ps, is a Linux tool that administrators use every day. It displays a lot of network related information, such as socket usage, routing, interface, protocol, network statistics, and more. Some of the most commonly used options are: -a Show all socket information -r Show routing information -i Show network interface statistics -s Show network protocol statistics ============= [root@server1 ~]# netstat -s Ip:     15052515222 total packets received     2847931 with invalid headers     14 with invalid addresses     15024657038 forwarded     0 incoming packets discarded     22028450 incoming packets delivered     15055903966 requests sent out     2633 outgoing packets dropped     260 dropped because of missing route     10469 fragments dropped after timeout     5600773 reassemblies required     2727990 packets reassembled ok     10469 packet reassembles failed     2710586 fragments received ok     128 fragments failed     5553326 fragments creat