logo © 1996 Phil Waclawski
Felitaur Site
Offerings
About Me
Crafts
Services
ftp files
Help Files
What's New?
Home Page
Other Links
Anatomy &
Physiology
Arthropods
Biology
Computers
Ferrets
Fun Links
Internet
Linux
S.C.A.
Win 95/NT
   
Basic UNIX Commands
Geting Started Basic Commands Other Stuff
How do I enter commands?
Where am I? (pwd)
How do I get there? (cd)
What files are there? (ls)
How to get help (man)
Moving files (mv)
Renaming files (mv)
Copying files (cp)
Making Directories (mkdir)
Deleting Files(rm)
Setting Permissions(chmod)
text editing (pico)
email (pine)
WWW (lynx)
FTP (ftp)
IRC (irc)
UNIXhelp Pages
UNIX is a Four Letter Word (both excellent sites for a lot of UNIX information)
Getting Started
Entering Commands
After you have "logged in" (see telnet or Cheat Sheetfor more information), you will see what is known as a "command prompt". Which prompts you to enter commands. ;) This will look a bit different from system to system, but usually you see something like username@hostname directory$ On our system at school, it is bash-2.03$ This is where you can enter commands. You can enter quick commands, such as ls or pwd or you can enter commands that start other programs, such as lynx or pine. When in these programs, you should note that the COMMAND PROMPT is MISSING! This means, do not try to use commands suchs as ls or cd as the program has taken over. You can not enter command prompt commands UNTIL you have exited the program you are in at the time.

Also note, everything in UNIX is "CASE Senstive", which means pine is a command, but Pine, PINE etc. are NOT.

Where am I? (pwd)
I call this the "Where am I?" command. pwd stands for "present working directory". It gives you your present path. When working on your web pages, either "public_html" (most systems) or "www" (MCC's system) should be part of your path. If not sure where you are, type "pwd" at the command prompt (bash-2.03$ or whatever yours is) to find out.

How do I get there? (cd)
cd is an important command, it stands for "change directory". If you type "cd www" when you first log on to mcunix, you change into your www subdirectory. Here are some other examples...
  • cd .. (move UP one level)
  • cd (go back to my home directory)
  • cd www/pictures (move down two levels to pictures)

What files are there? (ls)
Using ls -F you not only get a list of all the files in your pwd (present working directory) but it labels them as to type. If NOTHING comes after the name, it is a plain text file. If a "/" comes after the name, it is a directory. If you see a "*" then it is a program or script.

Getting help (man)
While it may be overkill for most folks who just want to type some web pages using telnet on a UNIX server, the "man" command is a wealth of information. Just type "man commandname" where commandname is the name of the command you want to learn about. Such as "man ls" to find out more about the ls command. Realize you may have to scroll through a lot of technospeak till you find the option you want. Still, very useful command.

Basic Commands
Moving and Renaming files (mv)
The mv command serves double purpose, both to move files, and to rename them.

mv filename.html www

Takes a file (filename.html) and moves it into the www directory

mv oldname.html newname.html

will take a file called oldname.html and rename it to newname.html

Copying Files (cp)
cp is almost identical to mv EXCEPT that the original file is unchanged and a new file with the same contents is created
cp template.html ferrets.html
This puts the contents of template.html into a new file called ferrets.html

Deleting Files (rm)
A potentially deadly command. Normally rm does NOT warn you, or ask you if you really want to wipe out all of your files. It assumes you know what you are doing and just does it. So be careful.

rm filename3.txt wipes out the file "filename3.txt" there is NO undelete.

You can use wildcards with rm but they are very dangerous
rm *.html.bak is very different from rm *  .html.bak

That extra space between the * and the period acts this way
rm * (delete EVERYTING in the pwd (present working directory) and THEN try to delete a file called .html.bak whoops.

A safer option is
rm -i *.html.bak

But with this you will have to hit "y" for each file you want to delete

Setting Permissions (chmod)
As UNIX/Linux is multi-user, you need to have someway to control who can do what with a file/program/directory. If you do ls -l in a directory, you will often see something like:

drwxr-x--x    2 muck     webdevel     4096 Mar 24  2000 projects
-rw-rw-rw-    1 muck     muck          182 Jan  9  2000 readme.txt
-rwxrwxr-x    1 muck     muck         4321 May 15 18:26 realestate.pl

The part at the beginning of each line lays out the permissions:
drwxr-x--x says that it is a directory, that the user (owner) has rwx permissions, the group has read and execute permissions and all the other folks have only execute permissons.

The first column of names is the owner (in this case muck) and the second column is the group name (webdevel).

To set permisions you can do several things:

  • use ugo (user group other) for example
    chmod ug+x file.pl (adds execute to user and group)
    chmod go-r file.pl (removes read from group and other)
    chmod a+x file.pl (adds execute to all (ugo))
    chmod go=rx file.pl(sets permissions to r and x for group and other, wipes out w if it exists)
  • You can also use the number system, remember that
    r is 4
    w is 2
    x is 1
    so, chmod 751 file.pl sets the following rwxr-x--x for permissions
Remember, for a file to run as a script or a program, it MUST be set x. The file endings in windows (.com, .exe .bat) have no meaning in the unix/linux world.