|
What is a Command Line? SSH and Telnet Commands - A command line is a method of sending commands to your computer, put in text form. When you work on a PC, you are still sending commands to your computer, but through your mouse, not text. MS-DOS is an example of a very simple command line, and it looks like this. MS-DOS Prompt it use Telnet Commands.If you have Windows, you will probably be very familiar with it, even though the more recent operating systems are steering away from it. If you have Linux or Unix, you might find you use the command line a lot, and you will be grateful to know that the commands are the same through SSH and Telnet as they are in Linux. This is because most servers run Linux. I am assuming your server is a Linux server, and you are able to SSH or Telnet in. With that in mind, lets get to work. SSH and Telnet Commands SSH and Telnet is another method to edit the files on your server. The way this is different though is it is more secure, and you work through a command line, not a drag and drop interface. This means that if you don’t know any commands you are going to have trouble. That is why I am writing this chapter. You NEED SSH or Telnet to install most CGI scripts so learn it, or bookmark this page so you can review the commands when you need to. Now lets learn about the command line. How do I use SSH and Telnet? To use SSH or Telnet, you need a program to talk to your host. Depending on your host, you might use SSH, or you might use Telnet - make sure to browse their help pages, or ask them which on to use. Both methods follow the same basic commands, but are just different methods of logging into your host. Windows has a basic Telnet application, so all you have to do is type “telnet” in the command line. If you need to use SSH, I recommend getting Putty. It works for SSH and Telnet. Now open up your SSH or Telnet Client, and lets learn how to login!
Logging in The first thing you need to do is login. All hosts are different, so make sure you ask your host how you login. I will use my site as an example. Program PuTTY it use SSH and Telnet Commands.
Now open Putty, and type in the name of your site, and check the SSH or Telnet box. Then make sure to save your configuration. Putty should look like this. SSH and Telnet Commands - Now lets learn some commands.
SSH and Telnet Commands SSH and Telnet Commands - Commands must be sent to the host through the command line - which means text input. Remember, all Linux commands are case SENSITIVE, which means “Cd” is different that “cd”. This goes the same for filenames. Also, there are no spaces allowed in file names, which is why I recommend placing “_” instead of spaces in your filenames. Type a backslash (“\”) in front of a special character so Linux knows it is a special character, not a command. Also, you can browse through past commands using the arrow keys. Last, you can tell Linux to finish the filename you are typing by pressing “Tab”. If nothing happens, press “Tab" twice to tell Linux to show you its MULTIPLE options. Remember, it will only finish the filename if there is nothing similar - if you have “site1.html”, and “site2.html”, you can’t type “si” and press “tab”, becuase Linux won’t know which one to pick. Now, to start off, lets learn how to browse the file system.
Browsing the File System I will give you a list of all of the common commands you will need to be able to browse a file system, then show you an example of them in real life. The command for you to type will be bold, followed by an explanation of the command. pwd : “pwd” stands for “Print Working Directory”, which means that when you type this command, it will show you what directory you are in. cd : You move between directory (folders) using the cd command. Type cd, then a space, then the directory you want to go to. If it is within your current working directory, you just need to type the folder name, but if it is not, you start it with a slash. By typing 2 periods, you go up a directory. I will show some examples later. ls : This will allow you to list files under your current working directory. Most people type “ls -l”, which shows all of the information about all of the files, including the last time they were edited, and their permissions.
Editing Files Now that you know how to get around, you need to learn how to edit files. cp : Copy files. Type “cp”, then a space, then the file you want to copy, then its new name/directory. rm : This removes files. Just type “rm”, then the file you want to delete. This is unreversable, so be careful. mkdir : This will create a directory. Type “mkdir”, then a space, then the name of the new directory. rmdir : This will remove a directory. Do the same as “mkdir”, but type the name of the directory you want to remove after the space. chmod : This is how you change the permissions of a file. This is very important, because most cgi scripts require you to set certain permissions. Type “chmod”, then a space, then the number the file needs, then the file. Most cgi scripts have to be 755. ./ : Rune the file after the slash, no space needed after slash. perl : Use perl to run a perl program. Add space after Perl, then filename. These are all of the commands. If you need more help, ask me or get a Linux book. You will learn more when I go over installing CGI scripts. Now lets build! mkdir [name] (CR) : Makes a directory or file group name [name]; e.g. `mkdir dirpgm (CR)' make the directory called `dirpgm'. pushd [name] (CR) : Pushes from the working directory to the directory [name] keeping the sequence of directories in a buffer for `popd'. popd (CR) Pops back up to the prior directory, if `pushd' was used before. For this reason, `pushd' and `popd' are more useful than the regular change directory command `cd'. cd [directory] (CR) : Changes the working directory to the directory [directory]; you can change it back with `cd(CR)' using your own login id; `cd $HOME (CR)' returns the shell back to your home directory. `.' denotes the current directory and `..' denotes the root or parent directory. cd ~[user] (CR) : Changes working directory to that of login id `[user]'. cd $TMP (CR) : changes to your temporary directory; same as `cd $TMP (CR)'. pwd (CR) : Displays working directory; `echo $HOME (CR)' displays the home directory. ls [directory] (CR) : displays the contents of the directory `[directory]'. mv [file1] ... [fileN] [directory] (CR) : moves `[file1]', ..., `[fileN]' to directory `[directory]'; e.g. `mv addtwo.* diradd' moves all files with prefix `addtwo.' to the directory `diradd' which must already exist from a prior 'mkdir diradd' command. This format works for `cp' also. cp [file1] [directory]/[file2] (CR) : copies [file1] into [file2] in directory [directory]. `cp [file] . (CR)' copies a file to the current directory using the original name. This format works for `mv' also.
|