Friday, July 20, 2007

Common Cygwin Commands

I am assuming that you also installed cygwin in c:\cygwin. Activate cygwin using below command in the command prompt.

C:\>cygwin\cygwin

CP
Copy from here to there.
$ cp -r path/fromDirectory path/toDirectory

CURL
Upload an archive at ftp location.
$ curl -T archive.tgz ftp://localhost -u newuser

GZIP
List the content of an archive.
$ gzip -l listContentsInMyFile.tar.gz

INFO
C:\>cygwin\cygwin
$ info commandName

MAN
C:\>cygwin\cygwin
$ man commandName

RM
Remove a file.
rm -v filename.ext

Remove a directory.
rm -rv directory

TAR
C:\>c:\cygwin\bin\tar -cvf createdMyStuff_C_Drive.tar myStuff_C_Drive
C:\>c:\cygwin\bin\tar -xvf extractMyStuff_C_Drive.tar

Uses GZIP to compress the file. tar converts directory into a file. gzip just compresses a file.
$ tar -cvzf backup.tgz directory
c = create, v = verbose, z = compress with GZIP, f = archive name

Extract the contents from the zip file.
$ tar -xvzf backup.tgz 
x = extract, v = verbose, z = use GZIP, f = archive name

For better compression you can use below also.
$ tar -cvjf backup.tar.bz2 directory

Decompress the backup using below command.
$ tar -xvjf backup.tar.bz2

No comments: