Posts

Showing posts from November, 2014

See Open Ports in a Linux PC ( Localhost/Remote Machine)

I am writing a small post that will help you just to see what ports are open in  a particular remote/local machine. we are going to use tool name as nc. To install it , open your terminal and type as  # yum install nc                               After installing , you can use it with nc -zv xxx.xxx.xxx.xxx <Port>                                            for example: nc -zv 192.168.1.100 80                                           if you want to do that for 2-3 ports nc -zv 192.168.1.100 80 8009                                             if you want to do scanning for range of ports nc -zv 192,168.1.100 80-8080 hope it will help you. T H A N K Y O U

Tutorial on .htpasswd and .htaccess with apache(httpd) in Linux

If there is a situation that have to dealt with like a public website but with some secret information. How can we protect the information ? . We can use .htpasswd and .htaccess in that time. How  ? Lets see................ Open your terminal and type as                         vim /etc/httpd/conf/httpd.conf and find line no : 334 to 338. This is the area of httpd.conf that dealt with .htaccess     334 # AllowOverride controls what directives may be placed in .htaccess files.     335 # It can be "All", "None", or any combination of the keywords:     336 #   Options FileInfo AuthConfig Limit     337 #     338     AllowOverride AuthConfig   Now look at line no 338 , before modifying it will look like                      AllowOverride None You have to modify it to                      AllowOverride AuthConfig Now make sure that if you have some website and VirtualHost configuration of that website is successfully completed. For my case that website is website1.com an

Make the system Time Zone persistent across REBOOT in Linux

Hi Guys! Are tou tired of fixing the Time Zone across reboot in your Linux box..?  Here are three simple steps for you to fix the issue. In this example we are fixing the time zone to IST. Similarly you can set it to any Time Zone of your choice. Step:1 Set the hardware clock to IST time zone # ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime Step:2 Verify the hardware clock is set to IST properly # hwclock --show Step:3 Verify the date and time also if necessary # date What if the system time is wrong..? Then follow Steps 4 to 7 Step;4 Correct system time # date -s "Tue 26 Apr 2016 19:36:00" Step:5 Sync system time to hardware clock time # hwclock --systohc --localtime Step:6 Verify hardware clock time # hwclock --show Step:7 Verify system time # date Result of Step:6 & 7 must be same. Thank You!

Fixing SELECT command denied to user 'user'@'x' for table proc

Open your hibernate.cfg file  and append this below string to your connection string.                                 Use Procedure Bodies=false;

How To do Software RAID using mdadm in CentOS

Today I am writing about how to create Software RAID. Creating Software RAID is pretty easy. All we need either 3 equal size partitions on different harddisks or 3 equal size harddisks.         In my approach , I am doing this in VmWare by choosing 3 virtual harddisks with equal 1 GB             Size. Our first step is we need to make those harddisks as ready for RAID.         In your terminal type as           # fdisk -l        To see available partitions and then try to create RAID partitions in that.         If We assume my 3 harddisks as /dev/sdb,/dev/sdc,/dev/sdd then in your terminal           # fdisk /dev/sdb         Then                   [root@ns1 sysadmin]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to          switch off the mode (command 'c') and change display units to          sectors (command 'u'). Command (m for help): m Command action    a   toggle a bootable flag    b   edit bsd disklabel    c   toggle the

VSFTPD - Passive mode port configuration

If your FTP got configured in Passive mode then to allow data transfers , you must to this. ##########/etc/vsftpd/vsftpd.conf################3 pasv_min_port=49152 pasv_max_port=65534 #############/etc/sysconfig/iptables-config############## IPTABLES_MODULES="ip_conntrack_ftp"

Virtual Hosts in Apache -Linux

############################ Listen 192.168.56.150:80 Listen 192.168.56.151:81 ############################ So above two lines are stands for IP based virtual hosting and as well as Port based Virtual Host. The virtual Host which listens to the 1st IP will browse throughh port 80 but other will listens and browse through port 81 only. Now We have to configure Virtual Hosts ######################################### <VirtulHost 192.168.56.150:80>     ServerAdmin root@localhost     DocumentRoot /var/www/website1.com     ServerName website1.com     ServerAlias www.website1.com     ErrorLog logs/www.website1.com_error.log     CustomLog logs/www.website1.com_custom.log </VirtualHost> ########################################### ########################################### <VirtualHost 192.168.56.151:81>     ServerAdmin root@localhost     DocumentRoot /var/www/website2.com     ServerName website2.com     ServerAlias www.website2.com     ErrorLog log/website2.com_error.log    

Rename Database in MySQL

Today I am writing about how to rename MySQL Database. So If you want to rename a database in MySQL dont forget taking backup of your Views,Procedures and Functions of current database. Because while you renaming changes wont apply for Views,Procedures and functions. After you have taken the backup , We can go for renaming with the command below. RENAME TABLE old_db.table TO new_db.table; Here old_db is your old database name and new_db is your new database name. You have to execute this command for each table. And this is the way. But what if w e have a big database with 1000 tables ? executing the same above command for 1000 times is a stupid idea. If you are using Linux you can use following BASH script to do that for you for table in $(mysql -p -s -N -e "show tables from db1"); do mysql -s -N -e "rename table db1.$table to db2.$table"; done; db1 is your old database name and db2 is your new database name and remaining everything will tool care by script only exc

Famous SELinux Contexts

1. httpd SELinux context                                          chcon -v --type=httpd_sys_content_t /path/to/dir 2.httpd SELinux context                     chcon -Rv --type=httpd_sys_content_t /path/to/dir 3. Restore old/default context                     restorecon -Rv -n /var/www/html                     ;    -n switch to prevent any relabelling occurring. 4. Changing default port for services permitted SELinux                                      #   semanage port -l                     #  semanage port -a -t http_port_t -p tcp 81 5. For Nagios chcon -R -t httpd_sys_content_t /usr/local/nagios            1st command to see what are the supported services. 2nd one changing default port for http service. Note: Give me time to write them with proper explanation.  More:  http://wiki.centos.org/TipsAndTricks/SelinuxBooleans

How to set the primary IP address of a Windows Server 2008 R2

Hi All..! Finally, today I got a solution for the problem continuously facing, whenever we add a new IP to our servers (Windows 2008 server), the primary IP address ( the default outgoing IP) is getting changed automatically which in turn causing lot many issues later. Here is the solution. http://www.aip.im/2013/01/how-to-set-the-primary-ip-address-of-a-windows-server-2008-r2/ This URL says that we need to install several patches, which is not mandatory for your servers as we already update the servers at the time of building them. So you can skip installing the patches and can proceed further as given below. 1) Open cmd with elevated privileges ( Run as Administrator) and add the ipaddress command-line instead of using GUI. Just run the following command in case if you are trying to add the IPADDRESS : 192.168.20.11 with SUBNETMASK: 255.255.255.0. netsh int ipv4 add address "Local Area Connection" 192.168.20.11 255.255.255.0 skipassource