Versions Compared

Key

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

Unix Command Cheat Sheet

Basic linux commands you need to know like breathing air

  • ls - list the contents of the current directory
  • pwd - print the present working directory  - tells you where you are currently. The format is something like /home/myID - just like on most computer systems, this represents leaves on the tree of the file system structure, also called a "path".
  • cd <whereto> - change the present working directory to <whereto>  You will need to provide a path like /work/myID to change to that directory.
    • Some special <wheretos>.. (period, period) means "up one level".   . means current directory. ~ (tilde) means "my home directory". ~myfriend (tilde "myfriend) means "myfriend's home directory".
  • nano - The text editor we'll be using
  • df shows you the top level of the directory structure of the system you're working on, along with how much disk space is available
  • head <file> and tail <file> shows you the top or bottom 10 lines of a file <file>
  • more <file> and less <file> both display the contents of <file> in nice ways. Read the bit above about man to figure out how to navigate and search when using less
  • file <file> tells you what kind of file <file> is.
  • cat <file> outputs all the contents of <file> - CAUTION - only use on small files.
  • rm <file> deletes a file. This is permanent - not a "trash can" deletion.
  • cp <source> <destination> copies the file source to the location and/or file name destination}. Using . (period) means "here, with the same name". * cp -r <dirname> <destination> will recursively copy the directory dirname and all its contents to the directory destination.
  • scp <user>@<host>:<source> <destination> works just like cp but copies source from the user user's directory on remote machine host to the local file destination
  • mkdir <dirname> and rmdir <dirname> make and remove the directory "dirname". This only removes empty directories - "rm -r <dirname>" will remove everything.
  • wget <url> fetches a file with a valid URL. It's not that common but we'll use wget to pull data from one of TACC's web-based storage devices.
  • man <unixcommand> displays the manual page for a unix command.
  • >  is used to redirect STDOUT and STDERR to files.

 

Wildcards and special file names

 

The shell has shorthand to refer to groups of files by allowing wildcards in file names. * (asterisk) is the most common; it is a wildcard meaning "any length of any characters". Other useful ones are []to allow for any character in the set <characters>> 

...

  1. . (single period) means "this directory".
  2. .. (two periods) means "directory above current." So ls -l .. means "list contents of the parent directory."
  3.  ~ (tilde) means "my home directory".


The concept of PATH

On a unix command line, you can only access files that are in your current working directory. If you are in /home/dhivya/dinner and you issue the command: 

...

Always remember where you are, on a Unix enviornment!

 

So many options...

When running scripts and software tools, all the inputs you provide to it are called arguments or parameters or options.  Each tool/script can be a little different in how it takes its arguments. But typically, they follow a structure.

...

  • command -h
  • command --h
  • command -help
  • command

 

.bash_profile, .profile files

A startup script that gets executed every time a session is started interactively. You can put any command in that file that you could type at the command prompt. Put commands here to set up your particular environment, and to customize things to your preferences (such as paths, aliases, modules to load).

 

If you haven't already, add this to your stampede profile for the class.

 

Warning
iconfalse
titleSet up .profile for class

 nano ~/.profile

 

# include common settings for the NGS course

 . /corral-repl/utexas/BioITeam/bin/profile_ngs_course.bash

#ctrl+z to exit, Y to save

 

BACK TO THE COURSE OUTLINE

...