Linux and FOSS

Mastering The Linux Shell - Finding Anything

You know how you get those emails that suggest you can find out anything about anyone? They claim to be able to locate any person and tell you who they are, where they are from, the date they were born, and what their background is . . . You'll be happy to know this isn't the subject of this article. It's a lot more fun than that.

Mastering The Linux Shell - Advanced Permissions

In my last article, I introduced the idea of permissions in the Linux world. Some users can read or write a file, while others can only read the same. A user may also belong to a group and share the permissions of that group which might also involve the ability to execute, or run a file as a program.

Mastering The Linux Shell - Getting Permission

Under Linux, access to files and directories is controlled by a system of permissions. Those permissions define who can see a file, whether they can modify it in any way, and in the case of some files, whether the commands within that file (or the file itself) can be executed. By executed, we mean "can we run that program?".

Mastering The Linux Shell : Making Things Disappear

Information begets information and eventually, there's just too much of it. I don't really believe that -- I'm an information junkie -- but there's no question that if you never delete anything, eventually, you will either use up all your disk space, or you'll have a terrible mess on your hands.

Mastering the Linux Shell : Files and Directories

Let me tell you the secret of computers, of operating systems, and of the whole industry that surrounds these things: Everything is data. Information is the be all and end all of everything we do with computers. Files are the storehouses for that information and learning how to manipulate them, use and abuse them, and otherwise play with them will still be the point of computers 20 years from now. There's a saying in the Linux world that "everything is a file" (a comment attributed to Ken Thompson, the developer of UNIX). That includes directories. Directories are just files with lists of files inside them. All these files and directories are organized into a hierarchical file system, starting from the root directory and branching out.

For the record, and to make things easier, you can safely assume that folders and directories are the same thing. The terms can be used interchangeably, but I will usually refer to them directories. If you are more comfortable thinking of them as folders, don't worry. Depending on the application, you'll see both terms used.

The root directory (referred to as slash, or /) is actually aptly named. If you consider your file system as a tree's root system spreading out below the surface, you start to get an idea of just what things look like.

Under the root directory, you'll find folders called usr, bin, etc, tmp, and so on.  And then we have the three invisible, often overlooked, but completely indispensible files on your system: standard in, standard out, and standard error. I'll tell you more about those three later. Suffice it to say that understanding and knowing how to work with all these “files” will provide you with amazing flexibility when it comes to doing your work. 

Mastering The Linux Shell

This is the first of several articles I will be writing on the subject of the Linux command shell. Feel free to consider this first entry as a polite introduction to the topic. In Windows-land, you had "CMD" or what some might remember as the DOS prompt. In Linux, we call it a command shell, or simply "a shell". There are many types of shells, each of which works similarly (e.g. they all allow you to run commands) but each sports many different capabilities. The default on Linux is called bash, or the GNU Bourne Again Shell, so named because it is based on the UNIX Bourne shell. 

If you're ready, it is time to transform you into a master or mistress of the shell. In deciding to join me here, you have identified yourself as one of the bold and curious explorers who really want to know their Linux systems. Sure, it is possible to work day in and day out with your Linux system and rarely use the command line, but the command line is power. Your reward for continuing to this next level will be a deeper understanding of your system and the power to make it do whatever you want.

The things I want to talk about here are basic commands that will serve you well throughout your time with Linux. One of the things I hope to show you is how flexible some of these commands are. With most, you can modify the basic function with command-line switches, flags, or options, and thereby have them yield far more information than a simple execution of the command itself. A little thirst for exploration will open you up to the real potential of everyday commands. 

01
Nov

To all my freedom-loving friends, drink up!

Yes, they are beer coasters. I got them at one of the big Linux conventions, many years ago. Yes, there used to be such things.

14
Dec

Need A Psychiatrist? Meet Eliza

For some of us, our original exposure to AI, or artificial intelligence, goes back to an old program called Eliza. Eliza was a kind of computerized psychiatrist written in the 1960s by Professor Joseph Weizenbaum at the Massachusetts Institute of Technology. Eliza (named after the character in George Bernard Shaw's "Pygmalion") was an exercise in human response and natural language communication with so-called machine intelligence. The version I played with all those years ago was a DOS program running on a TRS-80. Ah, nostalgia. Eliza may not have been a great doctor, but it was a fun and fascinating program, a kind of whimsical promise of the future of AI.

Over forty years have passed since Eliza made her debut in 1966. You can still find incarnations of her everywhere on the Internet. Eliza's ghost is represented in many of the bots and chatterbots you'll find on IRC channels and MUDs. In fact, you can download Eliza as a Perl module and experiment with the creation of your own bots using your own Linux system. The code is available at the CPAN repository or the Comprehensive Perl Archive Network. You can find the latest incarnation at http://search.cpan.org/dist/Chatbot-Eliza/ .

The file is called Chatbot-Eliza. When I picked up my copy, it was version 1.04 and I installed it in the following way.

tar -xzvf Chatbot-Eliza-1.04.tar.gz
cd Chatbot-Eliza-1.04
perl Makefile.PL
make
sudo make install

In the installation directory, you'll notice a file called simple. You can use this as the basis for creating your own AI, or you can simply execute the script by typing ./simple as I did in the following example:

$ ./simple
Welcome to your therapy session.
Your therapist's name is Liz.

Liz:    Is something troubling you?
you:    I'm concerned about artificial intelligence.
Liz:    Do you know anyone else who is concerned about artificial intelligence?
you:    Several people I know have different concerns regarding the subject.
Liz:    What differences do you see?
you:    Some are excited about computer intelligence and others are frightened.
Liz:    Do computers worry you?
you:    Not particularly.
Liz:    Tell me more about that.
you:    I've always had a fondness for computers, real or fictional.
Liz:    What about machines worries you?
you:    That they might actually understand what i am talking about.
Liz:    Are such questions much on your mind?
you:    Are they on yours?
Liz:    Possibly they are they on mine.
you:    Do you have anything else to offer?
Liz:    We were discussing you -- not me.
you:    I see. I should probably go.
Liz:    That's quite interesting.
you:    Goodbye.
Liz:    Goodbye.  It was nice talking to you.

The script that calls the chatbot can be extremely simple, hence its name. If you don't like the name Liz or the introductory text, edit the file and change it here.

use Chatbot::Eliza;
$chatbot = new Chatbot::Eliza 'Sigmund';
$chatbot->command_interface();

Make the script executable and run it. In this case, I have renamed my chatbot Sigmund. The default name is actually Liz. In the distribution directory, you will also find a file called doctor.txt that can be used as the basis for your own bot. I created one called mywords.txt from the doctor.txt file and modified my startup script slightly:

#!/usr/bin/perl -w
use Chatbot::Eliza;
$chatbot = new Chatbot::Eliza {
        name => 'Turing',
        scriptfile => 'mywords.txt',
        };
$chatbot->command_interface();

Now I start my script with the command ./myai, and this is the result:

$ ./my-ai

Turing: Well, well. Another person trying to see if machines can think.
you: There's no doubt that I am curious.

Particularly interesting in this distribution is an included script called twobots that lets two Eliza bots talk to each other. The resulting discussions can be quite interesting. You'll also find a script called simple.cgi so that you may add your own Eliza chatbot to your web site and share your therapist, or whatever you want Eliza to be, with the world. 

Artificial? Definitely. Intelligence? Depends on who you ask, I suppose.

Have fun!

21
Sep

Fly The Flyer

This morning, a representative from Addison Wesley (my publisher) contacted me regarding promotion for Moving to Ubuntu Linux.

I won't bore you with everything that transpired, but she did send me a cool flyer in PDF format. Download a copy, print it out, email it, or pass it around.

Visit your local bookstore, hand them a copy, and tell them to order it.

17
Aug

Virtual Book Launch, Friday, August 18

This coming Friday, August 18th, my new book, "Moving to Ubuntu Linux", will be officially released. For those lucky ones who will be at LinuxWorld Expo in San Francisco, that date might be as early as Thursday as they are planning on having copies to launch the book at LWE. Since I can't make the launch of my book in San Francisco (sniff), I thought it might be fun to do a Virtual Book Launch on Friday.

Pages

Comments

Subscribe to RSS - Linux and FOSS