Continued from ..

Here I should explain a little about the part after the colon and the directories. In DOS you will see the drive letter and the directory you are in: "c:\windows\>". Linux doesn't use the drive letter. Drive letters are named differently, and beyond the scope of this article. Also, Linux use the forward slash "/" for navigating the directories, unlike DOS that uses the back slash "\". You see: "nix:user$", the directory tree that linux sees is: /home/user. In DOS it would be: C:\home\user.

I assume at this point you have already uploaded some files to your web host. If not, go ahead and do so. We need them for the following examples.

All commands on linux, just like in DOS, come with some form of help built in. In DOS you would type in "dir /?". With linux you can use the man pages, "man <command>". Or, "<command> --help" (notice the space) and on some machines, "<command> info".

The first command we will work with is "ls". That is the same as "dir /w" in DOS. It lists the contents of the directory in columns. Everything will be in alphabetical order with the files and directories with capital letters first. My web host puts a "/" on the directories, this is not a default, your web host may not do that. Or may choose a different way of marking the directories for you.

If you are like most webmasters you will have a directory called "images". If you haven't uploaded any files yet, lets go ahead and make the directory. Type "mkdir images". That is the same as the DOS command.

To change to the directory type "cd images". Exactly the same as in DOS. Notice the cursor, it will look like: "nix:images$". Remember, in DOS it would look like: "C:\home\user\images>". Like DOS, you can "jump" to different directories by typing in the full path. This can throw you off a little at first. Remember, the directory tree is different than what you see. The full path in linux includes "/home/user". So the full path to your image directory is "/home/user/images". If you want to "jump" to that directory you would type, "cd /home/user/images". Its possible that your web host has a different way of handling where your default directory and web pages are at. If the above command doesn't work for you, call your web host for the full directory path.

Now, lets go back to your home directory, type "cd .." (notice the space). In DOS the command is "cd.." (no space).

We made a directory, now lets make a simple text file. For this you will need a text program. Commonly known as a text editor. In DOS you would use is "edit". The linux equivalent of edit is a program called "pico". There are others but I use this one because it was the first one I ever tried and I am used to it. In my version of Unix I use "vi".

Linux doesn't use the extension .exe like DOS. If fact, it isn't required to use the restriction of three character extensions, like ".htaccess", or use the dot, "mydoc" is permissible. Mostly linux uses the part after the dot for description of the file, not associations like Windows. Windows uses .ini, linux uses .conf.

Pico allows you to name the file while you opening the program. Or you can name it later. Lets name it later in this example, type pico. The text editor will open and fill the screen. Type in something simple, "This is my first time using telnet.". The cursor will be just to the right of the word "telnet". Now take your mouse and place the cursor anywhere in the word "first". Notice it didn't work. That's because the Telnet server cannot interrupt the mouse movement on your computer, instead you have to use your arrow keys to move the cursor around. You can play with the commands for pico listed at the bottom of the screen later. For now, press control+x and close pico. At the bottom of your screen you are prompted with the question, "do you want to save changes in buffer?", the answer is yes. Then you will get a prompt to name the file. Name it "mydoc" with no extension, and press enter. You should be at the prompt.

"Tourists are terrorists with cameras. Terrorists are tourists
with guns."
Anon.

Now lets pretend that you have a html page that needs one little correction. Up until now you opened your html editor, or notepad, made the change then saved the file, then opened your FTP program, and made the upload. Whew, that is a lot of steps. Instead, you can "Telnet in", type "pico mydoc" and make the change.

So lets do that. Type "pico mydoc". Make any change, press control+x, answer yes to save the buffer. But now, notice the question asks if you want to save to "mydoc". You can do two things here, save it as "mydoc" or save it as a different file name, i.e. "mydoc2". If you save it as a different file name, just like DOS, the original file will remain without the changes you made.

Lets pretend that you have the file "mydoc" in the wrong directory and want to move it. There are two commands to do this with. The first is "cp", just like the DOS "copy" command. Type "cp mydoc /home/ user/images". That will copy the file to the images directory and leave a copy of the file in the original location.

Or, you can use the "mv" command. Short for "move". This does the same thing as "cp" but you can rename the file during the move. Type "mv mydoc /home/user/ images/mydoc3".

Pretty simple so far isn't it. There are some more basic commands though. Lets go to the image directory and work with a with a couple of them. Type "cd images". Type "ls". You should see two files, mydoc and mydoc3. Lets delete mydoc. The DOS command would be "del mydoc", but in linux its "rm". Type "rm mydoc". If you want to check that is really gone, type "ls".

There may come a time when you want to rename a file. In DOS you use "ren <old filename newfilename>". In the linux you use a command you already know, the "mv" command. Thats right, you guessed it, just "mv" the file to the same directory, just don't use the path, Type "mv mydoc3 mydoc".

Now lets erase everything you see on the screen. The DOS command is "cls", the linux command is "clear". Type clear, and poof, everything is gone except the prompt. Is this cool or what. Like DOS, if you want to see the time and date, type "date".

We have typed enough commands now that I want to show you something else that is cool and will save you a lot of typing. Lets say you want jump to a different directory, so you typed in something like "cd /home/user/amateur
/sponsor/fpa1/nograhic". Then, you get and error that says "no such directory". Instead of typing the whole line over again, press your up arrow key. Linux will show you all the previous commands lines you have typed in. The DOS equivalent is "doskey", but its a program (utility) you have to type in at the dos prompt at the very beginning of your session or have it load at boot time. When you press the up arrow, re-read the line, you will find out that you misspelled, you typed in "nograhic" and it should have been "nographic". Just make the correction and press enter. Isn't that cool!

As you can see, the path names can get very long, and you can only see the current directory in the prompt. So, if you get confused, or lost, and can't remember where you are at exactly type "pwd". In DOS you would type "chdir".

Ok, now you get to play. Clean up all the files called mydoc, that is delete them. When your through, end your telnet session. Type "exit", just like in DOS. That will disconnect you from the web host. Btw, you don't have to be in any certain directory, you can do it anytime. The next time you "telnet in", you will go straight to the default directory.

If you want more help with commands, remember the "man <command>". Also do a search on Unix or Linux.


©2001 VNWR. All rights reserved.