HTSEQ Logo
Your session is inactive. Please login.
Working with files in UNIX


Contents


Description

This page explains some basic UNIX commands. While using UNIX, you can get help by typing man -k keyword at the prompt. This lists the commands relevant to the keyword. There are many good UNIX books out there, and many people in the lab are pretty UNIX-savy, so ask around if you have questions. There is also the following website for further information.

Definitions

A UNIX pathname specifies where a file is located on the unix system. This is analogous to a folder on a Mac or PC. An example of a UNIX path would be "/home/users/sammy", the home directory for the user "sammy".

Files (such as .dat, .gpr, .sag, .tif, etc. files) are located in directories. If sammy had a .dat file called 123.dat in his home directory, it could be refered to in Unix by its full path, "/home/users/sammy/123.dat". The full path is basically an unambiguous address for a file or directory.

Directories

  • cd pathname changes your current directory to the pathname you specified.
  • ls lists the files in your current directory.
  • dir lists the files in your current directory. It also provides the username of the person who last updated the file and when it was last updated. To get back to the UNIX prompt, hit 'q.'

Moving Files

  • cp filename new pathname copies a file from your current directory to the directory specified by the pathname. A copy of the file will remain in your current directory. cp will overwrite any file in the same name in the directory to which you are copying, so be sure that this is not the situation before you use cp. Once a file is overwritten, it cannot be recovered.

Deleting Files

  • rm filename removes the specified file from your current directory. Once a file has been removed, that copy can no longer be accessed. Make sure you no longer need this file or have copied it elsewhere before using the rm command. Unix will ask you to confirm this command before completing it.

Compressing Files

  • gzip filename compresses a file. It will take up less space, but it cannot be read in this format. After gzip, files carry the suffix ".gz"
  • gunzip filename uncompresses any file with a ".gz" suffix and removes the suffix.

Viewing Files

  • more filename allows you to view the contents of a file in your current directory. To view the next screen, hit the space bar. To get back to the UNIX prompt, hit 'q.'

Printing Files

  • lpr filename prints the specified file.