The Text Based Internet
Part 6: Useful UNIX Commands
Finding your way around the file system
You are at the command prompt. You have no idea were in the file
system you are. What do you do?
In order to find out the path of the directory that
you're in, type pwd.
[otto@shell internet]$ pwd
/home/o/t/otto/
[otto@shell internet]$
Odds are, if you just logged in, you will be in your home directory,
which is home/username.
Now that you know where you are, use ls -la to get a directory
listing.
[otto@shell otto]$ ls
#pico23295# .bash_profile .plan art4.zip mail/
#pico29260# .bashrc .procmail/ babies2.JPG pinerc01
./ .elm/ .procmailrc bigots/ stuff/
../ .letter.swp .rnlast bin/ referance
.addressbook .lynx_cookies .rnsoft braindump resume.doc
.addressbook.lu .mailbox .signature coverletter.doc story2.doc
.aliases .newsrc .tin/ cyberpunk tiny.doc
.article.swm .oldnewsrc Mail/ dead.letter tiny.rtf
.article.swn .pine-debug1 News/ games.ZIP www/
.article.swo .pine-debug2 art.ZIP games2.ZIP writings/
.article.swp .pine-debug3 art1.ZIP library
.bash_history .pine-debug4 art2.ZIP links.html
.bash_logout .pinerc art3.ZIP lynx_bookmarks.html
[otto@shell otto]$
As you can see, my home directory is a dumping ground for all sorts of
stuff. The files that start with a period, like .addressbook are
hidden files. Usually you can only see them if you put a -a after
the ls command. The files with a / behind them are
directories, for example Mail/.
A lot of the files that I have on my shell account
are temporary storage. The art and game zip files, for an example, I'm
currently moving from one computer to another and they are too big to fit
on disks. Wow, I should clean this up.
The first thing that I should do is make a directory to put them in. I
will call it "storage" and use the mkdir command to add it.
From now on, I will be shortening the directory listings for the
sake of brevity.
[otto@shell otto]$ mkdir storage
[otto@shell otto]$ ls
../ .letter.swp .rnlast bin/ referance
.addressbook .lynx_cookies .rnsoft braindump resume.doc
.addressbook.lu .mailbox .signature coverletter.doc storage/
.aliases .newsrc .tin/ cyberpunk story2.doc
As you can see, there is now a folder called storage in the home
directory. How do I move those pesky zip files into it? With the
mv command. Here's how it works.
I decide which files I want to move, all of the zip files. They all
have a .zip extension, which means I can move them all in one command with
a wildcard. So I want to tell the computer to move the files, which files
I want moved, and where I want to move them to. Then, I will use the ls
command to show that these files have indeed been moved.
[otto@shell otto]$ mv *.zip storage
[otto@shell otto]$ ls
.article.swn .pine-debug1 News/ games2.ZIP www/
.article.swo .pine-debug2 art.ZIP library writings/
.article.swp .pine-debug3 art1.ZIP links.html
.bash_history .pine-debug4 art2.ZIP lynx_bookmarks.html
.bash_logout .pinerc art3.ZIP mail/
[otto@shell otto]$ cd storage
[otto@shell storage]$ ls
./ ../ art4.zip
This is very embarrassing. Why didn't it work? Why did only one of
the
files that I said for it to move end up moved?
Look very closely. I told it to move all of the .zip files. art4.zip
was in fact moved, but none of the other zip files were. This is because
the extensions of the other files is .ZIP instead of .zip. Let me try
this again.
[otto@shell storage]$ cd ..
[otto@shell otto]$ mv *.ZIP storage
[otto@shell otto]$ ls
.article.swm .pine-debug1 babies2.JPG resume.doc
.article.swn .pine-debug2 bigots/ storage/
.article.swo .pine-debug3 bin/ story2.doc
.article.swp .pine-debug4 braindump tiny.doc
.bash_history .pinerc coverletter.doc tiny.rtf
[otto@shell otto]$ ls
./ ../ art.ZIP art1.ZIP art2.ZIP art3.ZIP art4.zip games.ZIP
games2.ZIP
[otto@shell storage]$
As you can see, the zip files are all stored away nicely.
Now, lets got to the directory where I seem to spend ALL of my time
these days for some more fun.
[otto@shell internet]$ cd ../bigots/internet
Since I finished the ftp page, I don't need the ftp-cuts file of my
screen shots anymore, so I may as well delete it. To do this, use the
rm command.
[otto@shell internet]$ rm ftp-cuts
[otto@shell internet]$ ls
./ ReadMe.htm news.html textbased.html tin.html
../ ftp.html pine.html thebasics.html
[otto@shell internet]$
Notice that it didn't ask me for confirmation. It didn't ask me if I
was sure. Notice, there is no recycling bin. Do not delete anything
unless you are sure you don't need it. Be very careful in using wildcards
with it because it will delete everything that qualifies without asking
you.
Four Useful Utilities
The first useful utility is Pico. Did you read the pine section?
Pico will look familiar.
Pico is a text editor that is very quick and easy to use. It has the
same interface as Pine. Basic commands that are good to know are
^K to cut a line of text, ^O to save, ^G to get help,
^T to go into the spell check and ^x to exit.
Type pico and the name of the file that you want to edit.
[otto@shell internet]$ pico sonnet_132
Here's a look at what you get.
UW PICO(tm) 3.5 File: sonnet Modified
SONNET NO. 132
Thine eyes I love, and they as pitying me,
Knowing thy heart torment me with disdain
Have put on black, and loving mourners be
Looking with pretty ruth upon my pain,
And truly not the morning sun of heaven
Better becomes the grey cheeks of the east,
Nor that full star that ushers in the even
Doth half that glory to the sober west
As those two morning eyes become thy face:
0, let it then as well beseem thy heart
To mourn for me since mourning doth thee grace,
And suit thy pity like in every part.
Then will I swear beauty herself is black,
And all they foul that thy complexion lack.
[ Read 20 lines ]
^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
ToSpell
You can use pico to edit any text file, including web pages. This, in
fact, is what I'm using to write this page right now.
Another useful utility that I will cover is telnet. Telnet
takes you from
the machine that you're on and lets you access another machine.
As an example, I will telnet to freeshell.org.
[otto@shell internet]$ telnet freeshell.org
Trying 63.68.131.237...
Connected to freeshell.org.
Escape character is '^]'.
GNU Version FOO (Channel sty.s_telnet_083) 02/28/00 1405.06 cst Mon
Up 17 days, 01:49 hours; Load = 8.05 out of 150.0 units; Users = 80
sdf.lonestar.org
if new, login "visitor" ..
login:
Here, I log in under my account. On freeshell, you can sign up for an
account by typing visitor at the login and following the
directions.
Freeshell allows you free e-mail using pine or some other UNIX
standard mail reader. If you want to access lynx or tin, you have to pay
a one time fee of $30. They do have some extras, though, like games.
If you type games at the command prompt, you get a list of games
they provide. I highly recommend Robots.
countmail macarena robots worm
cribbage mazewar rot wump
dungeon mille rot13 yow
f00f monop sail
factor morse showfigfonts
Most games use "vi" keys for direction, meaning:
k
h l
j
Also, you can quit most games by sending ^C from your TTY.
$
Note the last line. ^C is one of the most useful
command in the
UNIX, if not in the entire non-Microsoft world. By pressing ^C it
gets you out of the program that you are in. If you are in almost any
program that ceases to work, you can press ^C to get out.
When you are done playing, type logout, and that will take you back to
your original machine.
Talk is a utility to talk, in real time, to other people with
UNIX shells. Type talk email address and the will receive
a message saying that some one wants to talk to them. Then, they will
type talk your email address and you will be in a split
screen where half of the screen shows what you are typing, and the other
half shows what they are typing. To get out, press ^C, and it
takes you back to the command prompt. Move over IRC, talk is quick, easy,
and takes almost no bandwidth.
Lynx is a common text based web browser that is very fast,
easy, and
one of my favorites. You call it up on the command line by typing
lynx or lynx url. I was originally going to write a
segment on it, but it seems so self explanatory that I can't bear the idea
of doing that. Use ? to get to the help section which lists all of
the possible commands. Use g to type in the website that you would
like to go to.
There is a point where one must teach themselves, and this is the
point. All of you, go bring up lynx and just play. It will be good for
you.
Getting Help
The help command in UNIX is man, which is short for manual.
Type man.
[otto@shell internet]$ man
What manual page do you want?
[otto@shell internet]$
What was that? In order to use man, you need to look up a command.
You do this by typing man command.
[otto@shell internet]$ man man
man(1) man(1)
NAME
man - format and display the on-line manual pages
manpath - determine user's search path for man pages
SYNOPSIS
man [-acdfFhkKtwW] [-m system] [-p string] [-C con-
fig_file] [-M path] [-P pager] [-S section_list] [section]
name ...
DESCRIPTION
man formats and displays the on-line manual pages. This
version knows about the MANPATH and (MAN)PAGER environment
variables, so you can have your own set(s) of personal man
pages and choose whatever program you like to display the
formatted pages. If section is specified, man only looks
in that section of the manual. You may also specify the
order to search the sections for entries and which prepro-
cessors to run on the source files via command line
options or environment variables. If name contains a /
:
You can do this with any command or utility I have
covered. To go to the next page, use the spacebar. To quit, type
Q.
This about covers it. I hope that all of you learned something. I you
have any comments, questions, corrections, etc, feel free to
mail me. Thanks for listening.
- You can check your mail through Pine.
- You can check out the newsgroups through tin.
- You may want to download some files with ftp.
|