Guide to Telnet and the Unix Shell
Telnet is a method whereby you can control another computer on the network by issueing text mode commands. This can often be faster than FTP for making small changes to files. This guide shows you how to telnet into a machine, what commands to use, and gives a brief introduction to the Pico text editor.
Starting Up
To telnet into, for example, www.ucc.ie, go to Start->Run on windows, or a terminal on Unix, and type:
telnet www.ucc.ie
This will start a telnet program, which will connect to www.ucc.ie. You will be asked for a username and a password. These are the same as the ones you use to FTP into the site. Note however, that when you type in your password, nothing will appear on the screen, not even asterisks. This is for security reasons. You will be dropped into your home folder.
Common Commands
The commands below cover most things you'll want to do to files. Case is important, you have to type things in exactly as shown. The backspace and delete keys may not work, on a lot of systems they'll print out ^H. There's not much you can do about this if it happens. If you want to refer to a file in a folder, you type foldername/file.extn, or maybe folder1/folder2/file.extn. It's the same as typing things into a web-browser if you think about it. If you want to refer to a file in the folder above the one you're currently in (i.e. the one that contains it) type ../file.extn. You can do this repeatedly to refer to files several levels up, e.g ../../../file.extn. If a filename has spaces in it, prefix each space with a backslash. For example, to enter a folder called My Documents you'd type
cd My\ Documents
There are a couple of useful tricks you might want to know. If you want to repeat what you just typed, you can use the up and down arrows on you keyboard to cycle through your previous commands. If you're typing a long filename, only type the first few letters, then press the Tab key (the one on the left with the two arrows). If there's no doubt as to the file in question, the shell will finish off the rest of the filename for you. That, along with the list of commands below, should cover most things. If you want to learn more you can go here to get a more advanced tutorial. Bash is the name of the program that interprets all these commands in case you're wondering.
| Action | Command |
|---|---|
| Where am I? | pwd |
| Show contents of this folder |
ls ls -l displays detailed information on each file ls -a displays all files, including hidden ones. ls -a -l is a combination of the above two |
| Moving between folders |
cd [folder name] To move back up type cd .. |
| Delete a file | rm [filename] |
| Copy a file | cp [original file] [new file] |
| Move a file | mv [original location] [new location] |
| Rename a file | mv [original name] [new name] |
| Create a shortcut | ln -s [original file] [shortcut] |
| Display a file's contents | less [filename] |
| Edit a file | pico -w [filename] |
| Help |
For brief help on a command, type the command followed by --help e.g. ls --help For detailed help on a command type man [command] |
| How to force a program to quit | Hold down the Ctrl key and press C |
| Logout | exit |
Editing files using the Pico editor
There are several editors available for you, but only one is any good. It's called Pico. To start it type pico. To open a file with it type pico -w [filename]. The -w file stops Pico changing the file to make sure everything fits on screen. It's usually the safer option. You can still scroll left, right, up and down using the arrow keys on your keyboard. To perform actions (e.g. saving/opening files) you hold down the Ctrl key and press another. To make things easy though, they display the list of keys at the bottom of the page like so:
Pico Commands
^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where is ^V Next Pg ^U UnCut Text^T To Spell
So to save a file, you hit Ctrl-O, to open a file hit Ctrl-R and to exit hit Ctrl-X. When you go to save a file, it'll display the filename. If you don't want to change it, just hit enter.