Commands in Unix are also commonly referred to as 'Utilities'.
Commands are entered into the system through a terminal. Although there
are literally hundreds of utilities, there are only a handful that you will
need to be familiar with to work in the RS/GIS Teaching laboratory. Some
of the most commonly used utilities are described below ...
(NOTE: Unix commands are always lowercase.)
man : MANual.
Give this command along with the command you need more information on, and
a series of manual pages will appear that describe how to use the specified
utility. man <command>
Example:
man cd
will describe the use of the cd utility.
Hit spacebar for a page and return for a line to scroll
through manual entry.
Type q to get out
of the man page and back to your UNIX prompt.
cd : Change
Directory. Use cd to move to different directories on the network, similar
to DOS cd
When using cd , you can either give complete pathnames to
the directory you wish to move to or use
some of the following options...
cd .. moves
you 'up' one directory. For example, if you were in the directory
/home/gis77/homework : and issued the command cd .. you would now be in the
directory /home/gis77
cd ~ or cd by itself will
move you to your 'home' directory. So if you are user gis77 and are
in the directory /home/gis67/homework/feb/data: and issued the command cd ~
you would now be in the directory /home/gis77 (your
home directory).
Likewise, you can follow the ~ with the name of another user to go to his/her
home directory.
A command of cd ~gis24
That would put you in gis24 home directory ( /home/gis24/ )
pwd : Present Working Directory. Use pwd to see the name of the directory you are currently in.
ls
: LIST Use ls
to see the contents of your current directory, or give a pathname to specify
a directory. Similar to DOS dir
ls -l : List (Long option) Use ls -l to see the contents of your current directory,
file size in bytes, date of creation and
permissions of each file in the directory
ls -a : will list
all files in the directory (including "hidden" files)
rm : ReMove
files. After you issue the rm command, you will be prompted as to whether
you really want to delete the specified file(s).
With rm , you must specify a file or group of
files to remove. You can either give a file name or use the wildcard
'*'.
Examples:
rm myfile.txt will remove
only the file named myfile.txt (if it exists)
rm *.txt
will remove all files that end with .txt
rm -r : removes a directory, but still prompts you for each file
within that directory.
There is a command in UNIX that
will delete a directory without a prompt.
You can also do this from your file manager
You must be very careful with these kinds of commands.
BE SURE BE VERY SURE
cp
: Copy. Copies a specified file or files to a specified location
(directory). You must give both the file(s) to copy and the destination.
Using
the period '.' will put the file in the (current working directory)
specified directory and give the new file the same name. Using the period
without a path will put the file in you current directory.
Examples:
cp /home/gisdata/textfiles/hisfile.txt
/home/mydata/documents/myfile.txt
copies the text file called hisfile.txt and renames it myfile.txt
cp ~paxton/recipes/shoe.fly.pie . copies
the file to your directory & keeps
the same name
cp -r /home/fiction/public_html/images . copies
the images directory
to your directory and keeps the same name.
cp -r /home/fiction/public_html/images /home/nonfiction/photos
copies a directory to a new location with a new name.
mkdir : Make directory.
Makes a new directory. Example:
mkdir images will make a directory named images within
the your current
working directory.
mv : Move.
Will rename a file or directory or move a file to a new location.
Example:
mvimages photos Will rename the directory
images to photos.
mv tmcache.gif
/home/rsclass/data/tm30cache.gif Will move the
tmcache.gif file to the data directory and rename
it as tm30cache.gif.
more : Will display an ASCII
text file on the screen.
Example: more apples.txt
lpr : Prints a file to the default printer. Example: lpr apples.txt
lpq : Shows print jobs and # in the printer que.
lprm job# : Removes the print job # from the print que.
du -sk <directory> : Shows number of kilobytes stored in that directory
df . : Shows disk space in % and other information for the disk of the current working directory.
df -k : Shows disk space in kilobytes.
top : Shows what processes are running type q to exit top.
ln -s <d1> <d2> : Creates a symbolic link from the source <d1> to destination <d2>. A symbolic link is a pointer file. This pointer associates a filename with a directory on a harddrive. Example: ln -s /home/bbanner/temp temp this creates a file at the current working directory which when incorporated in a command will path to /home/bbanner/temp. If the user is located in the directory with the link they can type cd temp and the current working directory will be changed to /home/bbanner/temp.
chmod -options <file>: Changes the protection status of a file or directory. There are three levels of protection and each can be set separately. The levels correspond to a hierarchy of control with the highest being at the entire system level, the next being a group (students are in the student group) and finally the user level (such as user ttilton).
The window below shows an example of some of the utilities :
1) Move to the
following directory /home/rsclass/rsdatasets/RS4750data/TM
What letter do most of the files in this directory end with ?
How many files in this directory end with .img?
What command did you use to find out ?
2) Make sure you are in
the directory /home/rsclass/rsdatasets/RS4750data/TM
Try
to remove a file in this directory (don't be scared!).
What
happened ?
3) Type in the command cd ~
What
directory are you now in ?
4) Type
in the command man ls
Use the space bar
or Return key to scroll through the text.
What letters are used to indicate permissions for files ?
Hit q to quit the man page and get back to your unix prompt.
5)
TRY OTHER UNIX COMMANDS AND TAKE TIME TO
BECOME FAMILIAR WITH THE SYSTEM.
6) How do you open Netscape?
7) How do you open ArcView?
8) How do you open imagine?
Now add this information to your eg3850 webpage: Open webpage1 Part 1:
for more webpage instruction open next link. Includes links
setup for gisclass
These questions added by Nate Brunsell.
Rember to use the MANual.
9) What are the primary differences between the following
commands: cat, more,
and pg?
10) What is
the difference between ls and cat?