CTG - Basic Commands

Overview
  [Supercomputing]
  [Project Development]
  [Project Design]

Login Procedure
  [ssh (Putty) ]
  [Tutorial]

Unix
  [Basic Commands]
  [Utilities]
  [Pico]
  [Cygwin]

C++
  [Background]
  [Tutorial]
  [Advanced Syntax]

Java
  [Background]
  [Tutorial - Unix]
  [Tutorial - PC]
  [Advanced Syntax]

Graphics
  [gnuplot]
  [Tutorial]

Extras
  [Cygwin-X11]
  [E-mail]
  [ftp]
  [HTML]
  [Resources]

Supercomputing Challenge
  [Home Page]
  [Technical Guide]

This page will give you the basic commands needed to navigate the unix file structure and perform file manipulation tasks.

It may be valuable to reference the diagram below while learning about these commands.

Note: To learn more about any of these commands type "man command" (no quotes) at the mode prompt where "command" is replaced with any of the below commands. "man" stands for the on-line manual. Example:

mode:~>man ls

File commands

  • ls : This command will list the contents of the directory (folder) that you are currently in. Adding a "-F" (no quotes) to this command will indicate which listings correspond to directories (folders) by tacking a "/" to the end of its' name. Example:

    mode:~> ls
    
    data.txt mail public_html
    mode:~> ls -F
    data.txt mail/ public_html/
    mode:~>
  • mv : This command will rename the file and keep it in the current directory, or move the file into a different directory (folder). Example:

    mode:~> ls -F
    
    data.txt mail/ public_html/
    mode:~> mv data.txt backup.txt
    mode:~> ls -F
    backup.txt mail/ public_html/
    mode:~> mv backup.txt public_html
    mode:~> ls -F
    mail/ public_html/
    mode:~> cd public_html
    mode:~/public_html> ls
    abstract9900.shtml backup.txt index.html
    mode:~/public_html>
  • cp : This command will make a copy of a file. You must give the copy a new name if you make a copy in the same directory (folder). You may keep the name the same if you make a copy ina different directory . Example:

    mode:~> ls -F
    
    data.txt mail/ public_html/
    mode:~> cp data.txt new_data.txt
    mode:~> ls -F
    data.txt mail/ new_data.txt public_html/
    mode:~> cp data.txt public_html
    mode:~> ls -F
    data.txt mail/ new_data.txt public_html/
    mode:~> cd public_html
    mode:~/public_html> ls -F
    abstract9900.shtml data.txt index.html
    mode:~/public_html>
  • rm : This command will remove a file from your current directory (folder). Example:

    mode:~> ls -F
    
    data.txt mail/ new_data.txt public_html/
    mode:~> rm data.txt
    mode:~> ls -F
    mail/ new_data.txt public_html/
    mode:~> rm new_data.txt
    mode:~> ls -F
    mail/ public_html/
    mode:~>

Directory (Folder) Commands

  • pwd : This command will display your present working directory (folder) that you are currently in. Example:

    mode:~> pwd
    
    /scc/users/ch099abc
    mode:~>
  • mkdir : This command will make a directory (folder). Example:

    mode:~> ls -F
    
    data.txt mail/ public_html/
    mode:~> mkdir java_progs
    mode:~> ls -F
    data.txt java_progs/ mail/ public_html/
    mode:~>
  • rmdir : This command will remove a directory (folder). Note that the directory you wish to remove must be empty before you can delete it. Example:

    mode:~> ls -F
    
    data.txt java_progs/ mail/ public_html/
    mode:~> rmdir java_progs/
    mode:~> ls -F
    data.txt mail/ public_html/
    mode:~>
  • cd : This command will change directories (folders). Example:

    mode:~> ls -F
    
    data.txt mail/ public_html/
    mode:~> cd public_html
    mode:~/public_html> pwd
    /scc/users/ch099abc/public_html
    mode:~/public_html>

    You can "go up" a directory (folder) by using a "..". Example:

    mode:~/public_html> pwd
    
    /scc/users/ch099abc/public_html
    mode:~/public_html> cd ..
    mode:~> pwd
    /scc/users/ch099abc
    mode:~>

    Using the cd command without any arguments will take you from anywhere in the file structure to your home directory (folder). Example:

    mode:~/public_html> pwd
    
    /scc/users/ch099abc/public_html
    mode:~/public_html> cd
    mode:~> pwd
    /scc/users/ch099abc
    mode:~>

Note how the prompt changes when your are in different directories (folders). The prompt includes information which indicates which directory you are currently in. This allows you to be aware of your location without having to use the pwd command. If a "~" appears in this information, it denotes where you are located with respect to your home directory.

Not all Unix/Linux systems will be set up so that the prompt indicates which directory you are currently in. Mode has this feature ... Pi does not.


Supercomputing ChallengeQuestions? e-mail: consult