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 |
...
Tip | |||||
---|---|---|---|---|---|
To display a metacharacter as a literal inside double quotes, use the backslash ( \ ) character to escape the following character.
|
You can also use either single or double quotes to enclose text you want to appear on multiple lines:
Code Block | ||
---|---|---|
| ||
# this expression will output 4 lines of text
echo "1
2
3
4
|
backtick quoting and sub-shell evaluation
...
Code Block | ||
---|---|---|
| ||
today=$( date ); echo $today # environment variable "today" is assigned today's date today="Today is: `date`"; echo $today # "today" is assigned a string including today's date |
What is text?
So what exactly is text? That is, what is stored in files that the shell interprets as text?
On standard Unix systems, each text character is stored as one byte – eight binary bits – in a format called ASCII (American Standard Code for Information Interchange). Eight bits can store 2^8 = 256 values, numbered 0 - 255.
In its original form values 0 - 127 were used for standard ASCII characters. Now values 128 - 255 comprise an Extended set. See https://www.asciitable.com/
However not all ASCII "characters" are printable -- in fact the "printable" characters start at ASCII 32 (space).
ASCII values 0 - 31 have special meanings. Many were designed for use in early modem protocols, such as EOT (end of transmission) and ACK (acknowledge), or for printers, such as VT (vertical tab) and FF (form feed).
The non-printable ASCII characters we care most about are:
- Tab (decimal 9, hexadecimal 0x9, octal 0o011)
- backslash escape: \t
- Linefeed/Newline (decimal 10, hexadecimal 0xA, octal 0o012)
- backslash escape: \n
- Carriage Return (decimal 13, hexadecimal 0xD, octal 0o015)
- backslash escape: \r
Let's use the hexdump command (really an alias, defined in your ~/.bashrc login script) to look at the actual ASCII codes stored in a file:
Code Block | ||
---|---|---|
| ||
tail ~/.bashrc | hexdump |
This will produce output something like this:
Each line here describes 16 characters, in three display areas:
- The numeric offset of the 16-character line, in hexadecimal (base 16)
- 16 decimal is 0x10 hex
- The numeric value (ASCII code) for each character, again in hexadecimal
- each 2-digit hex number represents one 8-bit byte/character
- The translated text, written between a greater than ( > ) and less than ( < ) sign
- The display character associated with each ASCII code, or a period ( . ) for non-printable characters
Notice that spaces are ASCII 0x20 (decimal 32), and the newline characters appear as 0x0a (decimal 10).
Why hexadecimal? Programmers like hexadecimal (base 16) because it is easy to translate hex digits to binary, which is how everything is represented in computers. And it can sometimes be important to know which binary bits are 1s and which are 0s. (Read more about Decimal and Hexadecimal)
Writing multiple text lines
...