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.
Table of Contents |
---|
Terminal programs, shells and
...
commands
You need a Terminal program in order to ssh to a remote computer.
...
- 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 |
...
- The arguments to ls are one or more file /or directory names. If no arguments are provided, the contents of the current directory are listed.
- If an argument is a directory name, the contents of that directory are listed.
- If an argument is a directory name, the contents of that directory are listed.
Some handy options for ls:
- -l shows a long listing, including file permissions, ownership, size and last modified date.
- -a shows all files, including dot files whose names start with a period ( . ) which are normally not listed
- -h says to show file sizes in human readable form (e.g. 12M instead of 12201749)
...
- literal characters, that just represent (and print as) themselves
- e.g. alphanumeric characters A-Z, a-z, 0-9
- metacharacters- these are special characters that are associated with an operation in the environment
- e.g. the pound sign ( # ) comment character that tells the shell to ignore everything after the #
- e.g. the pound sign ( # ) comment character that tells the shell to ignore everything after the #
There are many metacharacters in bash: # \ $ | ~ [ ] to name a few.
Pay attention to the different metacharacters and their usages – which can depend on the context where they're used.
...
You know the command line is ready for input when you see the command line prompt. The shell executes command line input when it sees a linefeed character (\n, also called a newline), which happens when you press Enter after entering the command.
Expand | ||
---|---|---|
| ||
Note: The Unix linefeed (\n) line delimiter is different from Windows, where the default line ending is carriage-return + linefeed (\r\n), and some Mac text editors that just use a carriage return (\r). |
More than one command can be entered on a single line – just separate the commands with a semi-colon ( ; ).
Code Block | ||||
---|---|---|---|---|
| ||||
cd; ls -lh |
...
Notice that the shell indicates that it is not done with command-line input by displaying a greater than sign ( > ). You just enter more text then Enter when done.
...
Sometimes a line of text is longer than the width of your Terminal. In this case the text is wrapped. It can appear that the output is multiple lines, but it is not. We can see that by looking at lines of the mobydick.txt file, that has some very For example, FASTQ files often have long lines:
Code Block | ||
---|---|---|
| ||
tail -1 mobydick.txt cat -n mobydick.txt | morehead $CORENGS/misc/small.fq |
Note that most Terminals let you increase/decrease the width/height of the Terminal window. But there will always be single lines too long for your Terminal width (and too many lines of text for its height).
So how long is a line? And So how many lines of output are there in a filereally? And how long is a line? The wc (word count) command can tell us this.
- wc -l reports the number of lines in its input
- wc -c reports the number of characters in its input (including invisible linefeed characters)
And when you give wc -
...
l multiple files, it reports the
...
Examples:
...
line count of each, then a total.
Code Block | ||
---|---|---|
| ||
wc -l mobydick.txt $CORENGS/misc/small.fq # Reports the number of lines in the mobydicksmall.txtfq file cat mobydick.txt$CORENGS/misc/small.fq | wc -l # Reports the number of lines of its input wc -l $CORENGS/misc/*.fq # Reports the number of lines in all matching *.fq files tail -1 mobydick.txt$CORENGS/misc/small.fq | wc -c # Reports the number of characters of the last mobydicksmall.txt line |
...
fq line |
Command input errors
You don't always type in commands, options and arguments correctly – you can misspell a command name, forget to type a space, specify an unsupported option or a non-existent file, or make all kinds of other mistakes.
...