# Linux Command Line

Most of the things we do remotely do not require very much overhead. We typically just want to move some files around, change permissions, or maybe we want to start a program to run overnight. For all these functions we can use simple command line tools. Most people think of these as relics from the last century, but the fact is that they remain the fastest way to get what you want from a computer, even as they require almost no network bandwidth. Mathematicians need to know at least a little about this interface.

## Command Format

Most Linux commands have a simple format:

  commandname <switches> <file1> <file2>...

Obviously, the first thing we type is the name of the command we want to give. Sometimes that is all we need - all the things above that are in < > are optional. After the command name, there are an arbitrary number of arguments that give more information about what the command should do. The arguments are always separated by one or more spaces. The switches are arguments that can modify the behavior of a command.

## Some Commands

### ls

List the contents of a directory. Common options follow.
CommandEffect
ls -l
Long listing, with info about ownership, dates modified, size, and so on.
ls -a
List all files, including hidden files.
ls -lah
List all files in long format, with sizes given in human-readable format.
ls dir1
List all files in the directory dir1.

### cp

Copy one file to another with a different name.
CommandEffect
cp file1 file2
Copy file1 to another with name file2.
cp -i file1 file2
Copy file1 to file2, but if we are overwriting file2, ask first.
cp -p file1 file2
Copy file1 to file2, preserving the ownership, date stamps, and other properties.

### mv

Move one file to another with a different name. Note that when you move a file, ownership, dates, and other properties are automatically preserved.
CommandEffect
mv file1 file2
Move file1 to another with name file2.
mv -i file1 file2
Move file1 to file2, but if we are overwriting file2, ask first.

### cd

Change directory.
CommandEffect
cd dir1
Change to directory dir1.
cd ..
Change to the parent directory of the current directory.
cd ../dir2
Change to a directory called dir2 that is in the parent directory.

### less

Show the contents of a file, one page at a time.
CommandEffect
less file1
Show the content of the file file1. You can use page-up and page-down keys. Hit 'q' to quit.

### pwd

Print working directory. Just find out what the current directory is.

### chmod

Change mode of a file or directory. This is how we set the permission structure. Details are on the permissions page.

## Networking Commands

### ping

Send an echo request packet to another computer, hoping to receive an echo reply if the computer is up.
CommandEffect
ping ip.address
ping internet.name
ping the computer identified by the name internet.name

### arp

Find out about local network connections on the current computer.
CommandEffect
arp -a
Show all computers whose MAC addresses this computer has cached.

### dig

Find out the IP address of a computer. This comes with extra information about the DNS authority and such.
CommandEffect
dig internet.name
Get the IP address of the machine identified by internet.name.
dig -x ip.address
Get the internet name of the machine identified by the IP address ip.address.

### nslookup

This is an older way to find out the IP address of a computer.
CommandEffect
nslookup internet.name
Get the IP address of the machine identified by internet.name.

### netstat

Find out what network connections are maintained by your computer.

Assignment C is posted.

The test solution is available.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us