Kurinchi Blogger Scribbles …


Archive for the ‘LINUX’ Category

Apr 14
2015

How to avoid search engines from crawling your website?

Last updated: July 14th, 2015

Your answer is to create a robots.txt file in the root of your web directory and to have the code setting given below in the file.

User-agent: *
Disallow: /

You can read more about Robots exclusion protocol, here

Mar 30
2015

How to use different Python version with virtual environments?

Last updated: July 30th, 2015

Use the flag -p with virtualenv command to specify the python version that you would want to use

$ virtualenv -p /usr/bin/python/2.7

For windows environment, use

c:\> virtualenv –python=c:\Python27\python.exe myenv

Feb 03
2015

Python: How to setup virtual environment?

Last updated: July 30th, 2015

Different projects in python may require different modules and its dependencies. Also, there may be a necessity that certain projects be run on newer/older python releases hence introducing version conflicts. Virtual environment is a tool that helps you manage these scenarios.

To install virtualenv, use pip

$ pip install virtualenv

Now, create a virtual environment “myenv”

$ virtualenv myenv

To use the virtual environment, key in

$ source myenv/bin/activate

(if in windows, key in “myenv\Scripts\activate“)

The name of your virtual environment will appear on the left of the prompt

(myenv) …$

To exit out of the virtual environment, key in

$ deactivate

Jan 02
2014

Sudo, Visudo -bash: visudo: command not found

Last updated: December 31st, 2013

Visudo is needed to make modifications to the sudoers file. In a fresh install of CentOS “sudoers” file is not normally found. To install visudo issue the command

$ yum -y install sudo

As a sys admin, you need to be careful when performing tasks with root privileges. To be cautious, you can create a new user and assign him with root privileges using “visudo”

$ /usr/sbin/visudo

# User privilege specification
root ALL=(ALL) ALL
test ALL=(ALL) ALL

In the above file, test is a new user created with root privileges. In order for the “test” user to have root privileges, command “sudo” should be used. It prevents the user from issuing any commands that can cause system wide havoc and it also logs the command inside “/var/log/secure” for review

Jan 01
2014

PostgreSQL: Create database, connect and list (command line)

Last updated: December 31st, 2013

Changing host configuration
$ vi /var/lib/pgsql/8.4/data/pg_hba.conf

Add postgresql to startup process
$ chkconfig postgresql-8.4 on

Start postgresql service
$ service postgresql-8.4 start

Access postgresql
$ su – postgresql
$ psql

Create database
postgres-# create database test

List databases
postgres-# \list

Exit postgresql
postgres-# \q (or \quit)

Connect to database
postgres-# \c test (\connect test)

Dec 31
2013

How to install PostgreSQL on CentOS Linux?

Last updated: December 31st, 2013

First lets do an update before we start installing PostgreSQL

$ yum update

You can install PostgreSQL from CentOS Base repo or can do a search for the latest version and install it based on your needs. Method 1 describes manual setup and Method 2 indicates an install from CentOS base repo (more…)

Jun 19
2013

Linux message: Partition 1 does not end on cylinder boundary

Last updated: June 19th, 2013

$ fdisk -l /dev/sda

Device Boot Start End Blocks Id System

/dev/sda1 * 1 128 1024000 83 Linux
Partition 1 does not end on cylinder boundary.

/dev/sda2 128 383 2048000 83 Linux
Partition 2 does not end on cylinder boundary.

This is not a problem and is commonly seen in new systems. (more…)

Jun 14
2013

Linux: How the password is stored, salted and hashed securely?

Last updated: June 14th, 2013

In earlier systems, passwords were stored in the file /etc/passwd and they were not encrypted.

After the user is created, an entry gets recorded in /etc/passwd with ‘x’ in the second column instead of the acutal password.

$ useradd timmy

$ cat /etc/passwd
timmy:x:1002:1003::/home/timmy:/bin/sh

For security reasons, passwords are now stored in the file /etc/shadow and they are encrypted. Password was not set initially, when the user was created. This is indicated by !! mark (in RedHat, ! – Debian)

$ cat /etc/shadow

timmy:!!:15870:0:99999:7:::

(more…)

Feb 01
2013

How to install PHPSECLIB on a WAMP environment with PEAR setup?

Last updated: March 1st, 2013

PEAR should be already installed in the system before configuring the phpseclib channel.

PHPSecLib installation is very simple.

PHPSecLib is a library of optional PHP extensions which comes in handy if the application were to be packaged as a solution for deployment to the end user.

Step 1: Register the channel

c:\> pear channel-discover phpseclib.sourceforge.net
(more…)

Jan 10
2013

How to remove ^M characters at the end of lines in Vi from files in Linux?

Last updated: February 6th, 2013

Files created in windows when moved to linux will have ^M character at the end of lines when you open the files in Vi editor.

To remove the strange characters open the file in Vi editor and type

:%s/.$// 

(more…)


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict