Linux  
Connecting to
 cslab100 Linux
Dedicated connection
  • DH222 computer lab

 

Remote connection
  • Need a program to telnet
    • telnet
    • tera term
    • Putty - Preferred!

     

Connection information

Host Name: cslab100.cs.edinboro.edu
Port: 22
Protocol: SSH


login to
Linux
userid
   <first init of first name><last 6 student id><first init of last name>

   name = Kendall Zimmer
   student id = @00123456
   birthday = February 4, 1991

    userid = k123456z

 
password

    <2 digit birth month><2 digit birth day><2 digit birth year>

    password = 020491

files
Create a file

    Use an editor on Linux

  • joe editor
  • vi
  • PICO

joe editor helpful items:
   joe filename - enter edit mode to edit filename
   ^h - help screen toggles on and off
   ^t - menu to disable indent for screen copy & paste
   ^kx - save & exit
 

Transfer a file

    Use an ftp program

 

List files

ls - lists the contents of the current working directory

Example:

zimmer@cslab100:~/mystuff$ ls
total 2
f1.txt
f2.txt
 

Remove, move and copy a file

rm  - remove a file
mv - move or rename a file
cp - copy a file into another file

Example:

zimmer@cslab100:~/mystuff$ rm f1.txt  

removes the f1.txt

zimmer@cslab100:~/mystuff$ mv f2.txt f3.txt

renames f2.txt to f3.txt (f2.txt is deleted)

zimmer@cslab100:~/mystuff$ cp f3.txt f4.txt  

copies the contents of f3.txt into f4.txt
if f4.txt existed it is overwritten
f3.txt is unchanged

 

path &
directories
What is a Path?
  • "Directions" ("route") to a file
    (or directory/folder)
  • Based on the Directory Tree

Root Directory

Top Level Directory - "Root of the tree"

Macintosh:
             Macintosh HD
                   (Or whatever you've named your hard disk)

Windows:
               c:

Unix, Linux, Mac OS X, Web Servers:
                /

 

Home directory
  • Where you start when you login
    (sometimes referred to as "login directory", too)

  • Directory name is same as userid

  • Place to create files and subdirectories

Typical home directory on CS server:

/home/students/userid
 

Present Working Directory
  • You are always "in a directory"
            "Present working directory"

  • Same as active folder on Mac or PC

  • Where current work is performed

  • You can move to any directory (or "Change your present working directory")

  • Home or login directory
    is your initial current working directory

pwd - present working directory

  • Displays present working directory

  • Easy to lose track of present directory

  • pwd tells you where you are

ls -l

  • Long (detailed) listing

  • Leftmost character for directories = "d"

  • Leftmost character for files = "-"

Example:

zimmer@cslab100:~/mystuff$ ls -l
total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/

 

Changing the permissions

chmod - change mode command is used to change the permissions or privileges on a file.

r - read permission
w - write permission
x - execute permission

u -user permissions - first set of three letters
                            (applies to owner of file)
g - group permissions - second set of three letter
        (applies to group that owner belongs to)
o - other permissions - third set of three letters
                             (applies to the world)

Directories and permissions:

r - Can do a listing of the contents
w - Can create a file or dir in this
       dir or delete something in the dir
x - Can move into or through this directory

Example:

zimmer@cslab100:~/mystuff$ chmod o+wx f3.txt
zimmer@cslab100:~/mystuff$ ls -l

total 4
-rw-r--rwx 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/

 

zimmer@cslab100:~/mystuff$ chmod u-rw f4.txt
zimmer@cslab100:~/mystuff$ ls -l

total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
----r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/

 

zimmer@cslab100:~/mystuff$ chmod ug+rw f4.txt
zimmer@cslab100:~/mystuff$ ls -l

total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
-rw-rw-r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwxr-xr-x 2 zimmer users 4096 Aug 27 2003 old/

 

zimmer@cslab100:~/mystuff$ chmod go-rwx old
zimmer@cslab100:~/mystuff$ ls -l

total 4
-rw-r--r-- 1 zimmer users 0 Aug 25 2003 f3.txt
----r--r-- 1 zimmer users 0 Aug 25 2003 f4.txt
drwx------ 2 zimmer users 4096 Aug 27 2003 old/

Moving Around

cd  - change directory

  • Allows user to move among directories
  • You must have access rights to the directory

Example:

zimmer@cslab100:~/mystuff$ cd  

go to home directory

zimmer@cslab100:~/mystuff$ cd / 

go to root directory

zimmer@cslab100:~/mystuff$ cd old/files/  

go to old/files/ directory

 

Creating Directories

mkdir - make directory command

  • Creates directories within your account
     

Example:

zimmer@cslab100:~/mystuff$ mkdir stuff  

Creates a directory named "stuff" in the current working directory

 

Deleting Directories

rmdir - remove directory command


Example:zimmer@cslab100:~/mystuff$ rmdir stuff  

Delete the directory "stuff" from the current working directory

 

Relative vs. Absolute References

Absolute reference

  • Path from the root directory to destination directory
  • Full pathname

    /home/students/a123456z/mystuff/file.txt
     

Relative reference

  • path from present working directory to destination directory


If present directory = /home/students/a123456z/
Relative path = mystuff/file.txt

 

Parent Directory
  • Every directory has only one parent directory
  • The shorthand for the parent directory is ".."

If present directory = /home/students/a123456z/mystuff
cd ..
Now present directory = /home/students/a123456z/

 

Linux &
the web
public_html Directory
  • The default home directory for all web pages
  • you must create this directory
  • there can/should be subdirectories within to organize your webpages

 

index.html file

The default webpage name used when none is specified

    URL = cslab100.cs.edinboro.edu/~k123456z

requests the webpage:
/home/students/k123456z/public_html/index.html

    URL = cslab100.cs.edinboro.edu/~k123456z/mystuff

requests the webpage:
/home/students/k123456z/public_html/mystuff/index.html

    URL = cslab100.cs.edinboro.edu/~k123456z/mystuff/f3.txt

requests the webpage:
/home/students/k123456z/public_html/mystuff/f3.txt