Tuesday, 10 January 2012
Sunday, 8 January 2012
Your Cellphone can be hacked by international hackers-TV9, Mobile Phone Hacking News
Posted by Muhammad Nasir on 02:22
Linux Partitions of Disk, fdisk for Partitions in Linux, Ubuntu partitions
Posted by Muhammad Nasir on 00:45
1. Manage Partitions with fdisk
· Use fdisk to create a new partition table
o 1st primary partition (100 MB)
o 2nd primary partition (1 GB)
o 3rd primary partition (4 GB)
· Commit these changes
· Reboot and install Linux on the new partition table, mounting them as:-
· 1st primary partition as /boot (reiserfs)
· 3rd primary partition as / (ext3)
sudo fdisk /dev/sda
delete all partitions 1 ,2 using d then press w to write changes
Press n to create a new partition and press p for primary then 1 for partition 1 and then press enter for default starting cylinders then +100M as required for partition 1.
Press n to create a new partition and press p for primary then 2 for partition 2 and then press enter for default starting cylinders then +1G as required for partition 2.
Press n to create a new partition and press p for primary then 3 for partition 3 and then press enter for default starting cylinders then +4G as required for partition 3.
press w for write changes
mount /dev/sda1 /boot; mount /dev/sda3 /;
reboot and install new linux and use the existing file system. And make changes in sda1 as file system reiserfs and mount point /boot; sd2 as file system ext3 and mount point /
then install ubnuntu; this will load new file systems and partition table.
2. Create Partitions with fdisk
· Using fdisk, create a new extended partition with all the remaining space in the HDD
· Create a new logical partitions:-
o 1st logical partition (100 MB)
o 2nd logical partition (1 GB)
· Commit these changes
· Load the new partition table into the kernel by using partprobe utility
fdisk /dev/sda
type n for new partition; select e for extended partition and it will create new extended partition on rest of the space.
type n for new logical partition. it will make logical partition sd5 in sda4 extended partition. press enter for default starting cylinder and +100M for 100MB partition.
type n for new logical partition. it will make logical partition sda6 in sda4 extended partition. press enter for default starting cylinder and enter for allocating rest of space for this partition.
press w for commit changes
load partition table using sudo partprobe /dev/sda
3. Create File Systems
· From the command line, format the new partitions as:-
o 1st logical partition as reiserfs
o 2nd logical partition as ext2
· From the command line, mount the new partitions as:-
· 1st logical partition as /moodle
· 2nd logical partition as /moodledata
mkfs –t reiserfs /dev/sda5 ; mkfs –t ext2 /dev/sda6
sudo mkdir /moodle; sudo mkdir /moodledata;
mount /dev/sda5 /moodle; mount /dev/sda6 /moodledata;
Linux Emacs editor, emacs commands examples
Posted by Muhammad Nasir on 00:41
· emacs
· Given a buffer full of English text, answer the following questions:
a. How would you change every instance of his to hers?
press M-x . Then enter:
hers RET his RET hers
M-x replace-string
his
hers
b. How would you make this change only in the final paragraph?
Through “M-h” select paragraph then “M-x replace-string his hers”
c. Is there a way to look at every usage in context before changing it?
d. d. How would you deal with the possibility that His might begin a sentence?
Esc <
Friday, 6 January 2012
Linux Vim Editor, Vim editor commands
Posted by Muhammad Nasir on 21:27
1. Vim
· How can you cause vim to enter Input mode? How can you make vim revert to Command mode?
Using “i” for input mode and “esc” for revert to command mode.
1. To get into the input mode you press either ‘a’ or ‘i’ key. And to revert back to the command mode you press the ‘escape’ key.
· What is the Work buffer? Name two ways of writing the contents of the Work buffer to the disk.
The Work buffer is the area of memory where vim stores the text you are
editing. A”:w” command writes the contents of the work buffer to disk but
does not end your editing session. A ZZ command writes the contents of
The work buffer to disk and ends your editing session.
2. Vim stores the text being edited in the work buffer.
:w command writes the contents of the work buffer to disk but does not end the editing.
ZZ command writes the contents of the work buffer to disk and ends the editing.
· While working in vim, with the cursor positioned on the first letter of a word, you give the command x followed by p. Explain what happens.
The commands exchange the first two letters of the word. First the x
command copies the character the cursor is on to the General-Purpose
buffer and deletes the character, leaving the cursor on the character to the
right of where the deleted character was. Then the p command inserts the
contents of the General-Purpose buffer after the character the cursor is on.
3. The position of the first two characters are swapped. X command deletes the first letter and places it on the buffer. The cursor is then moved to a new position and when the p command is given the letter from the buffer is removed and placed to a new position i.e after the first letter.
· What are the differences between the following commands?
a. i and I
i=Insert before cursor.
I=Insert to the start of the current line.
i : insert cursor at the current position.
I :insert cursor at the beginning of the line.
b. a and A
a=Append after cursor.
A=Append to the end of the current line.
a : append after cursor.
A :append at the end of line.
c. o and O
o=Open a new line below and insert.
O=Open a new line above and insert.
o : Open a new line below and insert.
O : Open a new line above and insert.
d. r and R
r=Overwrite one character. After overwriting the single character, go back to command mode.
R=Enter insert mode but replace characters rather than inserting.
r : Replace character
R : Overwrite characters from cursor onward
e. u and U
u=Undo the last action.
U=Undo all the latest changes that were made to the current line.
u : Undo last change
U : Undo all changes to entire line
· Which command would you use to search backward through the Work buffer for lines that start with the word it?
Give the command ?^itRETURN to search backward (?) for a line beginning
with (^) it.
5. ?^it
· Which command substitutes all occurrences of the phrase this week with the phrase next week?
:s/this week/next week/g
6. :s/this week/next week
· Consider the following scenario: You start vim to edit an existing file. You make many changes to the file and then realize that you deleted a critical section of the file early in your editing session. You want to get that section back but do not want to lose all the other changes you made. What would you do?
This problem assumes that you have not written out the Work buffer since
you deleted the critical section. There are a few ways to approach this
problem. To be safe, make copies of the Work buffer and the original file
under names other than the name of the original file. That way, if you
make a mistake, you can easily start over. For example, give the command
:wq changedfile to save the work buffer as changedfile, and exit from vim.
Then use cp to copy the original file to, for example, file.orig and
changedfile to changedfile.orig. Start vim with the following command,
which instructs it to edit the original file first and the modified file second:
$ vim originalfile changedfile
Once you are editing the original file, search for and copy the part of the
file you want to save into a Named buffer. For example, to save five lines,
starting with the line the cursor is on, into the Named buffer a, give the
command "a5yy. Then edit the modified file by giving the command
:n!RETURN (edit the next file without writing out the Work buffer). Position
the cursor where you want to insert the text, and give the command "ap or
"aP, depending on where you want to place the copied text.
How can you move the current line to the beginning of the file?
We can move to the beginning of the file using “H” command.
8. “H” command.