Versions Compared

Key

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

Table of Contents

...

Expand
titleOther Windows ssh/Terminal options

If your Windows version does not have ssh in Command Prompt or PowerShell:

More advanced options for those who want a full Linux environment on their Windows system:

From now on, when we refer to "Terminal", it is either the Mac/Linux Terminal program, Windows Command Prompt or PowerShell, or the PuTTY program.

...

The Terminal is pretty "dumb" – just sending what you type over its secure sockets layer (SSL) connection to TACC, then displaying the text sent back by the shell. The real work is being done on the remote computer, by executable programs called by the bash shell (also called commands, since you call them on the command line).

image-2023-4-26_9-27-6.pngImage Removed

The bash REPL and commands

When you type something in at a bash command-line prompt, it Reads the input, Evaluates it, then Prints the results, then does this over and over in a Loop. This behavior is called a REPL – a Read, Eval, Print Loop. Many programming language environments have REPLs – Python and R for example.

The input to the bash REPL is a command. Here are some examples:

Code Block
languagebash
ls               # example 1 - no options or arguments
ls -l            # example 2 - one "short" (single character) option only (-l)
ls --help        # example 3 - one "long" (word) option (--help)
ls .profile      # example 4 - one argument, a file name (.profile)
ls --width=20    # example 5 - a long option that has a value (--width is the option, 20 is the value)
ls -w 20         # example 6 - a short option w/a value, as above, where -w is the same as --width
ls -l -a -h      # example 7 - three short options entered separately (-l -a -h)
ls -lah          # example 8 - three short options that can be combined after a dash (-lah)

A command consists of:

  • The command name – here ls (list files)
    • A command can be any of the built-in Linux/Unix commands, or the name of a user-written script or program
  • One or more options, usually noted with a leading dash (-) or double-dash (--).
    • -l in example 2 (long listing)
    • --help in example 3
    • Options are optional – they do not have to be supplied (e.g. example 1 above)
  • One or more command-line arguments, which are often (but not always) file names
    • e.g. .profile in example 4

The shell executes the command line input when it sees a linefeed, which happens when you press Enter after entering the command.

Command options

The notes below apply to nearly all built-in Linux utilities, and to many 3rd party programs as well

  • Short (1-character) options can be provided separately, prefixed by a single dash(-)
    • or can be combined with the combination prefixed by a single dash (examples 7, 8)
  • Long (multi-character/"word") options are prefixed with a double dash (--) and must be supplied separately.
  • Many utilities have equivalent long and short options (e.g.  --width and -w above)
  • Both long and short options can be assigned a value (examples 5, 6)
    • The short option and its value are usually separated by a space, but can also be run together (e.g. -w20)
    • Strictly speaking, the long option and its value should be separated by an equal sign (=) according to the POSIX standard (see https://en.wikipedia.org/wiki/POSIX). But many programs let you use a space as separator also.

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)

The arguments to ls are one or more file/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.

Getting help

So how do you find out what options and arguments a command uses?

  1. In the Terminal, type in the command name then the --help long option (e.g. ls --help)
    • Works for most Linux commands; 3rd party tools may use -h or -? or even /? instead
    • May produce a lot of output, so you may need to scroll up quite a bit or pipe the output to a pager (e.g. ls --help | more)
  2. Use the built-in manual system (e.g. type man ls)
    • This system uses the less pager that we'll go over later.
    • For now, just know that a space advances the output by one screen/"page", and typing q will exit the display.
  3. Ask the Google, e.g. search for ls man page
    • Can be easier to read

Every Linux command has tons of options, most of which you'll never use. The trick is to start with the most commonly used options and build out from there. Then, if you need a command to do something special, check if there's an option already to do that.

A good place to start learning built-in Linux commands and their options is on our Linux fundamentals page.on the command line).

image-2023-4-26_9-27-6.pngImage Added

About the command line

Setting up your environment

...

Now execute the lines below to set up a login script, called ~/.bashrc. [ Note the tilde ( ~ ) is shorthand for "my Home directory". See Linux fundamentals: pathname syntax ]

When you login via an interactive shell, a well-known script is executed to establish your favorite environment settings. The well-known filename is ~/.bashrc (or ~/.profile on some systems), which is specific to the bash shell.

...

So why don't you see the .bashrc file you just copied to your home directory when you do ls? Because all files starting with a period (dot files) are hidden by default. To see them add the -l (long listing) and -a (all) options to ls:

...

Since your ~/.bashrc is executed when you login, to ensure it is set up properly you should first log off ls6 Lonestar6 like this:

Code Block
languagebash
titleLog off Lonestar6
exit

Your Terminal  has logged off of Lonestar6 and is now back on your local computer.

...

Environment variables are like variables in other programming languages like python or perl (in fact bash is a complete programming language). 

They have a name (like BIWORK above) and a value (the value of $BIWORK is the pathname of the shared /work/projects/BioITeam directory). Read more about environment variables here: See More on environment variables.

To see the value of an environment variable, use the echo command, then the variable name after a dollar sign ( $ ):

...