Week 2: Using Basic UNIX Commands

Here I describe a set of UNIX commands that might be useful during the semester with a simple suggested scenario. I hope this page serves as a future reference: you can come back to this page when you cannot remember what the name of the command is. If you have certain operation you want to do, but cannot really find it, please come to me in Office Hours or beginning/end of the class, then we can search the web together and update this page.

  • PLEASE PRACTICE THESE COMMANDS BY FOLLOWING THE INSTRUCTIONS GIVEN IN THIS PAGE IF YOU'RE NOT FAMILIAR WITH THESE! If you don't, you'll find yourself wasting a lot of time because you can't remember certain commands.
  • If you think certain operation takes too much effort, google about it or consult with me to find a better way of attacking the problem. Seriously, you should be lazy to be a good computer engineer.

Why Use Command-Line instead of Fancy GUI?

  1. Sometimes, there is no other choice
  2. Faster
  3. More Accurate
  4. Looks like an expert

As you become more and more familiar with UNIX commands and know how to combine them, you can dramatically increase your efficiency of manipulating data/documents.

Navigating the Directory System

You're familiar with the tree-like directory system in Windows. You have almost the same thing in UNIX.

file system

Here, the 'Adobe' directory is placed under 'Program Files', and it's under 'C:'. Collectively, it's written as 'C:\Program Files\Adobe'. Let's find out where you are.

'pwd' command

The 'pwd' command displays where you are.

It says that I'm on 'yun3' under 'u4' under 'skew' under 'home'. Of course you'll be on the different directory.

'man' command

This is the most important command of this page. Whenever you're not sure how to use a certain command, type 'man [command]'. For example, type 'man pwd' and you'll see:

Press 'Space' to move forward, and 'b' to move backward. To quit, type 'q'.

'cd' command

Now you may want to move to the higher level. Type 'cd ..' Use 'pwd' to check out you're on the higher level. Use 'cd ..' again to go to the higher level.

Let's go back to your home directory. To go down, you have to specify the destination (because you're moving on tree!). Type 'cd 'u4'' to go to 'u4' directory. Take one step lower.

So far, we've been navigating in the relative fashion. That is, you specified your destination relative to your current position. You can also move with the absolute address.

'mkdir' command

You should use directories to organize your files neatly. You can make a new directory with 'mkdir' command. At the beginning of every semester, I create a new directory for that. Let's create one and move to it.

'ls' command

This should be the command you'll most frequently use! This command displays the list of files under this directory.

Eww… Gross? Please don't be a person like me. Keep your home directory clean.

'rmdir' command

You may also want to delete a directory (e.g. you think the given name is too lame). Here's how to do so:

'wget' command

In many times during the course, you'll have to download materials from web (e.g., data file for analysis, or supplementary source codes). Please download the following file from the web:

http://www.stat.purdue.edu/~yun3/week2.txt

'less' command

If you want to browse inside of the file, there are a lot of ways to do so, but here I pick 'less' command. Let's try it! Type 'less week2.txt'. (Tip: it's always useful to make use of 'TAB' key)

Press 'Space' to go to the next page. Press 'b' to go to the previous. You can also use cursor keys to navigate. Press 'h' to get the help menu. Press 'q' to quit. Press 'g' to go to the top. Press 'G' to go to the bottom.

Press '/' to search for certain keywords. Press 'n' to go to the next matched string. Press 'N' to go the previous matched string.

'rm' command

 
Back to top
courses/fall2010/598g/lab/week2.txt · Last modified: 2011/01/19 16:36 by vishy
 
 
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0