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
titleExecute this at TACC
cd $SCRATCH/core_ngs/fastq/prep
pwd -P

This will return display something like /scratch/01063/abattenh/core_ngs/fastq_prep.

For folks with Mac or Linux laptops or Windows 10+ users with scp available in the Command Prompt program (or running Windows Subsystem subsystem for Linux, or a Command Prompt with scp available):

  • Open a Terminal window on your local computer
  • cd to the directory where you want the files
  • Type something like the following, substituting your user name and absolute path:

...

Windows users can use the free WinSCP program (https://winscp.net/eng/index.php) if their Windows version does not support scp.

Editing files

There are several options for editing files at TACC. These fall into three categories:

...

three main approaches to editing Unix files:

  1. Use a command-line program that lets you enter/edit text in a Terminal window (e.g. nano, vi/vim, emacs)
    1. nano is extremely simple and is a good choice as a first local text editor
      **Warning**
        • warning: nano has a tendency to break long single lines into multiple lines
      1. vi and emacs are extremely powerful but also quite complex
    2. Text editors or IDEs that run Use a text editor or IDE (Integrated Development Environment) program that runs on your local computer but have has an SFTP (secure FTP) interface that lets you connect to a remote computer
      • E.g.,Komodo IDE (Windows & Mac) or Notepad++ or Komodo Edit (Windows). Both are no-cost.
      • Once you connect to the remote host, you can navigate its directory structure and edit files.
      • When you open a file, its contents are brought over the network into the text editor's edit window, then saved back when you save the file.
    3. Software Use software or protocols that will allow you to mount your home directory on TACC as if it were a normal disk
      then"mount" remote server directories
      • Once mounted, the remote storage appears as a local volume/drive.
        • Then, you can use any text editor or IDE on your local computer to open/edit/save
        files (although it will be slower than local file editing)e.g.
        • remote files.
      • Software programs that can mount remote data include ExpanDrive for Windows or Mac (costs $$, but has a free trial), TextWrangler for Mac.
      • Remote file system protocols include Samba (Windows, Mac) and NFS (Linux)

    Knowing the basics of at least one Linux command-line text editor is useful for creating/editing small files like TACC commands files. We, and we'll use nano and basic emacs for this in explore nano in this class. For editing larger files, you may find options #2 or #3 more useful.

    ...

    To invoke nano to edit a new or existing file just type nano <filename>. For example:

    Code Block
    languagebash
    titleStart the nano text editor
    nano <filename>
    

    You'll see a short menu of operations at the bottom of the terminal window. The most important are:

    newfile.txt

    You'll see the name of the file (if you supplied one) on the top line of the Terminal window.

    Navigation and operations in nano are similar to those we discussed in Command line editing

    You can just type in text, and navigate around using arrow keys (up/down/left/right). A couple of other navigation shortcuts:

    • Ctrl-a - go to start of line
    • Ctrl-e - go to end of line
    • Arrow keys are also modified by Ctrl- (Windows) or Option- (Mac)
      • Ctrl-right-arrow (Windows) or Option-right-arrow (Mac) will skip by "word" forward
      • Ctrl-left-arrow (Windows) or Option-left-arrow (Mac) will skip by "word" backward

    Once you've positioned the cursor where you want it, just type in your text.

    Warning

    Be careful with long lines – sometimes nano will split long lines into more than one line, which can cause problems in a commands file where each task must be specified on a single line.

    To remove text:

    • To delete text after the cursor, use:
      • Delete key on Windows
      • Function-Delete keys on Macintosh
    • To delete text before the cursor, use:
      • Backspace key on Windows
      • Delete key on Macintosh
    • Use Ctrl-k (kill) to delete everything on the line
      • This is different from Ctrl-k on the command line where it deletes everything after the cursor
    • Use Ctrl-u (uncut) to paste the just-killed text at the cursor
      • Recall this operation is Ctrl-y (yank) for command line editing

    Once you're satisfied with your edits:

    • use Ctrl-o - write out the file
    • use Ctrl-x - exit nano

    You can just type in text, and navigate around using arrow keys. A couple of other navigation shortcuts:

    ...

    These and other important nano operations are displayed in a menu at the bottom of the Terminal window. Note that the ^ character means Ctrl- in this menu.

    emacs

    emacs is a complex, full-featured editor available on most Linux systems.

    ...

    Warning

    Be careful when pasting text into an emacs buffer – it takes a few seconds before emacs is ready to accept the full pasted text.

    Double-check that the 1st line of pasted test is correct – emacs can clip the 1st few characters if the paste is done too soon.

    ...

    The dirty little secret of the computer world is that the three main "families" of computers – Macs, Windows and Linux/Unix – use different, mutually incompatible line endings.

    • Linux/Unix uses linefeed ( \n )
    • Windows uses carriage return followed by linefeed ( \r\n )
    • some Mac programs use carriage return only ( \r )

    And guess what? Most Linux programs don't work with files that have Windows or Mac line endings, and what's worse they give you bizarre error messages that don't give you a clue what's going on!

    ...