Saturday 9 March 2013

How To.... Vi / Vim - A Visual Editor :


The VI editor is a screen-based text editor available on all Unix computers (and available for all other kinds of computers, sometimes as ``vim'' rather than ``vi''). Given that it takes some effort, why bother to learn VI ? Because...... 

  • sometimes it's the only available editor
  • when you log on remotely (ssh) to a Unix host from a Mac or PC, only a text editor (like VI or emacs or pico) can be used to edit files in a text-only terminal window
  • mouse movements (e.g., menus, highlighting, clicking, scrolling) slow down the touch-typist. VI requires none
  • as mentioned above, VI is the editor sure to be on every Unix computer in the world
  • VI is a very powerful editor for those who learn more than just the beginner commands, and even more powerful for those who are familiar with Unix commands.


 Download vim for Win XP and Windows 7:  http://www.vim.org/download.php#pc

Monday 4 March 2013

Linux directory structure


As you may have noticed, Linux organizes its files differently from Windows.Everything in linux is a file, it may be a hard disk drive or cd drive or any sortware configuration file everything is kept in Linux as a text file. You can configure any device simply by editing these text files. First the directory structure may seem unlogical and strange and you have no idea where all the programs, icons, config files, and others are. This is by no means a complete list of all the directories on Linux, but it shows you the most interesting places in your file system.

</> (A Slash)
The root directory. The starting point of your directory structure. This is where the Linux system begins. Every other file and directory on your system is under the root directory. Usually the root directory contains only subdirectories, so it's a bad idea to store single files directly under root.
Don't confuse the root directory with the root user account, root password (which obviously is the root user's password) or root user's home directory.

</boot>
As the name suggests, this is the place where Linux keeps information that it needs when booting up. For example, this is where the Linux kernel is kept. If you list the contents of /boot, you'll see a file called vmlinuz - that's the kernel.

</etc>
The configuration files for the Linux system. Most of these files are text files and can be edited by hand. Some interesting stuff in this directory:
/etc/inittab
A text file that describes what processes are started at system bootup and during normal operation. For example, here you can determine if you want the X Window System to start automatically at bootup, and configure what happens when a user presses Ctrl+Alt+Del.
/etc/fstab
This file contains descriptive information about the various file systems and their mount points, like floppies, cdroms, and so on.
/etc/passwd
A file that contains various pieces of information for each user account. This is where the users are defined.

</bin, /usr/bin>
These two directories contain a lot of programs (binaries, hence the directory's name) for the system. The /bin directory contains the most important programs that the system needs to operate, such as the shells, ls, grep, and other essential things. /usr/bin in turn contains applications for the system's users. However, in some cases it really doesn't make much difference if you put the program in /bin or /usr/bin.

</sbin, /usr/sbin>
Most system administration programs are stored in these directories. In many cases you must run these programs as the root user.

</usr>
This directory contains user applications and a variety of other things for them, like their source codes, and pictures, docs, or config files they use. /usr is the largest directory on a Linux system, and some people like to have it on a separate partition. Some interesting stuff in /usr:
/usr/doc
Documentation for the user apps, in many file formats.
/usr/share
Config files and graphics for many user apps.
/usr/src
Source code files for the system's software, including the Linux kernel.
/usr/include
Header files for the C compiler. The header files define structures and constants that are needed for building most standard programs. A subdirectory under
/usr/include contains headers for the C++ compiler.
/usr/X11R6
The X Window System and things for it. The subdirectories under
/usr/X11R6 may contain some X binaries themselves, as well as documentation, header files, config files, icons, sounds, and other things related to the graphical programs.

</usr/local>
This is where you install apps and other files for use on the local machine. If your machine is a part of a network, the /usr directory may physically be on another machine and can be shared by many networked Linux workstations. On this kind of a network, the /usr/local directory contains only stuff that is not supposed to be used on many machines and is intended for use at the local machine only.
Most likely your machine isn't a part of a network like this, but it doesn't mean that /usr/local is useless. If you find interesting apps that aren't officially a part of your distro, you should install them in /usr/local. For example, if the app would normally go to /usr/bin but it isn't a part of your distro, you should install it in /usr/local/bin instead. When you keep your own programs away from the programs that are included in your distro, you'll avoid confusion and keep things nice and clean.

</lib>
The shared libraries for programs that are dynamically linked. The shared libraries are similar to DLL's on Windows.

</home>
This is where users keep their personal files. Every user has their own directory under /home, and usually it's the only place where normal users are allowed to write files. You can configure a Linux system so that normal users can't even list the contents of other users' home directories. This means that if your family members have their own user accounts on your Linux system, they won't see all the w4r3z you keep in your home directory. ;-)

</root>
The superuser's (root's) home directory. Don't confuse this with the root directory (/) of a Linux system.

</var>
This directory contains variable data that changes constantly when the system is running. Some interesting subdirectories:
/var/log
A directory that contains system log files. They're updated when the system runs, and checking them out can give you valuable info about the health of your system. If something in your system suddenly goes wrong, the log files may contain some info about the situation.
/var/mail
Incoming and outgoing mail is stored in this directory.
/var/spool
This directory holds files that are queued for some process, like printing.

</tmp>
Programs can write their temporary files here.


</dev>
The devices that are available to a Linux system. Remember that in Linux, devices are treated like files and you can read and write devices like they were files. For example, /dev/fd0 is your first floppy drive, /dev/cdrom is your CD drive, /dev/hda is the first IDE hard drive, and so on. All the devices that a Linux kernel can understand are located under /dev, and that's why it contains hundreds of entries.

</mnt>
This directory is used for mount points. The different physical storage devices (like the hard disk drives, floppies, CD-ROM's) must be attached to some directory in the file system tree before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called the mount point.
The /mnt directory contains mount points for different devices, like /mnt/floppy for the floppy drive, /mnt/cdrom for the CD-ROM, and so on. However, you're not forced to use the /mntdirectory for this purpose, you can use whatever directory you wish. Actually in some distros, like Debian and SuSE, the default is to use /floppy and /cdrom as mount points instead of directories under /mnt.

</proc>
This is a special directory. Well, actually /proc is just a virtual directory, because it doesn't exist at all! It contains some info about the kernel itself. There's a bunch of numbered entries that correspond to all processes running on the system, and there are also named entries that permit access to the current configuration of the system. Many of these entries can be viewed.

</lost+found>
Here Linux keeps the files that it restores after a system crash or when a partition hasn't been unmounted before a system shutdown. This way you can recover files that would otherwise have been lost.

</media>

mounted (or loaded) devices such as cdroms, digital cameras, etc.


</opt>
location for “optionally” installed programs

</proc>
dynamic directory including information about and listing of processes

</sys>
contains information about the system


Resources:

Sunday 3 March 2013

How to Code



"Programming allows you to think about thinking, and while debugging you to learn  about learning"

So visit......  http://www.code.org

Tuesday 26 February 2013

How to encrypt & decrypt files


Many people want to keep some of the files on their system in encrypted format and for that people spend a lot of money on proprietory solutions for encryption or they find a trial version of any software which works fine initially but ultimately denies to decrypt the file. (After using such softwares it's obvious that encrytion gives a nightmare to people).
In this article I will describe a very simple utility by which you can encrypt your file & keep it on your system. There are many uses of encrypting a file but for a typical home users there are two main uses of file encryption.

1. Other users of the computer won't be able to access the file, only the person who have encrypted the file can decrypt it.
2. If you want to store some personal information or sensitive information (like your passwords or credit card numbers) online on some third party cloud storage utility then you can just encrypt the file & upload it. So next time you can download the file decrypt it & use it.

I personally use the encryption for second purpose. Linux provides an inbuilt GPG (GNU Privacy Guard) utility for encrypting the files. Here I will describe most basic usage of this utility however this utility has many advanced features too which I will be covering in next articles. So here are the steps to encrypt a file using gpg encryption.

1. Suppose I have a file named foo.txt & I want to encrypt it. (You may encrypt any type of file)
2. Run the following command on a terminal

gpg -c <filename>

Here give the absolute path of the filename in case you are working from some other directory.
So here I will give command as

gpg -c foo.txt

3. Now it will prompt you for a passphrase. Here provide a passphrase which only you know. It's like a password. This passphrase will be needed to decrypt your file.

Note: Remember the passphrase you provide at this step. Without this passphrase you won't be able to decrypt your file.

4. It will prompt to repeat the passphrase. Type it in again & Voila! You are done.

Now you will see a file foo.txt.gpg in the same directory. This is the encrypted file. Now you can delete the original file & keep this encrypted version of it. This file can only be read when it is decrypted with same gpg utility & with same passphrase which was used to encrypt it.

Steps to decrypt your file:

1. Go to the directory where file is located & run the command:

gpg <filename>.gpg (Provide filename with .gpg extension)

e. g. gpg foo.txt.gpg

2. It will ask for the passphrase. Provide the same passphrase as you used for encryption & press enter.
3. You will see original file foo.txt in the same directory, now you can normally open & read it.
Note: If the original file already exists then the gpg utility will ask you to replace the file. If you specify YES then it will replace the already existing file and if you specify NO then it will ask for a new file name and it will restore the file with new filename.

Do not use this encryption with Directories(Folders) as it will encrypt the folder but when you will try to decrypt it, It will return a file with a size of 0 Bytes.

There are advanced encryption techniques of GPG using a key pair which includes a public key & a private key. I will be covering the advanced features in my subsequent articles.
Note: If a file has an extension .asc then it's an ascii encrypted file and if a file has an extension .gpg then it's a binary encrypted file.



Saturday 23 February 2013

How to install & upgrade JRE on Red Hat Linux

If you are connected to RHN (Red hat Network) then it is pretty easy to download & install the latest version of Java. You just need to type the following command in the terminal (as superuser)

yum install java-1.7.0-openjdk*

What if you have to install it offline or manually without using yum. Here are the steps:
1. Go to oracle site & download the latest package. Here I am using 64 bit package & also download the .bin package (not rpm.bin or any other).
2. Save the package jre-<version>.bin file to /opt directory.
3. Change the permission of the file (Make it executable). Run following command in the terminal (as superuser)

    chmod 777 jre-<version>.bin

4. Now install the jre package. Run the following command in terminal.

    ./jre-<version>.bin

or alternatively you can run:

    /bin/sh jre-<version>.bin

This command will install jre & create a directory in /opt (or in any other directory if you are installing somewhere other than /opt). Directory name will be jre<version>

5. Now run alternatives command:

   alternatives --install /usr/bin/java java /opt/jre<version>/bin/java 1

6. Now run command:

    alternatives --config java

Now make the latest version as default for the system.

7. Check the java version:

    java -version

It should show the latest version.

8. Check the status & java installation directories:

    alternatives --display java

You will get a message that java status is manual & it will also show the /opt directories where java is installed.

9. Now to set Java environmental variables, you can create a file in /etc/profile.d
    file name - java.sh
    Absolute path: /etc/profile.d/java.sh
    file content:

      export JAVA_HOME="/opt/jre-<version>/bin"
    export JAVA_PATH="$JAVA_HOME"
    export PATH="$PATH:$JAVA_HOME"

save the file.
10. Run the following command:

    source /etc/profile.d/java.sh
    


Thursday 13 October 2011

Ubuntu 11.10 Released – See What’s New

After 6 months in the making the latest release of Ubuntu – version 11.10 – is now available to download.

Sporting a retuned Unity interface, new and improved features, and even some new applications Ubuntu 11.10 certainly promises a lot – but does it live up to the hype?

Ubuntu 11.10 – minor, but major

Ubuntu 11.10 builds upon the groundwork laid in Ubuntu 11.04. Whilst there are many changes within Ubuntu 11.10 they are evolutionary rather than revolutionary.

But that’s not a bad thing, for example the Unity interface has matured into a dependable and intuitive work tool; the default application set has been rethought; and the new login screen ‘fits’ the overall style of the Unity desktop. All relatively minor or subtle changes on their own by all add up to a greater cohesive whole.

Canonical’s Jane Silber cites this ‘ease of use and stylishness’ as why Ubuntu is now a global phenomenon, ‘not just for system administrators, developers and expert users’ she says ‘but for a growing community of home users that want a simpler, safer way to use the PC.”

Whilst you’re waiting for your download to finish feel free to cast your eye over the current crop of changes…


Unity Changes

The changes to Unity are apparent from the get go. The Dash is now opened by a launcher icon: -

Ubuntu 11.10 Dash button

The colour of the Dash is derived from the average colour of your desktop wallpaper.

Lenses have been integrated into the Dash itself, and sport many changes including faster loading times, improved results, and new filtering options – all of which make finding your applications and files easier.

Amongst the Lens changes comes the addition of a new ‘Music Lens’. With this one can browse locally available music as well as that available to buy via the Ubuntu One Music Store. Clicking on a track you have, or don’t have, opens up the default music player Banshee,

Looks

The default Ubuntu themes (the dark ‘Ambiance’ and the lighter ‘Radiance’) look all the better from their port to GTK 3.

14 new HQ photo wallpapers are available for you to choose from:

A New login screen

A new login screen called ‘LightDM’ is in use for Ubuntu 11.10. Sleeker, lighter and – lets be honest – far sexier than the previous login screens it’s a minor change, but one that gives a polished impression from the get go.

New Default Apps

Ubuntu comes with the most important of software pre-installed.

Firefox 7 is the default web browser, giving you access to a whole world of add-ons and extensions.

For office-suite needs Ubuntu provides the Microsoft Office compatible LibreOffice suite – word processor, spread sheet and database apps all included.

Mozilla Thunderbird replaces Evolution as the default e-mail application. This is a breeze to set up with web-based e-mail accounts: just enter your details and Thunderbird does the complicated stuff for you. Keep an eye on the launcher icon for unread mails.

Shotwell photo manager gives you intuitive management and basic editing of your photos, as well as supporting uploads to Flickr, Facebook and other social sites.

Special mention goes to Ubuntu’s default social client ‘Gwibber’, which has been totally revamped. Now lighter, more responsive and sporting a slicker interface it’s a joy to use for reading your Tweets or updating your Facebook status.

Backing up is important, so Ubuntu provides the ‘Deja Dup’ backup tool by default. Head to System Settings > Back Up to set up backups of you important files on to a separate hard drive, partition, or even Ubuntu One.

backup tool in Ubuntu 11.10

Banshee music player, with integrated Ubuntu One music store; Totem movie player; and Tomboy notes, with Ubuntu One syncing, are also included out of the box.

Six games are pre-installed, including perennially popular titles like Mines and Mahjong. For more advanced/challenging titles head on into the Ubuntu Software Centre.

On the flip side two applications have been removed: Video editor PiTiVi and advanced package management tool ‘Synaptic’.

Ubuntu Software Centre 5.0

The Ubuntu Software Centre in Ubuntu 11.10 has been completely revamped, with a more intuitive ‘toolbar’ for navigation; an improved layout and new filtering options for more refined searching of software.

Indicators

It’s all change on the Indicator front with the removal of the Me Menu; the addition of a ‘Clear All’ item to the ‘Messaging Menu’; a new-look user menu, and a new ‘Power Indicator’ providing quick access to attached devices, session controls and system settings.

Installer Changes

The Ubuntu Installer has been streamlined yet again – now adding in a ‘Wifi’ connection step (if applicable) and the option to take a user account photo via your webcam.

Multi-arch

A new feature to Ubuntu 11.10 is “multiarch” support that allows 64bit Ubuntu users to install 32bit applications and utilities on their systems with no jiggery-pokery needed.

One Conf

OneConf is a new Software Centre feature that helps you keep a list of installed applications in sync across multiple computers. To activate it, open the Ubuntu Software Centre (icon on the Dash) and head to “File > Sync between computers…“.

Performance

So it looks prettier than its predecessor, but does it perform better?

The short answer is yes: the improvements to Unity and Ubuntu as a whole makes for a responsive and nimble desktop. To get the best out of it you’re still going to need fairly recent hardware, but I wouldn’t expect anyone with less than 1GB of RAM and a above-1Ghz processor to worry too much; my netbook is more than capable of handling Oneiric with more than enough oomph.

The downsides to 11.10 are in two areas: -

  • Boot time has increased from Ubuntu 11.04 – but only marginally. Those with SSDs and i7 Quad core processors won’t notice too much of a different, but those on ‘typical’ hardware should expect to wait anywhere between 15 – 25 seconds before the login screen loads. Phoronix have more in-depth details on the performance of Ubuntu 11.10 compared to earlier releases.
  • Battery drain – the kernel used in Ubuntu 11.10 suffers from a ‘power regression’ that sees it suck the juice from your battery or power source quicker than Eric Northman on Sookie Stackhouse’s blood.
By Joey Sneddon on www.omgubuntu.co.uk

Official Ubuntu 11.10 CDs for Sale

The official Ubuntu 11.10 CDs have gone on sale in the Canonical Store.

The CDs, which will begin shipping after Thursday’s release of Ubuntu 11.10, are available in three 32bit only flavours: -

As with previous releases the official CDs are sold in packs, which begin at £5 for 5 CDs.