Thursday, 29 November 2012

What is SVN and how to use svn

SVN stands for Subversion , it allow developers to simultaneously work on a centralised project.

svn checkout

To check out means that you copy all the documents that your projects are working on to your computer.

The first commands
Go to home directory  and write cd  and give the following command:

svn co <user name>

where you have replaced <your_username> with the username you have aquired from the admin. This will enable you to check in your work. If you don't have a user name or just want to browse our code, just skip the username
Update your working copy
svn up
Scedule a file for addition
svn add filename ex(test.pl)

Schedule a file for deletion
svn delete filename
You may also copy and move files and directories with these two commands, but read about them in the svn 
svn copy filename ex(last.pl)
svn move filename ex(last1.pl)

Examine your changes
svn status
Examine the file history
svn log FILE
 
Change the commit message for a specific revision
svn propedit svn:log --revprop -r REV FILE
This will bring up the existing log text for the specified revision in your deta.This is useful if you accidentally committed some changes with an empty or uninformative log message.
Compare your modified file to the version in the repository
svn diff FILE
 
Compare some earlier versions, say here versions 100 and95
svn diff -r 100:95 FILE
 
Undo your local changes (ie revert to the repository status)
svn revert FILE
 
Resolve Conflicts  and Others' Changes
svn update
svn resolved

Commit your changes
svn ci -m "Your description of the changes here." FILE
 
  the above changes, add, delete, copy, move, must all be committed by ci in order to take effect

Saturday, 24 November 2012

How to Set Up a Password-less SSH Login

First, on the local machine you will want to generate a secure SSH key:
ssh-keygen

Walk through the key generator and set a password, the key file by default goes into ~/.ssh/id_rsa

Next, you need to copy the generated key to the remote server you want to setup passwordless logins with, this is easily done with the following command string but you can use scp if you’d prefer:
cat ~/.ssh/id_dsa.pub | ssh user@remotehost 'cat >> ~/.ssh/authorized_keys'

This command takes the generated SSH key from the local machine, connects to the remote host via SSH, and then uses cat to append the key file to the remote users authorized key list. Because this connects with SSH to the remote machine you will need to enter the password to use this command.
Finally, confirm that you can now login to the remote SSH server without a password:
ssh user@remotehost.com

Assuming initial setup went as intended, you will connect to the remote machine without having to log in.

Thursday, 22 November 2012

Basic UNIX Commands

  • cat --- for creating and displaying short files
  • chmod --- change permissions
  • cd --- change directory
  • cp --- for copying files
  • date --- display date
  • echo --- echo argument
  • ftp --- connect to a remote machine to download or upload files
  • grep --- search file
  • head --- display first part of file
  • ls --- see what files you have
  • lpr --- standard print command (see also print )
  • more --- use to read files
  • mkdir --- create directory
  • mv --- for moving and renaming files
  • print --- custom print command (see also lpr )
  • pwd --- find out what directory you are in
  • rm --- remove a file
  • rmdir --- remove directory> %
  • rsh --- remote shell
  • setenv --- set an environment variable
  • sort --- sort file
  • tail --- display last part of file
  • tar --- create an archive, add or extract files 
  • telnet --- log in to another machine


cat
This is one of the most flexible Unix commands. We can use to create, view and concatenate files. For our first example we create a three-item English-Spanish dictionary in a file called "dict."
% cat >dict
 test1
 test2
 test3
<control-D>
   %
chmod

This command is used to change the permissions of a file or directory. For example to make a file new_file.pl readable by everyone, we do this:
   % chmod a+r new_file.pl
To make a file, e.g., a shell script mycommand executable, we do this
   % chmod +x mycommand
Now we can run mycommand as a command.
To check the permissions of a file, use ls -l . For more information on chmod, use man chmod.

cd
Use cd to change directory. Use pwd to see what directory you are in.
   % cd english
   % pwd
   % /test_file/test
   % ls
scrapbook
   % cd

cp
Use cp to copy files or directories.
   % cp test_file test_file.bk
This makes a copy of the file test_file.
   % cp ~/new_file/new_file.bk
This copies the file jabber in the directory poems to the current directory. The symbol "." stands for the current directory. The symbol "~" stands for the home directory.

date
Use this command to check the date and time.
   % date
Fri Nov  6 08:52:42 MST 2012

echo
The echo command echoes its arguments. Here are some examples:

grep

Use this command to search for information in a file or files. For example, suppose that we have a file dict whose contents are
redtest1
white test1

head

Use this command to look at the head of a file. For example,
   % head test.pl
displays the first 10 lines of the file essay.001 To see a specific number of lines, do this:
   % head -n 20 test.pl
This displays the first 20 lines of the file.

ls
Use ls to see what files you have. Your files are kept in something called a directory.
   % ls
     test      letter2
     test1    letter3
     test3   maple-assignment1
  

lpr
This is the standard Unix command for printing a file. It stands for the ancient "line printer." See
   % man lpr
for information on how it works. See print for information on our local intelligent print command.

mkdir
Use this command to create a directory.

   % mkdir test

mv
Use this command to change the name of file and directories.
   % mv foo foobar
The file that was named foo is now named foobar

print
This is a moderately intelligent print command.
   % print foo
   % print notes.ps
   % print manuscript.dvi

pwd
Use this command to find out what directory you are working in.
   % pwd

rm
Use rm to remove files from your directory.
   % rm test.pl
     remove test.pl? y
   % rm letter*
     remove letter1? y
     remove letter2? y

 rmdir
Use this command to remove a directory. For example, to remove a directory called "essays", do this:
   % rmdir essays
A directory must be empty before it can be removed. To empty a directory, use rm.

rsh
Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command
% rsh solitude
connects you to the machine solitude. This is one of our public workstations and is fairly fast.

sort
Use this commmand to sort a file. For example, suppose we have a file dict with contents
red test
white test1

tail

Use this command to look at the tail of a file. For example,
   % tail new_test.pl
displays the last 10 lines of the file new_test.pl To see a specific number of lines, do this:

   % tail -n 20 new_test.pl
This displays the last 20 lines of the file.

tar
Use create compressed archives of directories and files, and also to extract directories and files from an archive. Example:
   % tar -tvzf test.tar.gz
displays the file names in the compressed archive foo.tar.gz while
   % tar -xvzf test.tar.gz
extracts the files.

telnet
Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "solitude", do this:
   % telnet solitude
See also: rsh.

wc
Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contents
test file
test1 file1

Then we can do this
   % wc dict
     5      10      56 tmp
This shows that dict has 2 lines, 4 words, and 18 characters.