Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Use ssh (secure shell) to login to a remote computers.

Code Block
languagebash
titleSSH to a remote computer
# General form:
ssh <user_name>@<full_host_name>

# For example
ssh abattenh@ls6.tacc.utexas.edu

...

Code Block
languagebash
tail /etc/passwd | while IFS=':' read account x uid gid name shell
do 
  echo $account $name
done | more

Writing multiple text lines

There are several ways to output multi-line text. You can:

  • Start the text with a single quote or a double quote
    • press Enter when you want to start a new line
    • keep entering text and Enter until you're satisfied
    • supply the matching single quote or a double quote then Enter
    • example:

      Code Block
      echo 'My
      name is
      Anna'


  • Use echo -e
    • The -e option tells echo to replace some special backslash escapes characters that represent non-printable characters with their associated ASCII codes
      • So \n will be replaced by a newline (linefeed) character and \t will be replaced by a Tab.
    • example:

      Code Block
      echo -e "My\nname is\nAnna"


heredoc

Another method for writing multi-line text that can be useful for composing a large block of text in a script, is the heredoc syntax, where a block of text is specified between two user-supplied block delimiters, and that text block is sent to a command. The general form of a heredoc is:

Code Block
languagebash
COMMAND << DELIMITER
..text...
..text...
DELIMITER


Tip

The 2nd (ending) block delimiter you specify for a heredoc must appear at the start of a new line.

For example, using the (arbitrary) delimiter EOF and the cat command:

Code Block
languagebash
cat << EOF
This text will be output
And this USER environment variable will be evaluated: $USER
EOF

Here the block of text provided to cat is just displayed on the Terminal. To write it to a file just use the 1> or > redirection syntax after the block delimiter you name:

Code Block
languagebash
cat << EOF 1> out.txt
This text will be output
And this USER environment variable will be evaluated: $USER
EOF

The out.txt file will then contain this text:

Code Block
languagebash
This text will be output
And this USER environment variable will be evaluated: student01

Copying files between TACC and your laptop
Anchor
Copying_files_to_from_TACC
Copying_files_to_from_TACC

...