Friday, January 24, 2014

Cygwin complete Commands on Windows

Cygwin on Windows

Commands in Course Order:

Command
Usage
Comment
pwd
pwd
Print your current directory (folder) location
ls
ls
List the files in the current folder
mkdir
mkdir  Blast
Make a new folder.  Example Blast
cd
cd  /Blast
Change to another folder like Blast
cd
cd  c:/
Change to C drive
cd
cd   /
Change to the root directory.  Cygwin files are here
man
man  pwd
Show the manual pages for all command
cat  >
cat  >  file1
Create file1 and write data to it
cat  >>
cat  >>  file1
Add new lines to the bottom of file1
cat
cat  file1
Show/display contents of file1 to the screen
cat
cat  file1  file2
Show/display contents of file1 and file2 to the screen
sort
sort  file1
Sort the contents of file1
sort
sort  file1  file2
Sort the contents of file1 and file2 together
alias
alias  dog = “cat”
Assign the work dog to the cat command
alias
alias  path = “/BioDownload/bin/”
Type path instead of /BioDownload/bin/
|
cat  file1  file2  |  sort
Called Pipe.  Places output of cat into sort
head
head  TA496Seq1
View the first few lines of a file, especially a large file
tail
tail  TA496Seq1
View the first few lines of a file, especially a large file
less
less   TA496Seq1
View a large file and control the output
cp
cp  file1  file2_copy
Make a copy of file1 and call it file2_copy
cp
cp  file1  /Bioinfo
Make a copy of file1 and place it in the folder Bioinfo
cp
cp  file1  /Bioinfo/cp_test
Copy file1 into the folder Bioinfo and call it cp_test
mv
mv  file1  /Bioinfo
Move file1 into the folder Bioinfo
rm
rm  file1
Permanently delete file1
rm
rm  /Bioinfo/file2
Delete file2 which is located in the Bioinfo folder
rmdir
rmdir  /Bioinfo
Remove the folder called Bioinfo
grep
grep  “ATG”  file1 
Search for ATG in file1
grep
grep  “ATG”  file1  file2
Search for ATG in file1 and file2
grep
grep  -i  “ATG”  file1
Search for ATG in file1 regardless of case:  Atg, atg, ATg, and so on
grep
grep  -ic  “ATG”  file1
Search but return only a count of occurrences of all ATG
grep
An excellent reference
www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/

Commands in Alphabetical Order
Command
Usage
Comment
|
cat  file1  file2  |  sort
Called Pipe.  Places output of cat into sort
alias
alias  dog = “cat”
Assign the work dog to the cat command
alias
1alias  pathx = “/BioDownload/bin/”
Type pathx instead of /BioDownload/bin/
cat
cat  file1
Show/display contents of file1 to the screen
cat
cat  file1  file2
Show/display contents of file1 and file2 to the screen
cat  >
cat  >  file1
Create file1 and write data to it
cat  >>
cat  >>  file1
Add new lines to the bottom of file1
cd
cd  /Blast
Change to another folder like Blast
cd
cd  c:/
Change to C drive
cd
cd   /
Change to the root directory.  Cygwin files are here
cp
cp  file1  file2_copy
Make a copy of file1 and call it file2_copy
cp
cp  file1  /Bioinfo
Make a copy of file1 and place it in the folder Bioinfo
cp
cp  file1  /Bioinfo/cp_test
Copy file1 into the folder Bioinfo and call it cp_test
grep
grep  “ATG”  file1 
Search for ATG in file1
grep
grep  “ATG”  file1  file2
Search for ATG in file1 and file2
grep
grep  -i  “ATG”  file1
Search for ATG in file1 regardless of case:  Atg, atg, ATg, and so on
grep
grep  -ic  “ATG”  file1
Search but return only a count of occurrences of all ATG
grep
An excellent reference
www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/
head
head  TA496Seq1
View the first few lines of a file, especially a large file
less
less   TA496Seq1
View a large file and control the output
ls
ls
List the files in the current folder
man
man  pwd
Show the manual pages for all command
mkdir
mkdir  Blast
Make a new folder.  Example Blast
mv
mv  file1  /Bioinfo
Move file1 into the folder Bioinfo
pwd
pwd
Print your current directory (folder) location
rm
rm  file1
Permanently delete file1
rm
rm  /Bioinfo/file2
Delete file2 which is located in the Bioinfo folder
rmdir
rmdir  /Bioinfo
Remove the folder called Bioinfo
sort
sort  file1
Sort the contents of file1
sort
sort  file1  file2
Sort the contents of file1 and file2 together
tail
tail  TA496Seq1
View the first few lines of a file, especially a large file


1Note:  there are certain words that are reserved as “commands”.  For example we could not use “path” as an alias, but we could use “pathx”.

Basic Cygwin commands

Here are some basic Unix commands for navigating and exploring data:

Listing files and folders, type:


ls           - Lists the files and folders in the current directory
ls -lt      - Lists more information about all the files/folders in the current                              directory, one file/folder per line

Pattern matching

Example: 

1) ls time*? will list every file that starts with the word time while the command
ls time*.dat will match everything in the folder that begins with time and ends with .dat .

2) Tab            - The Tab button will complete the name of a file or folder if it is unique.  For example, if there is only one file that begins with untitled-2 then simply typing ls untitled-2 (Tab) will complete the file without having to type the rest of the letters. This saves a lot of time when most of the files are unique. 

3) Ctrl d         - This is typed if you have finished typing part of a filename and you need to find out which files have that same beginning part in their names.  For example, typing ls -untitled-2 (Ctrl d) will display all the files that have that beginning of the filename untitled-2.  After typing this, you can see what the exact name of the file you wish is named and type in the rest of the name.  When you combine Ctrl d with the Tab button, you typically only need to type a few letter per name, even if it is long.  This saves a considerable amount of time. 

4) Up arrow    - Typing the up arrow on the command line will show you the last command that was executed.  You can just modify this one or run it again to see the results of the same or new file. 

Changing folders/manipulation of folders


cd folder-name             - folder-name is the name of the folder you want to move to
pwd                                      - Displays what folder you are currently in
mkdir                                    - Creates a folder (directory)
rmdir                                    - Removes a folder (directory) but it must be empty
Changing/moving file/filenames
cp old-filename new-filename        - Copies the old file to the new filename without erasing the old file
mv old-filename new-filename        - Changes the old file to the new filename and erases the old file
rm filename                                    - Removes the filename you type

Printing a file

Cygwin users:  You can open regular text files in MS Word and save and print them normally. 

Viewing contents of a file

vi filename                     - vi is a visual program to view the text in a file such as the results from a program. 
head filename                - Shows the first 10 lines of a file
tail filename                - Shows the last 10 lines of a file. 

Executing/Stopping programs

To execute a program, you only need to type its name.  You may need to type ./ before the name, if your system does not check for executables in that file.
Ctrl c                     - This command will cancel a program that is running or wont automatically quite.  It will return you to the command line so you can run something else. 
vi program
Once you type the command above, the window will display the text.  Unlike a regular document program, vi does not let you just type using the keyboard.  Instead, each key has a function, such as move the cursor left or down.  Here are the basic commands you can use to edit and save the commands.  You can use the arrow keys just like normal, and must be used to move the cursor to the place you want to start typing/editing.  The mouse will not work in the standard vi program, only the keyboard is used.  This takes some getting used to. 
i                      - insert is similar to a but is to the left of where the cursor is.

a                      - appends to the data, after typing a you can use the keyboard to type in letter/numbers like a normal word processing program.  When you are done typing what you want at that location, you need to hit the Esc button before you can return to the regular mode. 

Esc                 - escape ends the current mode you are in (i.e. typing mode) and takes you back to the original.

x                      - Typing x lowercase will erase the character on the cursor, like the Backspace key does in a normal word processing program.  The Delete button will do the same thing in the regular mode.

:w                   - saves all the changes you made to a existing file name.

:w new-filename           - saves all the changes you made to a new filename you specify.

ZZ                   - Capital ZZ.  This will save and quit the vi program and bring you back to the command line.

:q!                 - This will quite the vi program without saving the last changes you made.

u                      - This is undo, and will undo the last action you have completed.

dd                   - This will erase the entire line.  Tying a number before typing dd will remove the number of lines chosen.

:se nu         - This is to set number lines which will temporarily number the lines of the document for you.

Ctrl f         - This will page down the document by one screen length.

Ctrl b         - This will page up the document by one screen length.

G                      - This will move the cursor to the end (bottom) of the document

1G                   - This will move the cursor to the top of the document

Tuesday, January 21, 2014

How to Open an Elevated Command Prompt in windows 8

Overview. The Command Prompt in Windows is the command-line interface program that is used to execute some low-level software or issue commands directly to your computer. The interface is very similar to the old Disk Operating System (DOS) that PCs used before the advent of the Windows operating system, and uses DOS syntax.

Some commands that change the basic functionality or licensing level of Windows require additional access privileges to execute. To run these commands, you will need to use an Elevated Command Prompt, which is the regular Command Prompt with Administrator-level access rights. You will need to know the username and Windows password of an account with full Administrator access rights before you can use the Elevated Command Prompt.

If you are using Windows 7 :

Click in the Start orb in the taskbar.
In the Search box, type cmd.exe but do NOT press Enter.
In the search results window, under Programs, right-click on the program cmd.exe.
In the pop-up menu, select Run As Administrator.
If a User Access Control window appears, log in with a Windows user account that has full Administrator access rights.
An Elevated Command Prompt window should now open.

If you are using Windows 8 & 8.1 :

If you are using a computer with a keyboard and mouse:
On the Windows 8 Start screen, just start typing the word command which will automatically open Search.
In the top left of the screen, under Apps, you should see a Command Prompt icon.
Right-click the Command Prompt icon.
This should open a menu at the bottom of the screen.
From the menu at the bottom of the screen, click Run As Administrator.
If a User Account Control window opens, log in with a Windows account with full Administrator access rights.
An Administrator: Command Prompt window should now be open.

If you are using a computer with only a touchscreen:

On the Windows 8 Start screen, swipe up to bring up the Apps menu.
Find the Windows System heading in your list of apps. You may need to swipe to the right to find it.
Find the Command Prompt icon in that list.
Tap and hold the Command Prompt icon.
This should open a menu at the bottom of the screen.
From the menu at the bottom of the screen, tap Run As Administrator.
If a User Account Control window opens, log in with a Windows account with full Administrator access rights.
An Administrator: Command Prompt window should now be open.

Cygwin complete Commands on Windows

Cygwin on Windows

Commands in Course Order:

Command
Usage
Comment
pwd
pwd
Print your current directory (folder) location
ls
ls
List the files in the current folder
mkdir
mkdir  Blast
Make a new folder.  Example Blast
cd
cd  /Blast
Change to another folder like Blast
cd
cd  c:/
Change to C drive
cd
cd   /
Change to the root directory.  Cygwin files are here
man
man  pwd
Show the manual pages for all command
cat  >
cat  >  file1
Create file1 and write data to it
cat  >>
cat  >>  file1
Add new lines to the bottom of file1
cat
cat  file1
Show/display contents of file1 to the screen
cat
cat  file1  file2
Show/display contents of file1 and file2 to the screen
sort
sort  file1
Sort the contents of file1
sort
sort  file1  file2
Sort the contents of file1 and file2 together
alias
alias  dog = “cat”
Assign the work dog to the cat command
alias
alias  path = “/BioDownload/bin/”
Type path instead of /BioDownload/bin/
|
cat  file1  file2  |  sort
Called Pipe.  Places output of cat into sort
head
head  TA496Seq1
View the first few lines of a file, especially a large file
tail
tail  TA496Seq1
View the first few lines of a file, especially a large file
less
less   TA496Seq1
View a large file and control the output
cp
cp  file1  file2_copy
Make a copy of file1 and call it file2_copy
cp
cp  file1  /Bioinfo
Make a copy of file1 and place it in the folder Bioinfo
cp
cp  file1  /Bioinfo/cp_test
Copy file1 into the folder Bioinfo and call it cp_test
mv
mv  file1  /Bioinfo
Move file1 into the folder Bioinfo
rm
rm  file1
Permanently delete file1
rm
rm  /Bioinfo/file2
Delete file2 which is located in the Bioinfo folder
rmdir
rmdir  /Bioinfo
Remove the folder called Bioinfo
grep
grep  “ATG”  file1 
Search for ATG in file1
grep
grep  “ATG”  file1  file2
Search for ATG in file1 and file2
grep
grep  -i  “ATG”  file1
Search for ATG in file1 regardless of case:  Atg, atg, ATg, and so on
grep
grep  -ic  “ATG”  file1
Search but return only a count of occurrences of all ATG
grep
An excellent reference
www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/

Commands in Alphabetical Order
Command
Usage
Comment
|
cat  file1  file2  |  sort
Called Pipe.  Places output of cat into sort
alias
alias  dog = “cat”
Assign the work dog to the cat command
alias
1alias  pathx = “/BioDownload/bin/”
Type pathx instead of /BioDownload/bin/
cat
cat  file1
Show/display contents of file1 to the screen
cat
cat  file1  file2
Show/display contents of file1 and file2 to the screen
cat  >
cat  >  file1
Create file1 and write data to it
cat  >>
cat  >>  file1
Add new lines to the bottom of file1
cd
cd  /Blast
Change to another folder like Blast
cd
cd  c:/
Change to C drive
cd
cd   /
Change to the root directory.  Cygwin files are here
cp
cp  file1  file2_copy
Make a copy of file1 and call it file2_copy
cp
cp  file1  /Bioinfo
Make a copy of file1 and place it in the folder Bioinfo
cp
cp  file1  /Bioinfo/cp_test
Copy file1 into the folder Bioinfo and call it cp_test
grep
grep  “ATG”  file1 
Search for ATG in file1
grep
grep  “ATG”  file1  file2
Search for ATG in file1 and file2
grep
grep  -i  “ATG”  file1
Search for ATG in file1 regardless of case:  Atg, atg, ATg, and so on
grep
grep  -ic  “ATG”  file1
Search but return only a count of occurrences of all ATG
grep
An excellent reference
www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/
head
head  TA496Seq1
View the first few lines of a file, especially a large file
less
less   TA496Seq1
View a large file and control the output
ls
ls
List the files in the current folder
man
man  pwd
Show the manual pages for all command
mkdir
mkdir  Blast
Make a new folder.  Example Blast
mv
mv  file1  /Bioinfo
Move file1 into the folder Bioinfo
pwd
pwd
Print your current directory (folder) location
rm
rm  file1
Permanently delete file1
rm
rm  /Bioinfo/file2
Delete file2 which is located in the Bioinfo folder
rmdir
rmdir  /Bioinfo
Remove the folder called Bioinfo
sort
sort  file1
Sort the contents of file1
sort
sort  file1  file2
Sort the contents of file1 and file2 together
tail
tail  TA496Seq1
View the first few lines of a file, especially a large file


1Note:  there are certain words that are reserved as “commands”.  For example we could not use “path” as an alias, but we could use “pathx”.

Basic Cygwin commands

Here are some basic Unix commands for navigating and exploring data:

Listing files and folders, type:


ls           - Lists the files and folders in the current directory
ls -lt      - Lists more information about all the files/folders in the current                              directory, one file/folder per line

Pattern matching

Example: 

1) ls time*? will list every file that starts with the word time while the command
ls time*.dat will match everything in the folder that begins with time and ends with .dat .

2) Tab            - The Tab button will complete the name of a file or folder if it is unique.  For example, if there is only one file that begins with untitled-2 then simply typing ls untitled-2 (Tab) will complete the file without having to type the rest of the letters. This saves a lot of time when most of the files are unique. 

3) Ctrl d         - This is typed if you have finished typing part of a filename and you need to find out which files have that same beginning part in their names.  For example, typing ls -untitled-2 (Ctrl d) will display all the files that have that beginning of the filename untitled-2.  After typing this, you can see what the exact name of the file you wish is named and type in the rest of the name.  When you combine Ctrl d with the Tab button, you typically only need to type a few letter per name, even if it is long.  This saves a considerable amount of time. 

4) Up arrow    - Typing the up arrow on the command line will show you the last command that was executed.  You can just modify this one or run it again to see the results of the same or new file. 

Changing folders/manipulation of folders


cd folder-name             - folder-name is the name of the folder you want to move to
pwd                                      - Displays what folder you are currently in
mkdir                                    - Creates a folder (directory)
rmdir                                    - Removes a folder (directory) but it must be empty
Changing/moving file/filenames
cp old-filename new-filename        - Copies the old file to the new filename without erasing the old file
mv old-filename new-filename        - Changes the old file to the new filename and erases the old file
rm filename                                    - Removes the filename you type

Printing a file

Cygwin users:  You can open regular text files in MS Word and save and print them normally. 

Viewing contents of a file

vi filename                     - vi is a visual program to view the text in a file such as the results from a program. 
head filename                - Shows the first 10 lines of a file
tail filename                - Shows the last 10 lines of a file. 

Executing/Stopping programs

To execute a program, you only need to type its name.  You may need to type ./ before the name, if your system does not check for executables in that file.
Ctrl c                     - This command will cancel a program that is running or wont automatically quite.  It will return you to the command line so you can run something else. 
vi program
Once you type the command above, the window will display the text.  Unlike a regular document program, vi does not let you just type using the keyboard.  Instead, each key has a function, such as move the cursor left or down.  Here are the basic commands you can use to edit and save the commands.  You can use the arrow keys just like normal, and must be used to move the cursor to the place you want to start typing/editing.  The mouse will not work in the standard vi program, only the keyboard is used.  This takes some getting used to. 
i                      - insert is similar to a but is to the left of where the cursor is.

a                      - appends to the data, after typing a you can use the keyboard to type in letter/numbers like a normal word processing program.  When you are done typing what you want at that location, you need to hit the Esc button before you can return to the regular mode. 

Esc                 - escape ends the current mode you are in (i.e. typing mode) and takes you back to the original.

x                      - Typing x lowercase will erase the character on the cursor, like the Backspace key does in a normal word processing program.  The Delete button will do the same thing in the regular mode.

:w                   - saves all the changes you made to a existing file name.

:w new-filename           - saves all the changes you made to a new filename you specify.

ZZ                   - Capital ZZ.  This will save and quit the vi program and bring you back to the command line.

:q!                 - This will quite the vi program without saving the last changes you made.

u                      - This is undo, and will undo the last action you have completed.

dd                   - This will erase the entire line.  Tying a number before typing dd will remove the number of lines chosen.

:se nu         - This is to set number lines which will temporarily number the lines of the document for you.

Ctrl f         - This will page down the document by one screen length.

Ctrl b         - This will page up the document by one screen length.

G                      - This will move the cursor to the end (bottom) of the document

1G                   - This will move the cursor to the top of the document

How to Open an Elevated Command Prompt in windows 8

Overview. The Command Prompt in Windows is the command-line interface program that is used to execute some low-level software or issue commands directly to your computer. The interface is very similar to the old Disk Operating System (DOS) that PCs used before the advent of the Windows operating system, and uses DOS syntax.

Some commands that change the basic functionality or licensing level of Windows require additional access privileges to execute. To run these commands, you will need to use an Elevated Command Prompt, which is the regular Command Prompt with Administrator-level access rights. You will need to know the username and Windows password of an account with full Administrator access rights before you can use the Elevated Command Prompt.

If you are using Windows 7 :

Click in the Start orb in the taskbar.
In the Search box, type cmd.exe but do NOT press Enter.
In the search results window, under Programs, right-click on the program cmd.exe.
In the pop-up menu, select Run As Administrator.
If a User Access Control window appears, log in with a Windows user account that has full Administrator access rights.
An Elevated Command Prompt window should now open.

If you are using Windows 8 & 8.1 :

If you are using a computer with a keyboard and mouse:
On the Windows 8 Start screen, just start typing the word command which will automatically open Search.
In the top left of the screen, under Apps, you should see a Command Prompt icon.
Right-click the Command Prompt icon.
This should open a menu at the bottom of the screen.
From the menu at the bottom of the screen, click Run As Administrator.
If a User Account Control window opens, log in with a Windows account with full Administrator access rights.
An Administrator: Command Prompt window should now be open.

If you are using a computer with only a touchscreen:

On the Windows 8 Start screen, swipe up to bring up the Apps menu.
Find the Windows System heading in your list of apps. You may need to swipe to the right to find it.
Find the Command Prompt icon in that list.
Tap and hold the Command Prompt icon.
This should open a menu at the bottom of the screen.
From the menu at the bottom of the screen, tap Run As Administrator.
If a User Account Control window opens, log in with a Windows account with full Administrator access rights.
An Administrator: Command Prompt window should now be open.