Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, January 30, 2011

Installing Mercurial on RHEL 5.5

Finally after a few attempts, I could install mercurial on RHEL.

Here are the steps I followed and thanks to a few forum posts, I found out my way through it.

So I tried all kinds of ways but what eventually worked was easy_install.

So this is what you need.

easy_install
python-setuptools

Downloaded the latest mercurial rpm.  Untar it.

Now if you dont have easy_install, install it by running the below command

wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg#md5=bd639f9b0eac4c42497034dec2ec0c2b

Once you are done downloading run the below command

ronak@ronak ~ $ sudo sh setuptools-0.6c11-py2.4.egg
[sudo] password for ronak:
Processing setuptools-0.6c11-py2.4.egg
removing '/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg' (and everything under it)
creating /usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg
Extracting setuptools-0.6c11-py2.4.egg to /usr/lib/python2.4/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/bin
Installing easy_install-2.4 script to /usr/bin

Installed /usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11




If you see this, easy_install is installed on your system.

Now, remember you have the untar directory mercurial1.7 (or whatever you have).  Make sure you are at that location.

Run the below command

ronak@ronak ~ $ sudo easy_install mercurial-1.7/
ronak@ronak ~ $ sudo easy_install mercurial-1.7/
Processing
Running setup.py -q bdist_egg --dist-dir /usr/local/home/rpatel/mercurial-1.7/egg-dist-tmp-bHHAXk
zip_safe flag not set; analyzing archive contents...
mercurial.help: module references __file__
mercurial.lsprof: module references __file__
mercurial.commands: module references __file__
mercurial.extensions: module references __file__
mercurial.i18n: module references __file__
mercurial.templater: module references __file__
hgext.mq: module references __file__
Adding mercurial unknown to easy-install.pth file
Installing hg script to /usr/bin

Installed /usr/lib/python2.4/site-packages/mercurial-unknown-py2.4-linux-i686.egg
Processing dependencies for mercurial==unknown
Finished processing dependencies for mercurial==unknown


ronak@ronak ~ $ hg
Mercurial Distributed SCM

basic commands:

 add        add the specified files on the next commit
 annotate   show changeset information by line for each file
 clone      make a copy of an existing repository
 commit     commit the specified files or all outstanding changes
 diff       diff repository (or selected files)
 export     dump the header and diffs for one or more changesets
 forget     forget the specified files on the next commit
 init       create a new repository in the given directory
 log        show revision history of entire repository or files
 merge      merge working directory with another revision
 pull       pull changes from the specified source
 push       push changes to the specified destination
 remove     remove the specified files on the next commit
 serve      start stand-alone webserver
 status     show changed files in the working directory
 summary    summarize working directory state
 update     update working directory (or switch revisions)

use "hg help" for the full list of commands or "hg -v" for details
ronak@ronak ~ $

Hurray... You are done..!!!!


Yum

YUM (Yellow Dog Updater, Modified)

The Yellowdog Updater, Modified (YUM) is an open-source command-line package-management utility for RPM-compatible Linux operating systems and has been released under the GNU General Public License. It was developed by Seth Vidal and a group of volunteer programmers. Though yum has a command-line interface, several other tools provide graphical user interfaces to yum functionality.


Installing and Upgrading Packages with Yum

Install Packages, Upgrade packages and System upgrades
Update your package list
# yum check-update
Install a new package
# yum -y install compiz
-y flag allows unattended installation.
Update a single Package
# yum update gnome
Update several packages
# yum update nbserver nbweb-billing nginx
Update all installed packages
# yum update
Search for a package to install
# yum search ImageMagick
If you need a particular library, but don't know what package provides it, yum will find it
# yum provides compiz

Removing Packages through Yum

# yum remove compiz
# yum remove compiz gnome ImageMagick

Obtaining information of installed packages through Yum

# yum list compiz
# yum list | grep gnome
# yum info compiz
# yum list updates

Maintain Yum

# yum clean packages -- to delete all cached packages
# yum clean headers -- to force fresh download of package headers
# yum clean oldheaders -- to remove old headers that the system no longer needs
# yum clean all == remove cached packages and old headers, preserving all the current headers

RPMs

Red Hat Package Management


Installing RPMs

# rpm -i packagename

# rpm -ivh packagename
  -v adds verbose feedback, and -h draws progress hashmarks

# rpm -ivh --test packagename

Upgrading RPMs

# rpm -Uvh packagename

To test the package install without really installing it.
# rpm -Uvh --test packagename


Removing RPMs

#rpm -e packagename does the job 

# rpm -ev packagename

( You dont need to mention the entire package, (abcd-1.23.34.5.i386.rpm) just the label name (abcd).


Removing/Uninstalling multiple RPMs at once.

# rpm -ev packagename packagename packagename


If you dont want to check dependencies,

#rpm -ev --nodeps packagename


To test your command before uninstalling/removing
#rpm -ev --test packagename


Collecting information on Installed RPMs
Use RPM's querying features.  All the queries start with rpm -q.
# rpm -q compiz

# rpm -qa | grep ubuntu

Listing files in an installed package

# rpm -ql compiz



To list the documentation for an application, use

# rpm -qd ubuntu

To list the configuration files for a package, use

# rpm -qc compiz

Listing the configuration files for a command

# rpm -qcf /usr/bin/ssh


To list all the packages installed, use

# rpm -qa

To see what package a file belongs to, use

# rpm -qf /usr/bin/abcd

To display package information 

# rpm -qi packagename


RPM queries will not follow symlinks, and will report that the file is "not owned by any package"  To find the file that a symlink points to , use:

# namei ~/ronak

Collecting Information from RPMs that are not installed.

Listing documentation files
# rpm -qpd abcd.rpm


Listing all the files of the package:

# rpm -qp1 abcd.rpm

Listing dependencies this package requires, 
# rpm -qpR abcd.rpm


To see what this package provides

# rpm -qp --provides abcd.rpm


Finding recentally installed RPMs

# rpm -qa --last
If the list is too long, rpm -qa --last | head.


Rebuild RPM database

# rpm --rebuilddb


Recreate RPM database
# rpm --initdb















Thursday, December 30, 2010

VIM

Vim Text Editor

Pros:
  • On every platform
  • 100% keyboard driven
  • Text surgery
  • powerful editing
  • Local and remote
  • Highly configurable
  • Extendable with plugins
  • Mac-friendly
  • Great Documentation
  • Long-terms skills
Cons:
  • Undesirable defaults
  • Clunky scripting Language
  • Destructive tasks are too easy
  • Inconsistent regular expressions
Started in 1976 then 1991 and now it is called VIMproved (VIM)

Main modes of VI editor
  1. Normal
  2. Insert
  3. Visual
  4. Replace
  5. Command-line
Upper case commands are super sized versions of the lower case commands

i - Inserts text starting from the cursor
I - Inserts text starting from the beginning of the line.
w - moves forward one word
3w - moves forward 3 words
b - moves backware one word
W - moves contiguous code as one word and move forward to the next meaningful word
dd - deletes the line where the cursor is located
dw - deletes the word
d2w - delete two words
G - goes to the end of the file
gg - goes to the start of the file
:w - write file (save)
:w! - write without confirmation
:q! - quit vim
:wq! - write and quit
:e filename - opens a file to edit
code folding command starts with a z
 
cw - change word
3cw - change three words
:h - help:bd - buffer delete

yy - yank line (copy)
Y - yank line (copy)
p - paste below cursor
P - paste above cursor
a - append text after cursor
6l - Forward six letters
2j - Down two lines
fN - Jump forward to the first 'N'
3fN - Jump forward to third 'N'
n- Next 

u - undo
Ctrl+R - redo

vim -N abcd.py (-N compatible with the latest version only)

Vim comes with 500 different syntax highlights.

:syntax enable
:set syntax=apache

:set hidden
:set syntax=python
:set syntax=cpp

:w !sudo tee %

:set incsearch
:set hlsearch


Search and replace

:%s/search/replace/gc

  % search the current buffer
  g - search for all occurance
  c - ask for confirmation on each match

e.g :%s/2.\2\.8/2.2.9/gc - this will replace all 2.2.8 occurances to 2.2.9 and will confirmation all occurances.

:set number
12G - go to line 12

:cd path
:pwd
:e . - to find out the files in the directory


V - visual mode

:b name - Switch to buffer (try TAB and arrows as well)
:bp - Previous buffer

:set autochdir - Automatically use the current file's directory as the working directory


Check out the vim-rooter plugin.

:set wildmode=list:longest - Activate TAB auto-completion for file paths.

Directory listing.

i - thin, long, wide or tree listings
s - sort on name, time or file size
r - Reverse sort order
gh - Hide or unhide dot files
- Open the file or directory
x - View file with associated application
d - Make directory
D - delete the file or directory
R - Rename the directory or file
- <-- Go up a directory


Window Management

Ctrl+w s - split window horizontally
Ctrl+w v - split vertically
Ctrl+w j - Move focus down
Ctrl+w k - Move focus up
Ctrl+w h - Move focus left
Ctrl+w l - Move focus right

Ctrl+w J - Move buffer up one window
Ctrl+w K - Move buffer down one window
Ctrl+w H - Move buffer left one window
Ctrl+w L - Move buffer right one window

Ctrl+w c - Close window
Ctrl+w o - Close all but current
Ctrl+w w - Cycle focus
Ctrl+w p - Focus previous window