Unix - Basic Unix commands
Managing files
All the files on your H-drive are stored on a UNIX fileserver. You can access them through Windows or a UNIX interface.
Unix computers are controlled by text commands that allow them to be used remotely. There are a few simple commands that can be used to manage your files. Your H-drive is actually in a directory (folder) named with your username. You can find out your home directory by typing pwd after you first log in (this can be abbreviated as ~ in file paths to save you typing it out).
Log into Unix (Start → Programs → Unix Applications → amos, mary, or midge) and at the $ prompt type ls to list your files. After each command you must hit return.
Useful commands
(you can get away with ls, cd, cp, rm)
- ls -ltr - list files in long time reversed order, so that the most recent are at the bottom
- pwd - print working directory (see where you are)
- rm - remove/delete a file (so use with care), eg. rm essay.doc
- mkdir - make a new directory in the current one e.g. mkdir myessays
- rmdir - remove directory (directory must be empty to use this command)
- cd - change directory, eg. cd myessays (cd .. will take you back again)
- cp - copy files eg. cp essay.doc myessays/ will create another copy of essay.doc in your myessays folder
- mv - move (same as copy but removes the original file, can also be used to rename a file)
- pico - a simple text editor (as used in Pine) e.g. pico textfile.txt. If you use a filename that does not exist, it will allow you to create a new file
- less - scrolls the contents of a file up the screen e.g. less textfile.txt
- pine - email program
Example
If you have the directory structure shown with two directories called dos and one you have created called myessays. There are two files in the dos directory and you have just logged onto midge (a unix machine) so you are in the folder abc20 (/u/d/abc20 in full, just type cd to return to this dir) you could move the two files into the myessays folder like the following example (not the fastest way but it illustrates lots of commands) remember to not type out midge $. The typed commands are in bold;
midge $ ls
dos myessays
midge $ cd dos
midge $ pwd
dos
midge $ ls
essay1.doc essay2.doc
midge $ cp essay1.doc ../myessays (the two dots mean back a directory)
midge $ rm essay1.doc (this deletes the old file)
midge $ ls
essay2.doc
midge $ cd ../myessays or type cd ~/myessays
midge $ ls
essay1.doc
midge $ mv ../dos/essay2.doc . (dot stands for current dir, using mv means no need to delete)
midge $ ls
essay1.doc essay2.doc
or you could have just typed:
midge $ mv dos/ess*.doc myessays
where the * is a wildcard that counts for anything and so will move both files.
Note on names:
Names and directories are case sensitive and space characters are used to separate commands and filenames so you must put double quotes around any names with spaces in.
Further introductory information is available here, with other sources of help on the Unix help page.