spacer.png, 0 kB

Linux News Flash

  • The Telepathic Desktop: Apps Are Out, People Are In 22 Nov 2008 | 1:03 am

    The New Topyli Standard: "This article is a humble opinion piece of a GNOME user who wishes to stop using communication software and just be in touch with people. I want to write mail to, chat with, talk to, and have video conferences with real people without worrying about applications and technology."

fish PDF Print E-mail


StumbleUpon!

Image fish is a user friendly command-line shell. For those new to Linux, the term shell refers to a program that executes other programs. If you open a terminal and type ls followed by a return, you are opening up your default shell and using it to execute the program 'ls'. There are many UNIX/Linux shells; there's the Bourne shell, C Shell, Kornshell, Bash (Bourne Again) Shell, and as we discuss here, the friendly interactive shell (fish). Each shell's main purpose is to execute other programs, but they all have slightly different features/syntax. Bash is the most commonly used shell for Linux users, but we're talking about fish here, because it was built with new Linux users in mind. To install fish, if it's not already installed, check your packaging system for fish; if you're running Ubuntu, you can simply run "sudo apt-get install fish" in a terminal.

With fish, every command follows the same simple syntax. A command is executed by writing the name of the command followed by any arguments. To being, open up a terminal and type fish followed by a return. If you have the fish shell, you will see a prompt similar to the following:

chris@ubuntu1:~$ fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

Begin by typing help followed by a return. fish will open up your default web browser and display the help contents. This is a great place to begin. If you ever need help with a particular command, type help followed by a space band and then the name of the command followed by a return. Let's try a really simple command:

chris@ubuntu1 ~$ echo hello world
hello world

You will notice that fish is a smart interpreter. If your terminal has color support, you will notice that certain words are highlighted. fish checks the first word on the command-line; the first word should always be some sort of identifier to the interpreter; in most cases, it is the name of a command or program. If fish recognizes that the first word is a command or executable program, then it will color in the command; this is a quick way of checking to see if you have typed the command correctly.

With a fresh prompt, hit the tab key. The shell will return a list of all executable programs. Tab is fish's way of performing command-line completion. For example, if you started to type the letters 'ech' and then you hit a tab, fish will show you all of the executable programs/commands available in your executable path that begin with the letters 'ech'. If it finds that there is only one such available program, it will go ahead and complete the line for you. In my case, echo is the only program I have that starts with ech, so fish edited the command-line and replaced ech with the word echo.

Command-line completion is not a new feature. You will find a similar feature in the bash shell. However, fish's interpretation of command-line completion is a little more sophisticated. For example, if you're in a directory, and you execute the program ls, you will be given a list of files in that directory; if you type ls, space, then hit tab, the shell will prompt you with a list of available files in that directory; it understands that ls lists files, and not only will it show you the files but it will also show you a brief description of the type of file. For example:

chris@ubuntu1 ~/Pictures$ ls spaceballs
$ceballs.jpg (JPEG image, 1.4kB) $ceballs1kf0.jpg (JPEG image, 8.9kB)
$ceballs.xcf (GIMP image, 14kB)

The following is a list of some useful and common commands:

  • cd, change the current directory

  • ls, list files and directories

  • help, bring up the help documentation

  • mv, rename files or move them from one directory to another

  • cp, copy files

  • open, open files with the default application associated with each filetype

  • less, list the contents of files (in ascii format)

Read up on each of these commands in the help documentation to get a better idea of how they work and what command-line arguments they can and cannot take. It's always a good idea to read up on a command before actually using it. You don't want to inadvertently delete important documents or overwrite any files. The command-line is a powerful tool, and Linux can be unforgiving. For example, the command rm removes a file. The default behavior for rm is to just remove the file without prompting if it's ok, and the file isn't removed to a trash bin, it's just removed completely. You can go the extra yard and write your own script that actually moves the file to a temporary folder or ensures that the user is prompted before the command is executed, but make sure to read up on the defaults so you're aware of their behaviors.

We suggest you play around with fish. Read up on the documentation. fish is great for people new to Linux, because it's so interactive. If you pay close attention to the color highlighting, you'll always be sure to type in your commands correctly, and the help feature is fantastic. If you become comfortable with fish, try moving on to one of the other shells, especially bash. Bash is the most used shell in Linux today, and you should make note of the subtle syntax differences between it and other shells.

Only registered users can write comments.
Please login or register.


Add as favourites (57) | Quote this article on your site | Views: 635

Be first to comment this article
RSS comments

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved





Reddit!Del.icio.us!Google!Facebook!Slashdot!Netscape!Technorati!Newsvine!Furl!Fark!Blogmarks!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
spacer.png, 0 kB
Copyright © New Epoch Software LLC 2008. Website by New Epoch Software LLC
All rights reserved. Logos are property of their respective owners.

We use Fedora Linux