Welcome to SSW

Overview


Welcome to SSW


David Bindel gave an opening spiel on the club and its purpose. A page was passed around to collect netids in order to set up accounts on our local instructional cluster (Totient).

Working with a Unix Shell


Stephen McDowell spoke about the basics of working at the terminal in Unix/Linux (the environment on Totient, and the default environment for interacting with many other cloud and HPC resources). The talk was based on slides form a half-semester course that he taught this spring, CS 2043.

The below is intended to be a bare-bones minimum in functioning with your Unix terminal / reference as you get familiar with your terminal.

pwd

  • Prints the "full" path of the current directory.
  • Handy on minimalist systems when you get lost.
  • Can be used in scripts.
  • Note: if you are following symbolic links, you need to use the -P flag.

ls [directory / filename]

  • List directory contents (including subdirectories).
  • Works like the dir command in Windows.
  • The -l flag lists detailed file / directory information.
  • Use -a to list hidden files.
    • Hidden folders / files in Unix start with a ..
    • E.g. .git/ or .gitignore.

cd [directory name]

  • Changes directory to [directory name].
  • If not given a destination, defaults to the user's home directory (~).
  • You can specify both absolute and relative paths.

File Paths

  • Absolute paths start at / (the global root).
    • E.g. cd /home/sven/Desktop
  • Relative paths start at the current directory.
    • cd Desktop, if you were already at /home/sven

Relative Path Shortcuts

Shortcut Meaning
~ current user's home directory
. the current directory
.. the parent directory of the current directory
- for cd command, return to previous working directory
# start by navigating to a directory
$ cd /usr/local/src
# the command below puts us at /home/sven, same as cd ~
$ cd
# the command below puts us back at /usr/local/src
$ cd -
# the command below takes us to the parent directory, /usr/local
$ cd ..

touch [flags] <file>

  • Adjusts the timestamp of the specified file.
  • With no flags uses the current data and time.
  • If the file does not exist, touch creates it.
  • Note: on Unix systems, file extensions do not matter.
    • touch creates a blank plain-text (ASCII) file by default.

mkdir [flags] <dir1> <dir2> ... <dirN>

  • Can use relative or absolute paths.
    • a.k.a. you are not restricted to making directories in the current working directory.
  • Need to specify at least one directory name.
  • Can specify multiple, separated by spaces.
  • The -p flag is commonly used in scripts.
    • Makes all parent directories if they do not exist.
    • Convenient because if the directory exists, mkdir will not fail.

rm [flags] <filename>

  • Removes the file <filename>
  • Removes multiple files with "wildcards":
    • Remove every file in the current directory: rm *
    • Remove every .jpg in the current directory: rm *.jpg
  • Prompt before deletion: rm -i <filename>

rmdir [flags] <directory>

  • Removes an empty directory.
  • Throws an error if the directory is not empty.
  • You are encouraged to use this command: failing on non-empty can and will save you!

Note: to delete a directory and all of its subdirectories:

  • rm -r <directory>
  • -r tells rm to recurse.
    • e.g. rm -r /home/sven/oldstuff

cp [flags] <file> <destination>

  • Copies from one location to another.
  • To copy multiple files, use wildcards (such as *).
  • To copy a complete directory:
    • cp -r <src> <dest>

mv [flags] <source> <destination>

  • Moves a file or directory from one place to another.
  • Also used for renaming, just move from <oldname> to <newname>
    • e.g. mv badFolderName correctName
  • Unlike the cp command, mv automatically recurses for directories.

cat <filename>

  • Prints the contents of the file to the terminal window.
  • Can specify multiple files to be concatenated: cat <file1> <file2>
    • Prints file1 followed by file2.

more <filename>

  • Scrolls through one page at a time.
  • Program exits when end is reached.

less <filename>

  • Scrolls pages or lines (mouse wheel, space bar, and arrows).
  • Program does not exit when end is reached.

head -[numlines] <filename>

  • Prints the first numlines of the file.
  • e.g. head -19 someFile.txt prints the first 19 lines.

tail -[numlines] <filename>

  • Prints the last numlines of the file.
  • e.g. tail -19 someFile.txt prints the last 19 lines.
Note: if number of lines not specified, default is 10.

The Same and More Information

Working with a Windows Shell


Eric Lee spoke about setting up the terminal for Windows environments. For convenience, the slides have been inlined below.

Unix for Windows Users

A few of the popular options:

Cygwin/MinGW

The two most popular Unix-like shells for Windows. Note that this might change with the aforementioned Bash for Windows 10.

Advantages:

Disadvantages:

Bash for Windows 10

A “full” Linux Distribution (Ubuntu-based) running inside Windows

Advantages:

Disadvantages:

Virtual Machines (VMs)

VMs are the primary method of running another operating system inside an existing one. Popular vendors include VirtualBox, VMware. Note that “Containers” (which are slighly different) are also becoming popular. We’ll discuss them in the future.

Note that a VM requres a certain subset of your system resources (memory, disk space, processing power, etc). You choose the size of this subset when you first create a VM.

Advantages:

Disadvantages: