31 January 2011
LINUX - netstat
1. Using Netstat to Count TCP Connection States
netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c
2. List TCP/UDP and it's PID
netstat -tuvnap
APACHE - Redirect http requests to https
First make sure Apache is configured for HTTPS connection and necessary SSL certificates are installed.
No non-ssl access i.e. only accept https connections
Now open httpd.conf or .htaccess file (mod_rewrite not required):
# vi httpd.conf
Append following line :
Redirect permanent / https://mail.nixcraft.com/
Any request made to http://mail.nixcraft.com will goto https://mail.nixcraft.com/
Save and close the file. Restart the Apache:
# systemctl restart httpd
No non-ssl access i.e. only accept https connections
Now open httpd.conf or .htaccess file (mod_rewrite not required):
# vi httpd.conf
Append following line :
Redirect permanent / https://mail.nixcraft.com/
Any request made to http://mail.nixcraft.com will goto https://mail.nixcraft.com/
Save and close the file. Restart the Apache:
# systemctl restart httpd
25 January 2011
LINUX - Determine number of CPU cores
# cat /proc/cpuinfo | egrep “physical\ id|core\ id”
physical id : 0
core id : 1
cpu cores : 2
If you have two CPUs in cpuinfo with the same physical id and core id, than – hyperthreading! When you have all CPUs with different physical ids, than you have SMP, and when you have CPUs with one physical id and different core ids – you have one multicore CPU. And so on…
core id : 1
cpu cores : 2
If you have two CPUs in cpuinfo with the same physical id and core id, than – hyperthreading! When you have all CPUs with different physical ids, than you have SMP, and when you have CPUs with one physical id and different core ids – you have one multicore CPU. And so on…
22 January 2011
PostgreSQL - Migrating from Oracle to Postgres Using ora2pg
LINUX - Loading data into database table
Example: To load username from /etc/passwd into a database table.
awk -F: '{print $1}' /etc/passwd > passwd_txt
cat passwd_txt | while read username; do echo "insert into {TABLE} (USERNAME,GROUPNAME,PRIORITY) values (""'$username'"", 'acct', 0);" >> users.sql; done;
awk -F: '{print $1}' /etc/passwd > passwd_txt
cat passwd_txt | while read username; do echo "insert into {TABLE} (USERNAME,GROUPNAME,PRIORITY) values (""'$username'"", 'acct', 0);" >> users.sql; done;
LINUX - awk
To print single column from a text file
#awk -F: '{print $1}' /etc/passwd
To print multiple columns from a text file
# awk -F: '{print $1,$7}' /etc/passwd
Subscribe to:
Posts (Atom)
Wordpress - Local installation in Vmware
If you're interested in exploring website design with WordPress, this guide will help you set up a WordPress instance on your local mach...
-
To print single column from a text file #awk -F: '{print $1}' /etc/passwd To print multiple columns from a text file # awk -F: '...
-
Your new IT project requires you to setup postgresql database and most of the time we get to the postgresql website and download the version...
-
SQL> select pg_size_pretty(pg_database_size(current_database())) as dbsize