Author: Arun Bagul

Indexes in MySQL

Indexes in MySQL

Managing Indexes in MySQL –

Index is a method/process that MySQL uses to speed up searches and reduce the time it takes to execute complex queries. Index provides an organized list of pointers to the actual data. Due to indexing, when MySQL is executing a query, it does not have to scan each table in its entirety to locate the correct data, but it can instead scan the index, which results in quicker and more efficient access…

MySQL supports five type of indexes that can be created on a table….

1) Primary Key – The value or set of values should be unique in the columns on which the primary key is defined. NULL value is not allowed. Table can include only one primary key.

2) Foreign Key – Enforces the relationship between the referencing columns in the child table where the foreign key is defined and the referenced columns in the parent table.

3) Regular – A basic index that permits duplicate values and null values in the columns on which the index is defined…

4) Unique – Requires that each value or set of values be unique in the columns on which the index is defined. Unlike primary key indexes,null values are allowed.

5) Full-text – Supports full text searches of the values in the columns on which the index is defined. A full text permits duplicate values and null values in those columns. A full-text index can be defined only on MyISAM tables and only on CHAR, VARCHAR columns…

How to create indexes –

(a) In below query for creating table. We are defining two indexes one primary key and other is unique.

mysql> CREATE TABLE market (orderID INT(5), modelID INT(5), Name VARCHAR(40), PRIMARY KEY(orderID), UNIQUE (orderID,modelID));
Query OK, 0 rows affected (0.00 sec)

mysql>

(b) In below query for creating table. We are defining Regular indexing

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40), INDEX(orderID) );
Query OK, 0 rows affected (0.00 sec)

mysql>

(c) How to add indexes to existing table –

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40));
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER TABLE market ADD PRIMARY KEY (orderID);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>

(d) How to create index by using “CREATE INDEX” –

mysql> CREATE TABLE market (orderID INT(5), Name VARCHAR(40));
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE INDEX myindex ON market (orderID);
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>
** How to drop index –

mysql> DROP INDEX myindex ON market;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql>

(e) How to get information about your Databases and tables –

** Below SQL commands can be used to view the database definition for specific database.

mysql> SHOW CREATE DATABASE zabbix;
+———-+——————————————————————-+
| Database | Create Database |
+———-+——————————————————————-+
| zabbix | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+———-+——————————————————————-+
1 row in set (0.00 sec)

mysql>

** SQL command to view table definition

mysql> SHOW CREATE TABLE market;
+——–+———————————————+
| Table | Create Table |
+——–+———————————————+
| market | CREATE TABLE `market` (
`orderID` int(5) default NULL,
`Name` varchar(40) default NULL,
KEY `myindex` (`orderID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+——–+———————————————+
1 row in set (0.00 sec)

mysql>

** How to describe the table structure –

mysql> SHOW COLUMNS FROM market;
+———+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+————-+——+—–+———+——-+
| orderID | int(5) | YES | | NULL | |
| Name | varchar(40) | YES | | NULL | |
+———+————-+——+—–+———+——-+
2 rows in set (0.01 sec)

mysql> DESC market;
+———+————-+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+———+————-+——+—–+———+——-+
| orderID | int(5) | YES | | NULL | |
| Name | varchar(40) | YES | | NULL | |
+———+————-+——+—–+———+——-+
2 rows in set (0.00 sec)

** How to views indexes defined on perticular table –

mysql> SHOW INDEX FROM market;
Empty set (0.00 sec)

mysql> CREATE INDEX myindex ON market (orderID);
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> SHOW INDEX FROM market;
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
| market | 1 | myindex | 1 | orderID | A | NULL | NULL | NULL | YES | BTREE | |
+——–+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+
1 row in set (0.00 sec)

mysql>

Thank you,
Arun Bagul

OpenMoko – open source mobile platform

OpenMoko – open source mobile platform

Introduction –

OpenMoko is the Free and Open Source Mobile Platform. The entire OpenMoko system and application software are built using Free and Open Source Software (FOSS). On the system side,openmoko OpenMoko uses software with a tireless history of success and stability, such as the Linux kernel, the GNU C library, the X window system, and the GTK+ toolkit etc… Open source is not a new concept but for the mobile world this is an entirely new concept. OpenMoko is just taking things mobile. For mobile developers OpenMoko is the best place to start. Since OpenMoko runs libraries and components commonly found on the computer….

Neo 1973
is the first free and open source mobile by OpenMoko. The Neo Base kit contains everything the mobile application developer needs to enjoy the benefits of the first free phone.

openmoko-neo

Neo 1973 – Hardware specifications –

  • 2.8″ VGA TFT color display
  • Touchscreen, usable with stylus or fingers
  • 266MHz Samsung System on a Chip (SOC)
  • USB 1.1, switchable between Client and Host (unpowered)
  • Integrated AGPS
  • 2.5G GSM – tri band (900/1800/1900), voice, CSD, GPRS
  • Bluetooth 2.0
  • Micro SD slot
  • High Quality audio codec

Cheers,
Arun Bagul

Ubuntu – GRUB splash image as background for GRUB menu

Ubuntu – GRUB splash image as background for GRUB menu

Introduction –

Why Ubuntu does not provide GRUB splash image as background for GRUB selection menu?. Really I don’t know but, today we will learn how to do it.

root@arunbagul:~# apt-get install grub-splashimages
Reading package lists… Done
Building dependency tree

….
root@arunbagul:~#

Once you install “grub-splashimages” you will get grub splash image installed on your Ubuntu system in “/boot/grub/splashimages” directory.

root@arunbagul:/boot/grub/splashimages# update-grub
Searching for GRUB installation directory … found: /boot/grub
Searching for default file … found: /boot/grub/default
Testing for an existing GRUB menu.lst file … found: /boot/grub/menu.lst
Searching for splash image … none found, skipping …

…….
Updating /boot/grub/menu.lst … done

root@arunbagul:/boot/grub/splashimages#

update-grub is a program used to generate the menu.lst file used by the grub bootloader. It works by looking in /boot for all files which start with “vmlinuz-“. They will be treated as kernels, and grub menu entries will be created for each. It will also create the initial menu.lst if none exists, after prompting the user. It will also add initrd lines for ramdisk images found with the same version as kernels found. e.g. /boot/vmlinuz-2.4.5 and /boot/initrd-2.4.5 will cause a line of “initrd=/boot/initrd-2.4.5 or similar to be added for the kernel entry in the menu.lst. After update-grub has been run for the first time, the user is required to edit the generated menu.lst.
Cheers,
Arun Bagul

How to configure Local DNS caching!

How to configure Local DNS caching!

Introductions –

DNS server resolves domain names into IP addresses. So when you request “yahoo.com” for example, the DNS server finds out the address for the domain, and sends your request the right way.

You can run a DNS cache on your system This will speed up the process of looking up domain names while browsing. The difference is about 35-55ms. dnsmasq is the tool, we will be using for caching nameserver lookups

** How to install dnsmasq –

root@arunbagul:~# apt-get   install  dnsmasq
Reading package lists… Done
Building dependency tree

….
root@arunbagul:~#

** How to configure dnsmasq –

The configuration file for dnsmasq is /etc/dnsmasq.conf. you can specify customized setting in this file…

root@arunbagul:~# vi /etc/dnsmasq.conf
root@arunbagul:~#

Now uncomment the following line in /etc/dnsmasq.conf file. So that dnsmasq will listen on local loop ie 127.0.0.1 address.

listen-address=127.0.0.1

Now edit /etc/dhcp3/dhclient.conf and make sure that it looks  as shown below…

root@arunbagul:~# cat /etc/dhcp3/dhclient.conf

prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

….
root@arunbagul:~#

How it dnsmasq works? –

If you are using DHCP connection ,then whenever you get a new dhcp lease, the dhcp3 client will updates the /etc/resolv.conf file on your system with the right values for the DNS servers to use. Adding the “prepend” option as we did above ensures that “nameserver 127.0.0.1” will appear on the top of the list of DNS servers. So in the future, whenever your system want to resolve a domain name, it will forward that request to local dnsmasq. dnsmasq maintains it’s own cache. If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the line “nameserver 127.0.0.1″…

Check your /etc/resolv.conf file –

root@arunbagul:~# cat /etc/resolv.conf
search indiangnu.org
nameserver 192.168.1.10
nameserver 192.168.1.11
root@arunbagul:~#

where is “nameserver 127.0.0.1” entry? This is because. Since dhcp haven’t renewed your lease after editing the /etc/dhcp3/dhclient.conf file. Let us add that in manually. see below

root@arunbagul:~# cat /etc/resolv.conf
search indiangnu.org
nameserver 127.0.0.1
nameserver 192.168.1.10
nameserver 192.168.1.11
root@arunbagul:~#

** Now is to start dnsmasq so that the changes we made to the configuration file take effect-

root@arunbagul:~# /etc/init.d/dnsmasq
Usage: /etc/init.d/dnsmasq {start|stop|restart|force-reload}
root@arunbagul:~#

root@arunbagul:~# /etc/init.d/dnsmasq start
Starting DNS forwarder and DHCP server: dnsmasq.
root@arunbagul:~#

Yes!! we are running our local DNS cache. If you want to measure your speed improvement then dig to some domain and find out how fast is Local DNS cache!

root@arunbagul:~# dig yahoo.com
root@arunbagul:~#

command(1) dnsmasq – is a lightweight DHCP and caching DNS server. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. It loads the contents of /etc/hosts so that local hostnames which do not appear in the global DNS can be resolved and also answers DNS queries for DHCP configured hosts. The dnsmasq DHCP server supports static address assignments, multiple networks & DHCP-relay.

Options

-h, –no-hosts
Don’t read the hostnames in /etc/hosts.

-H, –addn-hosts=<file>
Additional hosts file. Read the specified file as well as /etc/hosts.

-E, –expand-hosts
Add the domain to simple names (without a period) in /etc/hosts in the same way as for DHCP-derived names.

-T, –local-ttl=<time>
When replying with information from /etc/hosts or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning that
the requestor should not itself cache the information. This is the correct thing to do in almost all situations.

-k, –keep-in-foreground
Do not go into the background at startup but otherwise run as normal. This is intended for use when dnsmasq is run under daemontools or
launchd.

-d, –no-daemon
Debug mode: don’t fork to the background, don’t write a pid file, don’t change user id, generate a complete cache dump on receipt on
SIGUSR1, log to stderr as well as syslog, don’t fork new processes to handle TCP queries.

-q, –log-queries
Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.

-x, –pid-file=<path>
Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.

-u, –user=<username>
Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root privileges
after startup by changing id to another user. Normally this user is “nobody” but that can be over-ridden with this switch.

-g, –group=<groupname>
Specify the group which dnsmasq will run as. The defaults to “dip”, if available, to facilitate access to /etc/ppp/resolv.conf which is not
normally world readable.

-v, –version
Print the version number.

-p, –port=<port>
Listen on <port> instead of the standard DNS port (53). Useful mainly for debugging.

Cheers,
Arun Bagul

How to mount remote ssh filesystem by using sshfs

How to mount remote ssh filesystem by using sshfs

Introduction –

SSH (Secure Shell) is mostly used to login to remote shell (Linux/Unix machine). SSH is protocol to transfer files securely like FTP, but more secure. Transferring files to an from an ssh account can be done using the scp command. What if you could mount a remote folder that you can access using ssh on your local computer? What if you could access files on an ssh account just like they were local files on your pc? Well now you can! mount a folder in an ssh account, edit the files locally and save the files, that’s it! The file will be saved on remote ssh server.

sshfs is a tool, which allow us to mount directory file systems over ssh on Ubuntu. sshfs is a filesystem client based on the SSH File Transfer Protocol.
Most SSH servers already support this protocol it is very easy to set up on the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

How to install sshfs –

root@arunbagul:~# apt-get  install   sshfs
Reading package lists… Done
Building dependency tree

….
root@arunbagul:~#

This will also install fuse-utils and libfuse2, which are required.

What is required ?

fuse is the kernel module which need to loaded –

root@arunbagul:~# lsmod | grep fuse
fuse 47124 3
root@arunbagul:~#

If this module is not loaded, you will get following error-

fusermount: fuse device not found, try ‘modprobe fuse’ first

** Use below command to load ‘fuse’ module

root@arunbagul:~# modprobe fuse
root@arunbagul:~#

If you want to load ‘fuse’ modules on startup. Then edit the file /etc/modules and adding a ‘fuse’ on new line at the end.

** Now create a local directory where you want the files to be mounted…

root@arunbagul:~# mkdir /media/ssh_file_system
root@arunbagul:~#
root@arunbagul:~# chown arun:arun /media/ssh_file_system
root@arunbagul:~#

Once you have done the above, you can use sshfs to mount the remote directory to your local system!

Say I want to mount the “/var/www” directory on my remote server (192.168.0.1) I would do it by executing the following command…

root@arunbagul:~# sshfs root@192.168.0.1:/var/www /media/ssh_file_system
root@192.168.0.1’s password:
root@arunbagul:~#

** Check with mount command whether the file system is mounted or not

root@arunbagul:~# mount | grep sshfs
sshfs#root@192.168.0.1:/var/www on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)
root@arunbagul:~#

NOTE – Normal user should be in ‘fuse’ group to mount file system by using sshfs.

root@arunbagul:~# grep fuse /etc/group
fuse:x:106:
root@arunbagul:~#

** How to unmount the directory –

root@arunbagul:~# mount | grep sshfs
sshfs#root@192.168.0.1:/var/www on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)
root@arunbagul:~#

root@arunbagul:~# fusermount -u /media/ssh_file_system
root@arunbagul:~#

root@arunbagul:~# mount | grep sshfs
root@arunbagul:~#

done!

command(1) fusermount – mount FUSE filesystems. A virtual FUSE filesystem will be created on the mount point.

Options
-h print help

-V print version

-o opt[,opt…]
mount options

-u unmount

-q quiet

-z lazy unmount (works even if resource is still busy)

command(2) SSHFS – filesystem client based on SSH File Transfer Protocol

usage: sshfs [user@]host:[dir] mountpoint [options]

general options:
-o opt,[opt…]
mount options

-h –help
print help

-V –version
print version

-p PORT equivalent to ‘-o port=PORT’

Cheers,
Arun Bagul

SSH tunneling – for SOCK proxy port forwarding

SSH tunneling – for SOCK proxy port forwarding

Introduction –

SSH (secure shell) client can be used as “SSH tunneling for SOCK proxy port forwarding“.

ssh -D [bind_address:]port

* -D option in SSH can be used to specifies a local “dynamicapplication-level port forwarding. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address(127.0.0.1). Whenever a connection is made to this port(8080), the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root can forward privileged ports. Dynamic port forwarding can also be specified in the configuration file….

** How to use SSH tunneling for SOCK port forwarding –

root@arunbagul:~# ssh -D 8080 arun@192.168.0.1
arun@192.168.0.1’s password:

….

arun@server:~$
** Check the 8080 port is open or your local system –

root@arunbagul:~# netstat -nlp | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN –
tcp6 0 0 ::1:8080 :::* LISTEN –
root@arunbagul:~#

** 8080 is the SOCKS proxy port of your local system. This is a tunnel to the server(192.168.0.1). Now all you have to do is got to set the preference in Firefox browser and use a SOCKS proxy. The proxy is, of course, “localhost”, with the port 8080. Now whenever you browse, all the connections you make to websites will seem to originate from the server to which you SSH-ed(192.168.0.1). In addition, all outgoing and incoming data for the browsing session will be encrypted since it passes through the SSH connection…

Find out what is possible with ssh ?

Cheers,
Arun Bagul

Different methods of accessing subversion (svn) repository

Different methods of accessing subversion (svn) repository

Introduction –

There are three different methods of accessing subversion repository…

1] Local filesystem or Network filesystem accessed by client directly
2] Apache HTTP using WebDAV module
3] svnserve tunneled over an SSH (svn + ssh)

First of all I am creating base directory for svn as “/var/repos_base”

root@arun:~# mkdir /var/repos_base
root@arun:~# ls -ld  /var/repos_base
drwxr-xr-x 2 root root 4096 2006-12-26 16:32 /var/repos_base
root@arun:~#

How to get help ?

root@arun:~# svnadmin  help
root@arun:~# svn help
root@arun:~# svnlook  help
root@arun:~# svnsync  help
root@arun:~# svnversion  –help
root@arun:~# svnserve  –help

1] How to create svn repository ?

“svnadmin” command is used to perform adminitrative task in subversion. Like creating, taking dump, hotcopy, recovering & verifying subversion repository.

root@arun:~# svnadmin  create  /var/repos_base/myrepository

Here “/var/repos_base/myrepository” is the physical location of repository….

root@arun:~# ls -l /var/repos_base/myrepository/
total 28
drwxr-xr-x 2 root root 4096 2006-12-26 16:34 conf
drwxr-xr-x 2 root root 4096 2006-12-26 16:34 dav
drwxr-sr-x 5 root root 4096 2006-12-26 16:34 db
-r–r–r– 1 root root    2 2006-12-26 16:34 format
drwxr-xr-x 2 root root 4096 2006-12-26 16:34 hooks
drwxr-xr-x 2 root root 4096 2006-12-26 16:34 locks
-rw-r–r– 1 root root  229 2006-12-26 16:34 README.txt
root@arun:~#

2] How to create trunk , branches etc directories in svn repository ?

method (1) ~ Local filesystem

root@arun:~# svn  mkdir   file:///var/repos_base/myrepository/trunk/

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c

Committed revision 1.
root@arun:~# svn  mkdir   file:///var/repos_base/myrepository/branches

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c

Committed revision 2.
root@arun:~#

root@arun:~# svn  list   file:///var/repos_base/myrepository/
branches/
trunk/
root@arun:~#

method (2) ~ Apache HTTP using WebDAV module

arunsb@arun:~$ svn  mkdir    http://192.168.0.1/myrepository/trunk/

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c
Authentication realm: <http://192.168.0.1:80> || Welcome to Subversion Repository ||
Password for ‘arunsb’:

Committed revision 1.
arunsb@arun:~$ svn   mkdir    http://192.168.0.1/myrepository/branches/

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c

Committed revision 2.
arunsb@arun:~$ svn  list  http://192.168.0.1/myrepository/
branches/
trunk/
arunsb@arun:~$

method (3) ~ svnserve tunneled over an SSH (svn + ssh)

arunsb@arun:~$ svn mkdir  svn://192.168.0.1/myrepository/branches/

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c
Authentication realm: <svn://192.168.0.1:3690> ” || Welcome to Subversion Repository ||”
Password for ‘arunsb’:

Committed revision 1.
arunsb@arun:~$ svn mkdir  svn://192.168.0.1/myrepository/trunk/

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
c

Committed revision 2.
arunsb@arun:~$ svn list  svn://192.168.0.1/myrepository/
branches/
trunk/
arunsb@arun:~$

3] How to import un-versioned data in svn ?

root@arun:~# ls -l  /root/source_code/
total 12
-rwxr-xr-x 1 root root    3 2006-12-26 20:01 arun.html
-rw-r–r– 1 root root 2119 2006-12-26 20:03 License
-rwxr-xr-x 1 root root   64 2006-12-26 20:01 my.pl
root@arun:~#

* I wanted to import this data….

method (1)

root@arun:~# svn import   /root/source_code/ file:///var/repos_base/myrepository/trunk/    -m “welcome to first import”
Adding         /root/source_code/my.pl
Adding         /root/source_code/License
Adding         /root/source_code/arun.html

Committed revision 3.
root@arun:~#

List the imported data from svn repository –

arunsb@arun:~$ svn list file:///var/repos_base/myrepository/trunk/
License
arun.html
my.pl
arunsb@arun:~$

method (2)

arunsb@arun:~$ svn import   /root/source_code/   http://192.168.0.1/myrepository/trunk/  -m “welcome to first import”
Authentication realm: <http://192.168.0.1:80> || Welcome to Subversion Repository ||
Password for ‘arunsb’:
Adding         /root/source_code/my.pl
Adding         /root/source_code/License
Adding         /root/source_code/arun.html

Committed revision 3.
arunsb@arun:~$

method (3)

arunsb@arun:~$ svn import   /root/source_code/   svn://192.168.0.1/myrepository/trunk/  -m “welcome to first import”
Authentication realm: <svn://192.168.0.1:3690> ” || Welcome to Subversion Repository ||”
Password for ‘arunsb’:
Adding         /root/source_code/my.pl
Adding         /root/source_code/License
Adding         /root/source_code/arun.html

Committed revision 3.
arunsb@arun:~$

4] How to check out the svn repository ?

method (1)

arunsb@arun:~$ svn checkout file:///var/repos_base/myrepository/trunk/  /home/arunsb/mysource_code/
A    /home/arunsb/mysource_code/my.pl
A    /home/arunsb/mysource_code/License
A    /home/arunsb/mysource_code/arun.html
Checked out revision 3.
arunsb@arun:~$

method (2)

arunsb@arun:~$ svn checkout   http://192.168.0.1/myrepository/trunk/   /home/arunsb/mysource_code/
Authentication realm: <http://192.168.0.1:80> || Welcome to Subversion Repository ||
Password for ‘arunsb’:
Checked out revision 2.
arunsb@arun:~$

method (3)

arunsb@arun:~$ svn co svn://192.168.0.1/myrepository/trunk/   /home/arunsb/mysource_code/
Authentication realm: <svn://192.168.0.1:3690> ” || Welcome to Subversion Repository ||”
Password for ‘arunsb’:
Checked out revision 2.
arunsb@arun:~$

* Now check checked out data…

arunsb@arun:~$ ls -l /home/arunsb/mysource_code/
total 12
-rwxr-xr-x 1 arunsb oinstall    3 2006-12-26 20:42 arun.html
-rw-r–r– 1 arunsb oinstall 2119 2006-12-26 20:42 License
-rwxr-xr-x 1 arunsb oinstall   64 2006-12-26 20:42 my.pl
arunsb@arun:~$

** Now go to “/home/arunsb/mysource_code/”

arunsb@arun:~/mysource_code$ cd  /home/arunsb/mysource_code/
arunsb@arun:~/mysource_code$ ls
arun.html  License  my.pl
arunsb@arun:~/mysource_code$

* How to get information about svn repository –

arunsb@arun:~/mysource_code$ svn info
Path: .
URL: file:///var/repos_base/myrepository/trunk
Repository Root: file:///var/repos_base/myrepository
Repository UUID: 361de285-9226-493b-aed7-a95619a457c0
Revision: 3
Node Kind: directory
Schedule: normal
Last Changed Author: root
Last Changed Rev: 3
Last Changed Date: 2006-12-26 20:38:14 +0530 (Fri, 26 Dec 2006)
arunsb@arun:~/mysource_code$

4] How to commit data ?

Now create  new file “new_file.php” in modify the file…

arunsb@arun:~/mysource_code$ touch  new_file.php
arunsb@arun:~/mysource_code$ ls
arun.html  License  my.pl  new_file.php
arunsb@arun:~/mysource_code$ vi new_file.php
arunsb@arun:~/mysource_code$ mkdir  new_dir
arunsb@arun:~/mysource_code$ ls
arun.html  License  my.pl  new_dir  new_file.php
arunsb@arun:~/mysource_code$

* Now check the status… ‘?’ means file or directory NOT in svn repository

arunsb@arun:~/mysource_code$ svn  status
?      new_dir
?      new_file.php
arunsb@arun:~/mysource_code$

* Now add  newly created files and directories…

arunsb@arun:~/mysource_code$ svn add  new_dir
A         new_dir
arunsb@arun:~/mysource_code$ svn add  new_file.php
A         new_file.php
arunsb@arun:~/mysource_code$

* Another method to add directory is…

arunsb@arun:~/mysource_code$ svn mkdir new_dir2
A         new_dir2
arunsb@arun:~/mysource_code$

* Now check the status… ‘A’ means data is modified

arunsb@arun:~/mysource_code$ svn  status
A      new_dir
A      new_dir2
A      new_file.php
arunsb@arun:~/mysource_code$

* commit modified to svn repository…

arunsb@arun:~/mysource_code$ svn commit  -m “committing  data”
Adding         new_dir
Adding         new_dir2
Adding         new_file.php
Transmitting file data .
Committed revision 4.
arunsb@arun:~/mysource_code$

5] How to check svn status (working copy) –

arunsb@arun:~/mysource_code$ svn status
arunsb@arun:~/mysource_code$

arunsb@arun:~/mysource_code$ svn  status
A      new_dir
A      new_dir2
A      new_file.php
arunsb@arun:~/mysource_code$

6] How to update svn working copy –

arunsb@arun:~/mysource_code$ svn update
At revision 4.
arunsb@arun:~/mysource_code$

* update working copy to specific revision….

arunsb@arun:~/mysource_code$ svn update -r20

7] How to check  svn log (working copy) –

arunsb@arun:~/mysource_code$ svn log
————————————————————————
r1 | arunsb | 2008-12-26 21:53:04 +0530 (Fri, 26 Dec 2006) | 1 line
————————————————————————
arunsb@arun:~/mysource_code$

Thank you,
Arun Bagul

How to remove all blank lines from file – grep command

How to remove all blank lines from file – grep command

1] cat the file arun.txt which has several blank lines

root@indianGNU.org:/home# cat arun.txt
This is first line of file

this is second line

ok this script will help you to delete all blank links from file
How to start shell scripting

make sure that you will win

arun bagul

end of file

root@indianGNU.org:/home#

2] Run command for removing lines

root@indianGNU.org:/home# grep -v “^$” arun.txt > no_blank_lines.txt

3] Chcek new file –

root@indianGNU.org:/home# cat no_blank_lines.txt
This is first line of file
this is second line
ok this script will help you to delete all blank links from file
How to start shell scripting
make sure that you will win
arun bagul
end of file
root@indianGNU.org:/home#

History of UNIX

History of UNIX

In mid-1960, When American Telephone and Telegraph ( AT&T), Honeywell, General Electrical (GE) and Massachusetts Institute of Technology (MIT) embarked on massive project to delevelop an information utility. The project call MULTICS ( MULtiplexed Information and Computer Services) which was funded by DARPA ( DoD Advanced Research Project Agency).

In 1969 the MIT and AT&T decided to pull out of MULTICS project. After that Ken Thompson and Dennis Ritchie ( founder of C/C++) who were also part of MULTICS started work on new computer system (OS) based on MULTICS. They decided to call it as “UNIX“. During this time MULTICS project was continuing in Cambridge and which was coninued more than one & half decade.

In 1973, Ken Thompson rewrote most of UNIX in Ritchie’s newly invented C language. During 1978 the University of California had paid $400 to purchase UNIX with source code. Two graduate students Bill Joy and Chuck Haley of Berkeley started making significant modifcation and over the years it developed as independent computer system based on UNIX. They distributed modified UNIX as Berkeley Software Distribution (BSD). Due to licensing limitation Berkeley released modified UNIX as BSD 4.2. UNIX was trademark of AT&T and OS right at that time. They were worried about BSD UNIX popularity.

In this way the Industry was beset by two competing versions of UNIX.

  • AT&T UNIX system-V
  • Berkeley BSD 4.2

Thank you ,

Arun & Yogesh