My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://techienote.com and update your bookmarks.

Tech Resources

Thursday, May 28, 2009

Basic Linux Commands

Following are the useful linux commands: 
FILE COMMANDS
  • ls - directory listing
  • ls -al - formatted listing with hidden files
  • cd dir - change directory to dir
  • cd - change to home
  • pwd - show current directory
  • mkdir dir - create a directory dir
  • rm file - delete file
  • rm -r dir - delete directory dir
  • rm -f file - force remove file
  • rm -rf dir - force remove directory dir *
  • cp file1 file2 - copy file1 to file2
  • cp -r dir1 dir2 - copy dir1 to dir2; create dir2 if it doesn't exit
  • mv file1 file2 - rename or move file1 to file2 if file2 is an existing directory, move file1 into directory file2
  • ln -s file link - create symbolic link link to file
  • touch file - create or update file
  • cat > file - places standard input into file
  • more file - output the contents of file
  • head file - output the first 10 lines of file
  • tail file - output the last 10 lines of file
  • tail -f file - output the contents of file as it grows, starting with the last 10 lines

SEARCHING
  • grep pattern files - search for pattern in files
  • grep -r pattern dir - search recursively for pattern in dir
  • command | grep pattern - search for pattern in the output of command
  • locate file - find all instances of file

PROCESS MANAGEMENT
  • ps - display your currently active proceess
  • top - display all running process
  • kill pid - kill process id pid
  • killall proc - kill all process named proc (use with extreme caution)
  • bg - lists stopped or backgrpund jobs; resume a stopped job in the backgrpund
  • fg - brings the most recent job to foreground
  • fg n - brings job n to the foreground

SYSTEM INFO
  • date - show the current date and time
  • cal - show this month's calender
  • uptime - show current uptime
  • w - display who is online
  • whoami - who you are logged in as
  • finger user - display information about user
  • uname -a - show kernel information
  • cat /proc/cpuinfo - cpu information
  • cat /proc/meminfo - memory information
  • man command - show the manual for command
  • df - show disk usage
  • du - show directory space usage
  • free - show memory and swap usage
  • whereis app - show possible location of app
  • which app - show which app will be run by default

COMPRESSION
  • tar cf file.tar files - create a tar named file.tar containing files
  • tar xf files.tar - extract the files from file.tar
  • tar czf file.tar.gz files - create a tar with Gzip compression
  • tar xzf file.tar.gz - extract a tar using Gzip
  • tar cjf file.tar.bz2 - create a tar with Bzip2 compression
  • tar xjf file.tar.bz2 - extract a tar using Bzip2
  • gzip file - compress file and renamed it to file.gz
  • gzip -d file.gz - decompress file.gz back to file

NETWORK
  • ping host - ping host and output result
  • whois domain - get whois information for domain
  • dig domain - get DNS information for domain
  • dig -x host - reverse lookup host
  • wget file - download file
  • wget -c file - continue a stopped download

Labels:

Wednesday, May 27, 2009

Password Protecting USB Pen Drive.

One of my user needs to create a password protected folder in its pen drive. This is very simple but one more special requirement he asked for, if he insert that pen drive in any another pc he can able to see that folder over there without any software installation. This is quite tricky requirement. I found a tool for it i.e. Rohos Mini Drive. It's a freeware with some limitations.

Rohos Mini Drive creates hidden and encrypted partition on the USB flash drive memory. You work with the files on the hidden partition without opening a special program. Those who have megabytes of sensitive files on the USB drive and seriously concerned with a data security, cannot imagine their USB stick without the hidden volume that is created using this tool.

Download the program from here. Install it and run it.

After installation the Rohos Mini Drive, insert your USB pen drive to the computer and run the Rohos Mini Drive application.
Click on Setup USB Key


Insert a password.

It will create a partition namely K: with 297mb space. You can customize the partition size by clicking Change button.

Just you have to add file in this newly created partition, when you done just eject that partion as well as the pen drive.

For testing purpose you can insert this pen drive to any another PC. There it will show you one roho_mini_pendrive icon. Double click it and insert your password that's it now you can access your password protected partition on that computer.

Labels: , ,

Monday, May 18, 2009

Cacti on CentOS

Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.
We have to install following packages on our machine.
#rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

#yum install -y mysql-server mysql php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp php-pear-Net-SMTP php-mysql httpd net-snmp-utils php-snmp net-snmp-libs

Configuring the MySQL server

#service mysqld start

Assign  root password for MySQL

# mysqladmin -u root password NEW_PASSWORD

Creating cacti database

#mysql -u root -p
enter you mysql root password
mysql>create database cacti;

Creating user for cacti and assign a new password as cacti
mysql>GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
mysql>FLUSH privileges;
mysql>exit;
Configuring snmp

Just copy my snmpd.conf file on your server, to do it

#cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
#rm -rf /etc/snmp/snmpd.conf

Copy my snmpd.file from here.

Just change the contact and network as per your requirements.

Run the following command to know wether the snmp is working or not

#service snmpd restart
#snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

Sample output
IP-MIB::ipAdEntIfIndex.192.168.213.128 = INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

Installing cacti

#yum -y install cacti

Installing cacti tables

#mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.7d/cacti.sql
(You need to type cacti user password in my case it is cacti)

Configuring cacti

#vi /etc/cacti/db.php

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";

Save the file and exit

Configuring webserver

#vi /etc/httpd/conf.d/cacti.conf

#
# Cacti: An rrd based graphing tool
#
Alias /cacti    /usr/share/cacti
 

        Order Deny,Allow
        Allow from all


Save and exit.

Restarting webserver

#service httpd restart

Cronjob for cacti

Open /etc/cron.d/cacti file and uncomment the first line.

Running cacti installer

Now cacti is ready to install. Copy the following link on your webbrowser:

http://you_server_ip/cacti/

Just follow on screen instructions. The default username and password for cacti is admin / admin. Upon first login, you will be force to change the default password.

Labels: ,

Sunday, May 17, 2009

Installing phpmyadmin on CentOS5.2

phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement. 

Prerequisites: 
mysql



To install phpmyadmin on your CentOS system run the following commands


#cd /var/www/html
#wget http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.4-english.tar.gz
#tar zxvf phpMyAdmin-3.1.4-english.tar.gz
#mv phpMyAdmin-3.1.4-english.tar.gz phpmyadmin
#cd phpmyadmin
#cp config.sample.inc.php config.inc.php

Edit config.inc.php file

#vi config.inc.php

$cfg['Servers'][$i]['auth_type'] = ‘http‘; # default is cookies


Restart your apache webserver for updating the setting

#service httpd restart


For accessing phpmyadmin http://your_server_ip/phpmyadmin
Enter your mysql username and password.


Saturday, May 16, 2009

Installing PHP5.2 on CentOS5.2

PHP  is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Installing php5.2 on your CentOS, you have to download it from jasonlitka's repository

For enabling it run the following commands:

#touch /etc/yum.repos.d/utterramblings.repo
#echo '[utterramblings]' >> /etc/yum.repos.d/utterramblings.repo
#echo "name=Jason's Utter Ramblings Repo" >> /etc/yum.repos.d/utterramblings.repo
#echo 'baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/' >> /etc/yum.repos.d/utterramblings.repo
#echo 'enabled=1' >> /etc/yum.repos.d/utterramblings.repo
#echo 'gpgcheck=1' >> /etc/yum.repos.d/utterramblings.repo
#echo 'gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka' >> /etc/yum.repos.d/utterramblings.repo

After just update your php

#yum update php