PmWiki

pmwiki.org

edit SideBar

UsingLinux

This is a general overview for someone who is not familiar with command-line, terminal systems. For information on connecting to a Linux server, please see CycleServers.

When you first login, you will see the following prompt:

[USERNAME@cycle1 ~]$

The ~ indicates you are currently in the home directory. Every student is given their own home directory when they are given a Cycle account. You can see the full path by typing the "print working directory" command:

pwd

The output will be of the form:

@@/home/hoover/u3/USERNAME
A quick note on a difference between Linux and Windows: Windows filesystems are organized around physical drives, for example the C:\ drive, which normally corresponds to the primary hard drive. All files located on the C drive are said to have "C:" as the "root" of the drive, and all files on the D drive (which might be a CD-ROM drive, or another hard drive) have "D:" as a "root". However, on Linux, there is a single filesystem that spans all drives. Instead of using drive names, and having multiple roots, there is one root in linux: "/" (Another note: In linux, the character seperating folders is "/". In windows, it is "\". Yes, it is obnoxious).

Listing and manipulating files

To list files in Linux:

ls

The Cycle servers are configured to automatically use the "--color" option, so folders, executables and links will all have different colors.

To make a directory:

mkdir dirName

This will create a directory called "dirName". Linux is case sensitive (Unlike Windows), and on top of that dislikes spaces in folder names.

To change the directory you are currently in:

cd dirName

This will change the directory name in the command prompt.

To delete a directory:

rmdir dirName

This will fail if the directory is not empty.

To delete a file:

rm fileName

Please be careful - there is no way to undo a delete.

You can use the wildcard operator here - "*". For example:
rm *.c will delete all files ending in ".c".
rm cs* will remove all files starting with "cs".
rm cs*.c will delete all files starting with cs and ending with ".c"
rm -r dirName will remove all files and folders contained within the directory dirName.

To copy a file:

cp fileName location

To move a file:

mv file location

Programming in Linux

There are two ways to program in a Linux, command-line, environment: vim and emacs?. Choose one of these command-line text editing programs, and realize that you have just taken sides in a holy war that began before you were born.

Linux references

Linux has a manual built in. To look up a certain command, use "man". For example:

man man

This will display the man page for the man command. This works for most C library functions as well. You can also start a google search with "man" and you will be linked to several online man pages.

Page last modified on February 12, 2009, at 04:23 PM