This site will look much better in a browser that supports web standards, but should be accessible to any browser or Internet device.

>> To Part Two >>

Week Three

Before We Begin: PuTTY Update

PuTTY about dialog  screenshotBefore we get started here, I realized thanks to a conversation on the course message board that my version of PuTTY was a bit out of date. I had version 0.53b. The current version is 0.54. I offer proof that I have upgraded here. lol

If anyone has not gone and grabbed the new version yet, I can promise the download is small and install is totally painless.  All my settings were saved and all seems right in the Unix/PuTTY world...or at least the section of it over here.

The URI for the PuTTY website is:
http://www.chiark.greenend.org.uk/~sgtatham/putty/

Part 1: Files & Directories

<< mkdir >> command

Creating test directories and checking to make sure they are in the correct spots with:
mkdir newdirectoryname

<< touch >> command

Command used to create an empty file. [Note:  This file has not yet had its type or extension defined.]  Unix does not require file extensions. File types are determined by name and first 4 bytes.  Practically all files in UNIX are ASCII text files (with the exception of binary files such as .exe).

touch newfilename

Creating new files and directories using << mkdir >> and << touch >>:

-bash-2.05b$ mkdir public_html/unix-rookie
-bash-2.05b$ mkdir public_html/unix-monkey
-bash-2.05b$ cd public_html/unix-rookie
-bash-2.05b$ pwd
/home/myusrname/public_html/unix-rookie
-bash-2.05b$ touch rookie1
-bash-2.05b$ touch rookie2
-bash-2.05b$ cd ..
-bash-2.05b$ pwd
/home/myusrname/public_html
-bash-2.05b$ cd unix-monkey
-bash-2.05b$ pwd
/home/myusrname/public_html/unix-monkey
-bash-2.05b$ touch monkey1
-bash-2.05b$ touch monkey2
-bash-2.05b$ mkdir moremonkey
-bash-2.05b$ cd ../unix-rookie
-bash-2.05b$ pwd
/home/myusrname/public_html/unix-rookie
-bash-2.05b$ mkdir morerookie

Check to make sure everything is where you expected it to be:

-bash-2.05b$ pwd
/home/myusrname/public_html/unix-rookie
-bash-2.05b$ ls -l
total 4
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 00:32 morerookie
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie2
-bash-2.05b$ cd ../unix-monkey
-bash-2.05b$ ls -l
total 4
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:30 monkey1
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:31 monkey2
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 00:31 moremonkey

You can decide the name convention that is best for you in unix.  Examples of potential names for the same file.

monkey1
monkey1.txt
monkey1.stuff.txt
sample.monkey1.stuff

Hiding Files

You can hide files by placing a dot in front of them. [example: change mypage.html to .mypage.html] However, since the leading dot indicates a system or configuration file, this can cause confusion. Better to give the file a temporary extenison such as:
monkey1.html.temp

Files can be organized systematically while in the working/hidden stage like so:

monkey1.html.temp
monkey1.dates.html.temp
monkey1.stuff.html.temp

<< mv >> command

Move or Rename a File

This commands doubles as move and/or rename.

To rename:
mv currentfilename newfilename

mv -i [interactive flag] alerts you if you are about to overwrite a file that already exists.

Changing file names with << mv >>:

-bash-2.05b$ mv monkey1 u-monkey1
-bash-2.05b$ mv monkey2 u-monkey2
-bash-2.05b$ ls -l
total 4
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 00:31 moremonkey
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:30 u-monkey1
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:31 u-monkey2
-bash-2.05b$ mv -i u-monkey2 u-monkey1
mv: overwrite `u-monkey1'? n
-bash-2.05b$

<< cp >> command

Copy File or Directory

[files]
An option to copy files on the server since you can't do that via ftp programs.
The <<cp>> command will accept:

[directories - copying]
Using wildcard, the command to copy entire directory would be:
cp directory/* copydirectory
Note: Sub-directories will not be processed this way, each would have to be done individually.

[move directories]
A more efficient alternative might be:
Use the -r - recursive flag. With this method, all files and sub-directories will be copied.
Note:  <<cp -r>> is generally preferred to <<mv>> when moving directories, especially with sub-directories involved.

<< rm >> & << rmdir >> commands

Once you have moved the directory and are satisfied that you have a full copy, you may want to delete the directory in the old location.  For this you would use <<rm>>

First you need to remove all files inside the directory.  Navigate to the directory, then use:
rm *

After that is done, navigate back up one level using ..directoryname and use:
rmdir directorytodeletename

Guess it's time for trying to create some examples of these commands in use. 

Copying files with << cp >>:

-bash-2.05b$ mkdir unix-tests
  -bash-2.05b$ cd public_html/unix-rookie
-bash-2.05b$ pwd
/home/myusrname/public_html/unix-rookie
-bash-2.05b$ ls -l
total 4
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 00:32 morerookie
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie2
-bash-2.05b$ cp rookie1 u-rookie1
-bash-2.05b$ cp rookie2 u-rookie2
-bash-2.05b$ ls -l
total 4
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 00:32 morerookie
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 00:29 rookie2
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:42 u-rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:42 u-rookie2
-bash-2.05b$

Moving Directories [including sub-directories] with << cp -r >> & copying file to sub-directory:

-bash-2.05b$ cd ..
-bash-2.05b$ pwd
/home/myusrname/public_html
-bash-2.05b$ cp -r unix-rookie/* unix-tests
-bash-2.05b$ cp -r unix-monkey/* unix-tests
-bash-2.05b$ cd unix-tests
-bash-2.05b$ ls -l
total 8
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 01:55 moremonkey
drwxr-xr-x    2 myusrname   myusrname       4096 May 30 01:54 morerookie
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:54 rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:54 rookie2
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:55 u-monkey1
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:55 u-monkey2
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:54 u-rookie1
-rw-r--r--    1 myusrname   myusrname          0 May 30 01:54 u-rookie2
-bash-2.05b$ cp rookie1 morerookie/rookie1
-bash-2.05b$ cp rookie2 morerookie/rookie2
-bash-2.05b$ cd morerookie
-bash-2.05b$ ls
rookie1  rookie2

Deleting files with << rm >> & << rm * >> and deleting directories with << rmdir >>:

-bash-2.05b$ cd ..
-bash-2.05b$ pwd
/home/myusrname/public_html/unix-tests
-bash-2.05b$ rm rookie1
-bash-2.05b$ rm rookie2
-bash-2.05b$ ls
moremonkey  morerookie  u-monkey1  u-monkey2  u-rookie1  u-rookie2
-bash-2.05b$ cd ../unix-rookie
/home/myusrname/public_html/unix-rookie
-bash-2.05b$ rm *
rm: cannot remove `morerookie': Is a directory
-bash-2.05b$ ls
morerookie
-bash-2.05b$ rmdir morerookie
-bash-2.05b$ ls
-bash-2.05b$ cd ..
-bash-2.05b$ pwd
/home/myusrname/public_html
-bash-2.05b$ rmdir unix-rookie
-bash-2.05b$ cd unix-monkey
-bash-2.05b$ rm *
rm: cannot remove `moremonkey': Is a directory
-bash-2.05b$ rmdir moremonkey
-bash-2.05b$ ls
-bash-2.05b$ cd ..
-bash-2.05b$ rmdir unix-monkey
[ran ls command on public_html here.  
will not print out long list, but unix-rookie and unix-monkey are now gone.  
content is in unix-tests from prior copying.]

>> To Part Two >>