This page should serve as a reference for the many "things Linux" we use in this course. It is by no means complete – Linux is **huge** – but offers introductions to many important topics.
...
- Macs and Linux have a Terminal program built-in
- Windows options:
- Windows 10+
- Command Prompt and PowerShell programs have ssh and scp (may require latest Windows updates)
- Start menu → Search for Command
- Putty – http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- simple Terminal and file copy programs
- download either the Putty installer or just putty.exe (Terminal) and pscp.exe (secure copy client)
- Windows Subsystem for Linux – Windows 10 Professional includes a Ubuntu-like bash shells
- See https://docs.microsoft.com/en-us/windows/wsl/install-win10
- We recommend the Ubuntu Linux distribution, but any Linux distribution will have an SSH client
- Command Prompt and PowerShell programs have ssh and scp (may require latest Windows updates)
- Windows 10+
Use ssh (secure shell) to login to a remote computers.
| Code Block | ||||
|---|---|---|---|---|
| ||||
# General form: ssh <user_name>@<full_host_name> # For example ssh abattenh@ls6.tacc.utexas.edu |
...
Of course Google works on 3rd party tools also (e.g. search for bwa manual)
Viewing text in files
cat, more or less
The most basic way of view file data is the cat command. While the name comes from its ability to concatenate one or more files, it can be used to output the contents of a single file. For example:
| Code Block |
|---|
cat ~/.profile
# or, to see line numbers in the output:
cat -n ~/.profile |
Using cat by itself is fine for small files, but it reads/writes everything in the file without stopping. So for larger files you use a pager such as more, or less. A pager reads text and outputs only one "page" of text at a time, then waits for you to ask it to advance. And a "page" of text is the number of lines that will fit on your visible Terminal.
Using the more pager:
| Code Block |
|---|
more ~/.bashrc |
- Press the spacebar to see the next page.
- If there is additional output, you'll see the --More-- indicator again; if not, the command prompt appears again.
- To end the more display, just type q (quit) or Ctrl-c.
Using the less pager:
| Code Block |
|---|
less ~/.bashrc
# to see line numbers in the output:
less -N ~/.bashrc
# to use case-insensitive matching:
less -I ~/.bashrc |
Basic navigation in less:
- Use q to quit less at any time
- space or Ctrl-f advances one page forward; Ctrl-b goes back one page
- down arrow goes down (forward) one line; up arrow goes up (backward) one line
Searching in less:
- /<pattern> – search for <pattern> in forward direction
- n – goes to the next match of <pattern>
- N – goes to the previous match of <pattern>
- ?<pattern> – search for <pattern> in backward direction
- n – previous match going back
- N – next match going forward
Introducing grep
Another method of text searching is using the grep program, which stands for general regular expression parser. In Unix, the grep program performs regular-expression text searching, and displays lines where the pattern text is found.
Nearly every programming language offers grep functionality, where a pattern you specify – a regular expression or regex – describes how the search is performed.
There are many grep regular expression metacharacters that control how the search is performed (see the grep command).
Basic usage is: grep '<pattern>' <file> where
- '<pattern>' (usually enclosed in single quotes) just contains alphanumeric characters (A-Z, a-z, 0-9).
Common options:
- grep -i will perform a case-insensitive search
- grep -n will display line numbers where the pattern was matched
Terminal input
Literal characters and metacharacters
...