Posts

Showing posts from 2014

Fix conky hiding

I have installed and got some conky script but after system starting its hiding automatically and the only way I can see it while shutting down. So I have googled and got some solution which can fix my problem. Open your conkyrc file which is a hidden file  in home directory with $ vim  .conkyrc or $ vim ~/.conkyrc Find the area of below lines and make the configuration as I have mentioned. own_window yes own_window_class Conky own_window_type normal own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager  own_window_transparent yes Then save and exit from your conkyrc file. Then in we have to reload the conky with updated configuration , so all you have to do is kill the conky and then start it again. so In your terminal as root user do as # killall conky & conky or $ su -c " killall conky & conky"   I hope that will help you.

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

Use Wget for downloading from FTP with username and Password

Hi , We all know we can use wget to download files from command-line. Downloading files from FTP can be done but for with username and password you have to scroll manpage a lot. wget --user <username> --password <password> ftp://xxx.xxx.xxx.xxx/dir/file/download to resume wget -c --user <username> --password <password> ftp://xxx.xxx.xxx.xxx/dir/file/download

Automation with Cron

In every linux cron service we found and it is most familiar command to every system administrator. I am proud to be one of them. CRON - Introduction : The cron is a daemon and we can manage it with service names crond. Cron is the best solution in all sort of Linux Operating systems to run scritps,commands at a determined or specified time. So as I did mentioned it is a service it will start with system and do its running as long as system running. Generally cron will executes commands or scripts in "sh" shell (/bin/sh) . If you want to run your script in a different shell dont forget mentioning it before executing the command. Cron Configuration file will be called as cron table and we can invoke it with command named as "crontab". Every user in linux have his/her own crontab and all users cron configurations will store at /var/spool/cron. All the cron jobs will be recorded at location /var/cron/log or /var/adm/cron/log. CRON - Format : Minute     Hour      DayofM

How to remove Shutdown,restart options from startmenu in windows server 2008.

1. Open run 2.Type gpedit.msc 3.choose User Configuration -> Administrative Templates -> Start menu & Task Bar Choose  Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands and open it and select enabled. Then see whether it is updated or not. If its not updated then open run and type as gpupdate /force and now shutdown,restart removed from start menu.

Basic MySQL Administration

1. How to create a user and along with his privileges automatically ? GRANT ALL PRIVILEGES ON database.* To 'username'@'hosr or IP ' IDENTIFIED BY 'password'; flush privileges; 2. How to give only specific privileges to users ? GRANT select,lock tables ON *.* To 'user'@'host or IP ' IDENTIFIED BY 'password'; flush privileges; 3. How to see permissions of a user ? show grants for 'username'@'hostanme'; 4. How to revoke all given privileges ? revoke all privileges on *.* from 'user'@'host'; 5. How to take backup of database ? mysqldump --user <username> --password=<password> databasename > databasebackup.sql 6. How to take backup of two databases ? mysqldump --user <username> --password=<password> databasename1 databasename2 > databasebackup.sql 7. How to take backup of all databases in MySQL ? mysqldump --user <username> --password=<password> -all-databases   >

Reset root password in CentOS 6

In CentOS base version , I mean v6 there is a bug and you cant reset the password in the usual way. I am going to mention both the ways. To reset root password of CentOS machine, Start your PC. You will get GRUB screen and there choose " e" to edit booting kernel. After that It will open in a new window with current configuration. If you observe there you can find a line with two last words like  " rhgb quiet \" Dont worry about "\" , use backspace and remove " rghb quiet". Then add in that line as " a 1 " and then press F10 key to boot. it will successfully boot into /bin/sh and there by using passwd command you can reset the root  password of the server. If its not working . 1 . SELinux may be causing the problem , to take care of it you have to restart Machine and again edit GRUB , but this time we have to one more parameter extra. Now add parameters like " a selinux=0 1 " , So CentOS will boot into /bin/sh with permissive

CentOS 7 not detecting Windows

Install ntfs-3g package and you should be able to mount your Windows OS installed partition then after mounting it run command as grub2-mkconfig -o /boot/grub2/grub.cfg There you will see Windows getting detected in updated grub configuration. Hope it helps.

CentOS 7 Repositories

EPEL for CentOS 7 ## RHEL/CentOS 7 64-Bit ## # wget http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm # rpm -ivh epel-release-7-0.2.noarch.rpm RPMForge for CentOS 7 sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt sudo yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm Remi for CentOS 7 sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm sudo sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/remi.repo Note: Didnt get full information about RPM Fusion , if anybody get it let me know.

Explanation of /etc/fstab

Image
What is fstab file? fstab is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under  /etc , so the full path to this file is /etc/fstab. /etc/fstab contains information of where your partitions and storage devices should be mounted and how. If you can't access your Windows partition from Linux, aren't able to mount your CD or write to your floppy as a normal user, or have problems with your CD-RW, you probably have a misconfigured /etc/fstab file. So, you can usually fix your mounting problems by editing your fstab file. /etc/fstab is just a plain text file, so you can open and edit it with any text editor you're familiar with. However, note that you must have the root privileges before editing fstab. So, in order to edit the file, you must either log in as root or use the su command to become root. Sample fstab file looks like this Note that this system has two IDE partitions, one which is used a

Install lshw in CentOS 6.X

While I am trying to use the command lshw in CentOS 6 , I just came to know that it is not installed and not available in main repo. To install lshw in your CentOS PC . 1. Open Link :  http://pkgs.repoforge.org/lshw/?C=M;O=D 2. Copy download link of latest rpm package 3. Install with yum rather than using rpm , if you use rpm then it will fail due to missing dependencies. so better to use yum. # wget http://pkgs.repoforge.org/lshw/lshw-2.17-1.el3.rf.i386.rpm # yum install lshw-2.17-1.el3.rf.i386.rpm After installing you can use it, simply type as lshw in the terminal. lshw - simple meaning is list hardware . It will list total information about hardware in your PC or Server. It will give very big output , so you better choose the desired output by using grep. For example I just want VGA information : [root@localhost ~]# lshw | grep VGA              description: VGA compatible controller              product: SVGA II Adapter [root@localhost ~]#

Process Management

Hello , My new blogpost is about Process Management and I have gone all concepts of Process Management. I have written this document with help of .Doc and it consists of images. So its hard to maintain the format in blogger too. I am placing the download link , Please use that link to download. I hope it helps you. To Download my post Please click here

TCP Wrappers

Image
The Simple thing I can tell us all about TCP Wrappes is  " TCP Wrappers are Host-Based Networking Access Control List (ACL) System & used to filter Network access to Internet. For all services in Linux TCP wrappers cant be applicable by default and its possible if source of the service got compiled with libwrap. To check whether given service is compatible or not with TCP Wrappers , do as ldd  /path/to/service | grep libwrap.so For example lets check sshd service having support or not. ldd /var/sbin/sshd | grep libwrap.so Now it will print some output like its there for sshd. Similarly you can check for any other service you want. Wild Card Entries: ALL ,LOCAL, UNKNOWN,KNOWN. 1. To block all hosts from accessing all services remotely # vi /etc/hosts.deny ALL : ALL It will drop all the connections. 2. Allow all except one domain ALL : @support ALL : .tech.com EXCEPT development.tech.com 3. Placing logs for unauthorized access ALL: .developement.com : spawn /bin/echo %a from %h

SSH configuration: sshd_config file

In SSH Server , we do have two types of configuration files. They are sshd_config and ssh_config. Here sshd_config is all about server side configuration. The behavior of SSH server written at this file. In this article I am writing a simple article with few best practices over sshd_config. Note: For edit that you are doing to sshd_config , you must restart sshd service. Please review my last article about ssh restart. 1. Allow login only with root and deny all other. This is actually simple. In the terminal type as a root user as menioned below # touch /etc/nologin That's it. Then restart sshd service. Now try with normal user and you wont be allowed to login. 2.SSH Protocol switching. SSH have two versions as Version-1 , Version-2 Version-1 have only feature that user based authentication.Due to this we can only know who is getting login into server but we cant see from which machine or host he is doing this and this machine may be authorized or unauthorized. Due to this its not