Monday, May 9, 2011

Some Essentials



  • How to remove the control-M characters from file?
    File Ascci contains the text shown in below image. The commands shown in the image gives you the desire the output. If you want to save this output in differant file then redirect the desire output in differant file by using redirection operator i.e. '>'.
    Here are some different ways to achive the same result.......


  • command: 'cat Ascci.txt' shows you the content of the file.


  • command: 'cat -v Ascci.txt' shows you all the characters in your file.


  • command: 'sed 's/^M//g' Ascci.txt' substitutes / replaces the occurances of ^M with ''.


  • command: 'sed 's/\r\n//g' Ascci.txt' -- Actually ^M character forms with Carriage Return and a new Line Feed character means 'CR' & 'LF'. So in unix we can say for Carriage Return '\r' and for Line Feed '\n'. Hence substituting with \r\n also provides us the same result.


  • command: ' tr -d '^M' < Ascci.txt' -- here we are deleting ^M character from the output and not actually from the inputfile Ascci.txt


  • command: 'perl -p -e 's/^M//g' Ascci.txt' -- here we are running perl one liner. Here -p stand to print the output, -e stands for executes the remaining script. in single quotes we are again substituting ^M with '' globally with in entire file Ascci.txt. This also provides us the same desire result.


Tuesday, April 19, 2011

How to make a new partition on new hard disk

Hi All,

Please perform the following things, make sure you need to login as root first....

[root]# fdisk /dev/hdb
Command (m for help): m (Enter the letter "m" to get list of commands)
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-2654, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2654, default 2654):
Using default value 2654

Command (m for help): p

Disk /dev/hdb: 240 heads, 63 sectors, 2654 cylinders
Units = cylinders of 15120 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 2654 20064208+ 5 Extended

Command (m for help): w (Write and save partition table)

[root]# mkfs -t ext3 /dev/hdb1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2508352 inodes, 5016052 blocks
250802 blocks (5.00%) reserved for the super user
First data block=0
154 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root]# mkdir /opt2
[root]# mount -t ext3 /dev/hdb1 /opt2

I hope this helps for you...

Thanks...

Friday, January 28, 2011

How to install Linux on your Machine --- Dual Boot

Hi All,

I would like to discuss with all of you about "How To Install Linux on your Machine so that you can use your machine as DUAL BOOT..."

DUAL BOOT means you can use your old Operating system as well as newly installed Linux operating system on same machine.

I am considering for this article that you have a 40 GB hard disk and windows is installed on it. One of the 5GB drive is free or empty.

Now before going ahead let me tell you that you required first CD's / DVD's of any Linux Flavours along with you and of course you required free windows drive of approximately 5GB free space.
* If you didn't have those then try to download it from internet (From RedHat / SuSe / Ubantu official websites), burn it on CD's or DVD's .
* Other way to collect CD's or DVD's of installation media is check out the software magazines (like PCQuest, PCdigit or Linux For You).

Once you have those CD's / DVD's along with you. Place it in your CD-ROM / DVD-ROM and then just reboot your PC. Before actually going for installation, make sure that you have choose 'First Bootable Device as CD-ROM / DVD-ROM'. so that installation will automatically starts from CD-ROM / DVD-ROM.

Installation media will first automatically detects your Keyboard, Monitor, Mouse, Graphical Card etc... and it will prompt you for checking of installation media. It is always a good habit to check the installation media before proceeding ahead. Once it is through you can go ahead for installation.

I am considering that you have checked the installation media (CD's / DVD's of linux) now please proceed ahead for installation. Now the next screen you will see on which you need to select MBR for system. There are two MBR's (Master Boot Reader) available in Linux as below.
* GRUB * LILO

As per my knowledge, I will recommend you to select GRUB as your MBR. I am telling you this since it is very easy to operate on it instead of LILO. I will give you more details about MBR in another article. Please select GRUB as your MBR and move ahead. Now you will see the screen where you can select the partition. Two options provided to you.

* Manual Partition * Automatic Partition

If you select Automatic partition then all 5 GB space will get seggarigated by system on its own. Then you don't need to do anything. But if you select 'Manual Partition' then you need to provide the size of all partition.

The following partition you need to create on your system.

/boot -- Size should be approximately 100MB.
/swap -- Size should be exactly double of your RAM size.
/home -- Depends on you, how many number of users you need to create -- 1024 MB
/var -- 1024 MB
/ -- all the remaining one.

For all above partitions you need to select type of file system as EXT3.

Note:- I am not here discussing any LVM or RAID partitions. This whole article is about simple linux installation so that people can enjoy the features of this OS.

Once you are through with partition now system will ask the packages you need to install. In linux all the softwares are coming in terms of packages (like Word, Excel, Editors, different Programming Languages, Games etc). You need to select the appropriate packages as per your need and then move ahead. System will already select some default packages so if you don't need any of those then feel free to deselect it.

Once the package installation start it will take some time. Once it is over you need to set ROOT password for the system. This will make the system to appear login screen, try to login with userid 'root' and its relative password. Check out the desktop. Once done, reboot the system.

While rebooting take out CD's / DVD's. Now the first screen will appear is the MBR (GRUB) loader. Here now move arrow (up / down) keys which will displays the below option

* Linux * Other

Now this other will contain your other operating system available on your machine too i.e. Window 95 / Windows Me / Windows 2003 / Windows Xp etc...

So this will give you a flexibility that you can use linux as well as windows as per your situation demands.

Thanks & Yours
Vaibhav Wadkar