75 articles Uncategorized Page 2 / 8

Script for Adduser with Random pasword

I have just created a small bash script which will create user without asking for password. It will use random password. At the end it will show you username and password. I have made important 2 lines in bold and highlighted. Please note that It doesnt have any validation on User input or any other…

How to split & join large files, binary, text etc.

In Linux, we can split large files with split command. And to join you just need to cat the files into one file. Split can be used on binaries, text files whatever. To split -># split –byte=10k /path/to/large/file /path/to/output/files/prefix For eg. I want to split /root/slapd binary file. Size of it is 1.3M root@neel:~/test# ls…

How to do Authentication by PAM in PHP code

1. Check which user Apache server is running. In our eg. it is running by www-data 2. Change group ownership of /etc/shadow chgrp www-data /etc/shadow   3. Install php5-auth-pam   3. Create login.html under webserver’s DocumentRoot and put below code under <html> tag            <form name="input" action="login.php" method="post">             Username: <input type="text" name="uname" /><br />…

Starting with OpenLDAP

Starting with OpenLDAP 1. Install OpenLDAP on Ubuntu2. apt-get install slapd ldap-utils gq db4.8-util db4.8-doc jxplorer3. Create slapd.conf /usr/share/slapd/slapd.conf or whereever you want only thing it should be readable. Change domain components and admin password, dn as per your requirement4. Please check apparmor is off5. Please check /var/run/slapd directory is there or not. If yes…

 Script to get the list of services running on system in below format: Protocol – Port – Program Name for LIST in `netstat -nalpe | egrep -i ‘^tcp|^udp’ | grep ‘LISTEN’ | awk ‘{ print $1"|"$4"|"$9 }’`; do PROT=`echo ${LIST} | cut -d"|" -f1`; PORT=`echo ${LIST} | cut -d"|" -f2`; PORT=${PORT##*:}; PROG=`echo ${LIST} | cut…

Virtual hosting in Apache

There are 2 types of VirtualHosting:1. Name Based Virtual Hosting2. IP Based Virtual Hosting 1. Name Based Virtual Hosting:In this we host multiple websites on Single IP.Here is the basic configuration for name based virtual hosting in httpd.conf: ======================== NameVirtualHost  ganesh.com <———– <VirtualHost ganesh.com>    ServerAdmin webmaster@ganesh.com    DocumentRoot /var/www/html    ServerName ganesh.com    ServerAlias www.ganesh.com    ErrorLog logs/ganesh.com-error_log    CustomLog…

Linux Boot Process (Simplified)

Linux Boot Process is consist of all process from starting PC upto userspace initialization in Linux. We will make simple flow of Linux Boot Process Power ON || ||BIOS || ||Stage 1 Boot Loader –> MBR || ||Stage 2 Boot Loader –> LILO/GRUB || ||Kernel –> Linux || ||init -> Father of all processes Overview…

Configuring Apache with Authentication

Basic Authentication: 1. Create user database with htpasswdhtpasswd is a program which create user database. In this example we will create users in /etc/apache2/users     $ htpasswd -c /etc/apache2/users test  ===========> Here test is username 2. Server side configuration: Here in httpd.conf or your virtual host configuration file between <Directory … >  </Directory> Give following…

Tuning MySQL

 1. To know current default values for mysqld give               $ mysqld –verbose –help 2. While Tuning MySQL, 2 values are most important      a. key_buffer_size  –> key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.The maximum permissible setting for…