My personal blog around GNU/Linux

Archive for the ‘Tips and Tricks’ Category

Status

Django Collections

I have been a python guy for almost a year. Learning it & loving it.Now wanted to get into web-development with Django, though initially started with Flask, to get better understanding of what goes under the hood.

While browsing through the internet came across certain sites which one might find useful to get started with Django.

  1. Djangoproject.com – Official website for Django which itself contains a very good documentation to get started with.
  2. Djangorocks.com – A site which helps to know facts behind Django and with snippets and tutorials along with.
  3. GettingStartedwithDjango.com – a site which takes the beginners getting started to advanced level.
  4. Djangopackages.com – List of almost all the available packages for web-development with  Django, categorized.
  5. Djangobook.com – Yet another wonderful Free online book.

So, what are you waiting for? Dive into Django now.

Bash – Sqlite3

Wanted to use a very light weight file based Database Engine and Sqlite3 was my 1st choice. I am making this post on basic commands on Sqlite3 for my anytime reference.

Installing

sudo apt-get install sqlite3

Starting and using Basic commands

  1. $sqlite3 db_name.db – creates a new db with the give name
  2. sqlite3>.databases – list the available databases
  3. sqlite3>.tables – list the existing tables inside the selected database
  4. sqlite3>.schema tablename – displays the structure of the table.
  5. sqlite3>create table tablename (field1 datatype, field2 datatype, etc…);
    Eg:- create table test(id INTEGER PRIMARY KEY AUTOINCREMENT, name CHAR(40));
  6. sqlite3>insert into tablename(fields) values(values);
    Eg:- insert into test(NULL,”Pras”); or
    insert into test(id,name) values(NULL,”Pras”);
  7. sqlite3>update tablename set fieldname=value where fieldname=value;
    Eg:- update test set name=”Prasanna” where name=”Pras”;
  8. sqlite3>select * from tablename;
    Eg:- select * from test; or
    select * from test where name=”Prasanna”;
  9. sqlite3>drop table test; – deletes my table even from the entry
  10. sqlite3>delete from tablename – deletes the values and schema of the table.
  11. sqlite3>.quit – Get out of sqlite shell prompt and return to Bash.

 

Personal home server with Apache

I wanted to set up a personal web server in my home using which I would love to retrieve pages in my smartphone’s browser. If you are a passionate photographer you can host a photo album web app in your personal server and you can give links who ever visits your home they can use their laptop or smartphone to enjoy your photography!

what do you need?
1. Apache web server
2. A wireless router
3. A smartphone or laptop with wifi

To be continued …

Ruby conf India 2012

Attended Rubyconf 2012 at Pune and will be updated soon

How to configure the IP address manually via Terminal

Sometimes we may need to configure the Internet Protocol Address Manually in order to establish the connection with the Server.
Here in this article post i will show how to set or change the IP address for your system via Terminal.

Step 1: Open Terminal. In Ubuntu ( Applications -> Accessories -> Terminal )

Step 2: Type the following command to check if any IP is assigned to your system automatically.

Command$: ifconfig

The above command will dispaly output something like this

eth0 Link encap:Ethernet HWaddr xx:xx:xx:xx:xx:xx
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:40 Base address:0x1000

lo      Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:56144 errors:0 dropped:0 overruns:0 frame:0
TX packets:56144 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:35563073 (35.5 MB) TX bytes:35563073 (35.5 MB)

Step 3: In the above output, in eht0 we cannot find ‘inet addr’ field, which means that no IP address is assigned.

Step 4: Now in the below command I will show how to assign the IP address.

Command$: ifconfig eth0 201.222.255.1 netmask 255.255.255.0

Note: I have used a random IP. You have to use the ip which you desire to use.

Step 5: In order to check whether the IP has been set or changed. Again run the command ‘ifconfig‘.

How to Check md5 checksum in Linux.

The MD5 Message-Digest Algorithm is a widely used cryptographic hash function with a 128-bit (16-byte) hash value. Specified in RFC 1321, MD5 has been employed in a wide variety of security applications, and is also commonly used to check data integrity.

As mentioned above MD5 CHECKSUM is used to check the integrity of the file. If you think the legal file that you have downloaded from products official website has been modified or if you want to check whether you have downloaded the exact file provided by the product owner you can use MD5 checksum.

MD5 Checksum algorithm will generate a group of character strings using which we have to match and verify the checksum of downloaded file and File in the site.

Use the following command in Terminal to verify checksum of the file:

$ md5sum filename.extension

Example:

spv@Pras_linux:~/Downloads$ md5sum mongodb.pdf 
ec70cfc19d9babff02484a74e22ebbbc  mongodb.pdf

In the above 1st line is used to generate the md5sum of a pdf file and the 2nd line is the output of the command.

Now in order to verify whether data integrity is maintained properly you need to check the md5checksum of the pdf file in its official site, provided they have included it.

All the OpenSource Products , when released will have md5checksum string in their official site. This ensures you are using a right product provided by the original developer.

[Solved] Grub fails to show Windows 7 Loader in the Grub menu.

Today i installed Ubuntu 10.10 in one of my friend’s Desktop which had already Windows xp and Windows 7 installed.

1. I used Ubuntu 10.10 Live CD + Installer and booted using it and clicked on “Install Ubuntu”.

2. Then everything went as usual like selecting location, username, password, etc. When it comes to Partitioning i selected “Specify Partitions Manually”

3. Then i decided to install Ubuntu by formatting the drive which had windows xp.

4. So i did so, Installation was successfull and it said to reboot as the installation has been completed.

5. When i rebooted the system , it went straight away into Ubuntu without displaying the Grub Menu.

6. Eventhough windows 7 is present in another drive GRUB doesn’t detect it.

7. When i looked for solutions into Ubuntuforums.org, i found the solution as:

Boot from Windows 7 CD and try to repair it and not reinstall it.
Repairing in the sense Click on Repair windows and then select COMMAND PROMPT.
On the command prompt that appears type the following command:
BootRec.exe /FixBoot
bootrec.exe /fixmbr

After finishing this step you should now be able to go directly into windows 7 instead Ubuntu.

8. So in order to make a dual boot without reinstalling Ubuntu again , boot with Ubuntu live cd and then open terminal in live cd and type the following command:
sudo mount /dev/sda5 /mnt
sudo grub-install –root-directory=/mnt /dev/sda
sudo update-grub

9. Thats it … you are fixed now. Enjoy Dual OS now.

Courtesy — http://ubuntuforums.org/showthread.php?t=1664118&page=6