Command Line Tutorial

Now that we know a few Unix commands, let’s do some bioinformatics. Click here to download some sequence data:

Archive.zip

Find the file that was just downloaded – it should be in your Downloads folder, but if it is somewhere else, adjust the following commands accordingly.

Go to your terminal. You should still be pointed into the folder we made, called Unix. If not, use your Unix skills to point your terminal into the Unix folder.

Now, lets use a new command:

mv /Users/jgrant/Downloads/Archive.zip .

The mv command moves a file from one place to another. It takes two arguments, the file to be moved and the place you want to move it to. In this case, we are moving the Archive.zip we just downloaded. The second argument . is nickname for the folder we are currently pointed into (as we saw .. is a nickname for the next folder up). We could also have typed the full path for the folder:

mv /Users/jgrant/Downloads/Sequences.zip /Users/jgrant/Documents/Bioinformatics/Unix

but that is much more typing!

If you wanted to get a copy of the file and leave the original in the Downloads folder, you could have used cp (copy) instead of mv (move)

cp /Users/jgrant/Downloads/Archive.zip .

Sometimes this is safer, but you could also end up with multiple mostly unnecessary copies of files.

To see what is in your folder now, type

ls

ls, for list, lists all visible files in a directory. You should see the Archive.zip file is now in the Unix folder. The ls command seems pretty straightforward, but it actually has many options that make it more powerful and more useful. To learn more about any Unix command, you can use man (for manual). Type:

man ls

and look at the output. The manual entry starts with the basic usage, how to use it and then gives a long list of options. For example:

ls -a will show all files in the directory (even hidden files!) and
ls -l will show more information about the files in the directory, including file size, permissions, and date modified.

The man command can be used for any Unix command and is really useful if you forget how a command is used, or if you want to explore a command in more detail.

Next, we want to unzip the archive with this command

unzip Archive.zip

NOTE: unzip is not a unix command. It calls a program called unzip and runs it. It is possible that your computer wont have unzip installed, in which case you will get an error. If this happens, go ahead and use whatever program you usually use to decompress files.

Now look in your folder with ls. You should see many fasta files!

Now you know

  • cd
  • mkdir
  • mv
  • cp
  • ls
  • man
  • That’s a lot of Unix!

    But there’s more! Next…