Tag Archives: gui

An Introduction to the Linux Shell

She sells seashells by the seashore. Well, yes… that may be true, but that’s not the type of shell we’re going to talk about here today.

I’m going to talk a bit about the Linux shell. What is the Linux shell? What does it do? How can I interact with it on my GNU/Linux operating system? Those are all good questions. While today’s most popular distributions of GNU/Linux are morphing into operating systems that are more and more graphic user interface oriented, the real power of Linux still resides in the command line.

When you boot up your Ubuntu or Mandriva GNU/Linux operating systems, most of you see a graphical login screen. Others, like myself, might see a non-graphic command line login. Both do basically the same thing. They log the user into the Linux shell so that he may begin to utilize his system’s potential to perform tasks. That’s what we do with our computers, regardless of what the tasks happen to be… emailing pics to auntie Myrtle or hacking cloud and cluster security systems.

The Linux shell is the interface between you in that seat in front of your monitor and the operating system that controls the hardware in that box under the desk that does the actual stuff you want done. There are numerous shells in Linux; the most commonly used one is called BASH – Bourne Again Shell. You’re in the shell anytime you’re logged into your GNU/Linux operating system; whether you’re interacting with it graphically or from the command line.

Graphic User Interfaces or GUIs are just “front ends” to applications that are running in the shell. I’ll be talking mostly about the non-graphical command line interface here today, though. You can access your command line interface from within your GUI by using the graphic front end application for the command line provided by your desktop environment. For example, in Gnome, you could use Gnome Terminal; or in KDE, you could use Konsole. Either way, these are both just graphical front ends for the BASH shell command line.

When you first login, you’ll get what’s known as a prompt. It is just a blank line waiting for your input (commands). It’ll look something like this:

joe@mysystem:~$

The first part, “joe”, is just the user’s login name. “@mysystem” is the name of the computer the user is logged into. The “~” character tells us that user Joe is working from his home directory. The “$” character is the standard character denoting a non-root, regular user.

Let’s say Joe wants to list all the files in his home directory. All he has to do is type:

joe@mysystem:~$ ls

This command, known as “list”, tells the shell that user Joe wants to see a list of all the contents of his home directory. The shell immediately responds after Joe hits the Return (Enter) key on his keyboard with this output:

Desktop  joe_archives  joe_common     joe_private
Dropbox  joe_backups   joe_downloads

It looks like Joe has five regular directories, a Dropbox directory, and the directory that contains his desktop icons. In reality, there are more directories and files in Joe’s home directory, but they’re what are known as “hidden” files. Their names are usually preceded by a .(period) to make them hidden. If joe wants to see all his directories and files he can list them this way:

joe@mysystem:~$ ls -a

The “-a” option means all. The list command will list all items in a directory when using the -a option. Joe’s list now looks something like this:

.dropbox        .macromedia      .thunderbird
.ICEauthority           .esd_auth    .moz_icons      .viminfo
.PySolFC           .fontconfig    .mozilla      .wicd
.Xauthority           .gconf        .mozilla_3.x      .xchat2

The above directories are hidden by the preceding .(period), as mentioned above.

Let’s say Joe want’s to create a grocery list for his afternoon shopping chores. He can do this via the shell and command line also by using a command line editor such as vim. He would first do this by bring up the vim application in the command line interface:

joe@mysystem:~$ vim groceries

This command would initiate the vim application using a new file called “groceries”. Vim or Vi-Improved, as it’s known, is a non-graphical text editing application. It would look something like this to Joe:

lettuce

tomatoes

catfood

peanut butter

eggs

milk

bread

~

~

~

–INSERT–                                                 10,1          All

Once Joe had finished typing out his grocery list, he would save it using the vim command :wq, which would also close the vim application and bring Joe back to the command line prompt. He could also print his list from the command line like this:

joe@mysystem:~$ lpr groceries

The lpr command would tell the shell that Joe wants to output the contents of the groceries file to the printer. The printer would receive the data and the command to print from the computer’s hardware and begin printing Joe’s grocery list.

All of this we’ve talked about today doesn’t even scratch the surface of the power at your finger tips when using the Linux shell. Your first step should be to read the Linux manual page for the BASH shell. There is some very useful information in that document. Stay tuned here… I’ll come up with some other lessons in the future. Remember what I always say…

Learn something. It won’t hurt you none. I promise.

Later…

~Eric

Graphical Boot-up? I Don’t Think So

It’s a Slackware thing, baby. Real Slackers don’t use a graphical boot-up screen.

Ever since I can remember, I’ve modified my /etc/inittab in every distribution I use to boot-up using runlevel 3 as the default. This gives you full multi-user with no X running. Why do I do it this way? Well… it’s COOL! Seriously though, I just prefer it and it serves some practical purposes, also.

Even though I started my Linux journey a few years ago with Ubuntu, I had Slackware up and running as my primary operating system shortly thereafter. You might even say I cut my Linux teeth on Slackware. This is the Slackware way… lightness of being, simplicity, efficient use of resources.

I do a lot from the command line in most of my distros. I just find it easier to start off with no X running in case I do have system chores that need doing, like updating or editing config files for some reason or another. Command line? Bet you thought that went out with octal machine code, huh? Well, it didn’t.

The command line still offers a FAST way to perform functions within the operating system. But hey… it’s not for everyone. It’s a great skill to have at least a passing knowledge of, but you can be perfectly content as a 100% GUI penguin. Nothing wrong with that. Linux ain’t about dictating how you do things. It’s ALL about giving you choices and options to get your work done.

If you feel the need to explore the dark side of Linux, the command line interface, you can modify your /etc/inittab configuration file to boot you into runlevel 3 as a default, as I do. Once you’re done with your stuff and want your graphic interface up and running, just type “startx” at the prompt (no quotes). This command will start the X Window System on your Linux.

In some rare cases, where you’re using certain windows managers/desktop environments, the startx command will not work. You’ll need to know the specific command to launch your graphical interface. For instance, in my Sidux installation, which uses LXDE/Openbox desktop environment/windows manager, I have to type “startlxde” (again without quotes) to fire up the graphic interface. 99% of the time, though, startx will work.

For more information in the /etc/inittab file and runlevels in Linux check out Sandra Henry-Stocker’s recent piece over at ITWorld : Unix How-To: the Linux /etc/inittab file

Have FUN while you’re learning.

Until next time, folks…

~Eric