Friday, 6 January 2012

Linux Vim Editor, Vim editor commands

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.

Linux Hard and Soft Links Examples

·        Go into the tmp directory:
·        cd /tmp;

·        Make a directory called original
·        mkdir original; cd original;

·        Copy the /etc/host.conf file or any file to test with here
·        cp /etc/host.conf .;

·        List the contents and take note of the inode (first column)
·        ls -il;   = 143265 -rw-r--r-- 1 Nasir Nasir 92 ……. host.conf

·        Create a symbolic link to host.conf called linkhost.conf
·        ln --symbolic -T host.conf linkhost.conf;

·        Now list out the inodes again
·        ls -il;   =132095 lrwxrwxrwx 1 nasir nasir 9 …….. linkhost.conf→host.conf

·        Notice if the the inode for the link is different?
·        Yes, inode for this link is different from the file host.conf

·        Now create a hard link to the same file called hardhost.conf
·        ln -T host.conf hardhost.conf;

·        Now list the inodes one more time
·        ls -il;   = 143265 -rw-r--r-- 1 Nasir Nasir 92 ……. hardhost.conf

·        Notice if the the inode for the link is different?
·        No, inode is same for file and its hard link.

·        Open up linkhost.conf and edit it and save it
·        vi linkhost.conf; (save :wq)

·        Now look in host.conf and notice if the changes were made
·        Yes, same changes appear in host.conf

·        Lets cut/paste host.conf up one directory and see if it causes any problems
·        mv host.conf ../; it moved seccussfully;

·        Do ls -l and see what is the result?
·        the line for linkhost.conf (softlink) appear black indicating broken link.

·        What is the result of cat linkhost.conf?
·        cat: linkhost.conf: No such file or directory

·        What is the result of cat hardhost.conf?
·        it works and opens host.conf although it is moved to upper directory.

Managing File Permissions and Ownership

·        List files which are readable for current user in /sbin directory
·        ls -l /sbin; find /sbin -perm -u=r -type f -exec ls -l {} \;

·        Create a file and change its permissions so that owner can only read the file and the respective group can read/write the file while other can read/write/execute the file using octal values
·        touch file; chmod 467 file;

·        Change the permissions of the file so that user can read/write/execute the file, group can read/execute the file and others can only read the file without using octal values
·        chmod u=rwx,g=rx,o=r test;

·        Create a new user “Lab_user” and change the ownership of the file to this new user
·        sudo useradd Lab_user; sudo chown Lab_user test; ls -l;

·        Create a new group “Lab_users” and assign this group to the file
·        sudo groupadd Lab_users; sudo chown :Lab_users test; ls -l;
·        sudo chgrp Lab_users test;

·        Change the default permissions to rwx rw- r--
·        umask 013;    (default is umask 022 )

·        Create directory so that only the owner or root can delete the directory
·        mkdir newdir; chmod go-w newdir;

·        Create a file so that when it is executed, the group ID of the process is changed to the group ID of the file
·        touch grp; chmod g+sx grp;

·        Create a new directory so that new files/directories created in this directory belongs to “Lab_users”
·        mkdir mydir; chmod g+sx mydir;

·        Create a file so that when the file is executed, the userID of the file changes to owner of the file
·        touch usrs; chmod u+sx usrs;

Wednesday, 4 January 2012

Linux Find Commands, Find commands in Ubuntu

1.      find
·         Find all lib files greater than 100 KB in /lib
·         find /lib -size +100k
·         This will print many file you can view smoothly by pressing ENTER just append “|more” with the command

·         Find all files which are smaller than 200 bytes
·         find -size -200b
·         There is no path specified so we can optionally specify path as current directory “.”

·         Find all symbolic links in /lib
·         find /lib -type l OR find -lname “*”
·         Both commands find the symbolic links. You prove by just “ls -l” any of the link.

·         Find all files which have been modified in last 24 hours
·         find -mtime 1
·         mtime used to find the updated files in days and if we want to see files with 36 hours, we have to find files which modified two days before by –mtime or calculate minutes and find files by –atime flag.

·         Find the file “cpuinfo” and print its first lines using “head” in the same command
·         sudo find / -iname ‘cpuinfo’ -exec head -1 {} \;
·         -name is case sensitive whereas –iname is case insensitive. –exec produeces new process and gets the results of the parent command in {} and ends with \.

·         Find your group name and ID, and search all files which belong to your group using group name and ID
·         id;    find -user 1000 -group 1000;
·         You can specify numeric userid and group as well as alphabetic names.

·         Find all files which have “.so” in their names using regular expressions
·         Find -iname “*.so”
·         * is the regex used for “all”

Basic Linux Commands, Ubuntu Commands

  Show the present working directory

  Show the current user's session information in long format
  ps -l

  Show the current user's group membership
  id -g; id –gn

  Show the current user's PATH
  echo $PATH;

  List the contents of /boot in long format in three ways:
  Calling ls with an absolute path
  ls -l /boot;
  Calling ls with a relative path
  ls -l ../../boot;
  Changing directory to /boot and calling ls
  cd /boot ;ls -l

  Make a directory in the current user's home directory called lab2
  mkdir lab2

  Make two files in the lab2 directory: test and .test
   cd lab2; vi test; vi .test;  OR touch test ; touch .test;
  touch lab2/test ; touch lab2/.test; ls –alr lab2

  Make directory in the lab2 directory named sub1
  mkdir lab2/sub1; ls -alr lab2

  Change the permissions on test so only the owner can read and write the file and the file is not executable
  chmod 600 lab2/test; ls -alr lab2;

  Change the permissions on .test so the file is globally readable, write-protected, and globally executable
  chmod 707 lab2/.test; ls –alr lab2;

  List all processes for the current user and store the results into test
  who >> lab2/test ; ps –u $USER >> lab2/test;

  Use head to show the first line in test
  head -1 lab2/test

  Use tail to show the last line in test
  tail -1 lab2/test

  Use cat to show the contents of test
  cat lab2/test

  Change to the current user's home directory
  cd ~ OR cd

  Use find to recursively list the lab2 directory
  find lab2;

  Use ls to recursively list the lab2 directory
  ls -alr lab2

  Use rmdir to delete the sub1 directory
  rmdir lab2/sub1

  Use rm to delete the lab2 directory recursively
  rm –r lab2


Sunday, 1 January 2012

Define Attitude? Organization Attitude Effect On IT Project

                 In project management an attitude is a response toward an idea, event, in situation or                                          to a person positively or negatively. One other definition is a mental situation for any event, situation or idea and response to particular event.
Attitude and IT project:
 As we know from attitude definition that it is a response toward a particular event so attitude has a great effect on IT projects. Developing an IT project is a great challenge for IT project manager and his team. So every member and manager should have good attitude. Attitude provides confidence and it is very important in decision making. So a good project manager should have a good attitude. Organization attitude has a great effect on Projects. So a good project manager must have following properties.
I)                   Respect
II)                Responsibility
III)             Empathy
IV)             Trust
V)                Confidence  

Free Host | lasik surgery new york