Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




OpenSuSE 11.1 Quick Start Guide
Previous Page Home Next Page

8.2 Entering Commands

As soon as the prompt appears on the shell it is ready to receive and execute commands. A command can consist of several elements. The first element is the actual command, followed by parameters or options. You can type a command and edit it by using the following keys: , , Home, End, Backspace (Backspace), Del, and Space. You can correct typing errors or add options. The command is not executed until you press Enter.

IMPORTANT: No News Is Good News

The shell is not verbose: in contrast to some graphical user interfaces, it usually does not provide confirmation messages when commands have been executed. Messages only appear in case of problems or errors —or if you explicitly ask for them by executing a command with a certain option.

Also keep this in mind for commands to delete objects. Before entering a command like rm (without any option) for removing a file, you should know if you really want to get rid of the object: it will be deleted irretrievably, without inquiry.

8.2.1 Using Commands without Options

In Section 7.3.1, Permissions for User, Group and Others you already got to know one of the most basic commands: ls, which used to list the contents of a directory. This command can be used with or without options. Entering the plain ls command shows the contents of the current directory:

[email protected]:~> ls
bin Desktop Documents public_html tux.txt
[email protected]:~>

As you already learned in Section 7.2.1, Key Features files in Linux may have a file extension or a suffix, such as .txt, but do not need to have one. This makes it difficult to differentiate between files and folders in this output of the ls. By default, the colors in the Bash shell give you a hint: directories are usually shown in blue, files in black.

8.2.2 Using Commands with Options

A better way to get more details about the contents of a directory is using the ls command with a string of options. Options modify the way a command works so that you can get it to carry out specific tasks. Options are separated from the command with a blank and are usually prefixed with a hyphen. The ls -l command shows the contents of the same directory in full detail (long listing format):

[email protected]:~> ls -l
drwxr-xr-x 1 tux users     48 2006-06-23 16:08 bin
drwx---r-- 1 tux users  53279 2006-06-21 13:16 Desktop
drwx------ 1 tux users    280 2006-06-23 16:08 Documents
drwxr-xr-x 1 tux users  70733 2006-06-21 09:35 public_html
-rw-r--r-- 1 tux users  47896 2006-06-21 09:46 tux.txt
[email protected]:~>

This output shows the following information about each object:

drwxr-xr-x 1 tux users 48 2006-06-23 16:08 bin 

Type of object and access permissions. For further information, refer to Section 7.3.1, Permissions for User, Group and Others.

Number of hard links to this file.

Owner of the file or directory. For further information, refer to Section 7.3.1, Permissions for User, Group and Others.

Group assigned to the file or directory. For further information, refer to Section 7.3.1, Permissions for User, Group and Others.

File size in bytes.

Date and time of the last change.

Name of the object.

Usually, you can combine several options by prefixing only the first option with a hyphen and then write the others consecutively without a blank. For example, if you want to see all files in a directory in long listing format, you can combine the two options -l and -a (show all files) for the ls command. Executing ls -la shows also hidden files in the directory, indicated by a dot in front (for example, .hiddenfile).

The list of contents you get with ls is sorted alphabetically by filenames. But like in a graphical file manager, you can also sort the output of ls -l according to various criteria such as date, file extension or file size:

  • For date and time, use ls -lt (displays newest first).

  • For extensions, use ls -lx (displays files with no extension first).

  • For file size, use ls -lS (displays largest first).

To revert the order of sorting, add -r as an option to your ls command. For example, ls -lr gives you the contents list sorted in reverse alphabetical order, ls -ltr shows the oldest files first. There are lots of other useful options for ls—in the following section you will learn how to investigate them.

8.2.3 Getting Help

Nobody is expected to know all options of all commands by heart. If you remember the command name but are not sure about the options or the syntax of the command, choose one of the following possibilities:

--help option

If you only want to look up the options of a certain command, try entering the command followed by a blank and --help. This --help option exists for many commands. For example, ls --help displays all the options for the ls command.

Manual Pages

To learn more about the various commands, you can also use the manual pages. Manual pages also give a short description of what the command does. They can be accessed with man followed by the name of the command, for example, man ls.

The man pages are displayed directly in the shell. To navigate them, move up and down with PgUp and PgDn. Move between the beginning and the end of a document with Home and End. End this viewing mode by pressing Q. Learn more about the man command itself with man man.

Info Pages

Info pages usually provide even more information about commands. To view the info page for a certain command, enter info followed by the name of the command, for example, info ls. You can browse an info page with a viewer directly in the shell and display the different sections, called nodes. Use Space to move forward and Backspace to move backwards. Within a node, you can also browse with PgUp and PgDn but only Space and Backspace will take you also to the previous or subsequent node. Like for the man pages, press Q to end the viewing mode.

Note that man pages and info pages do not exist for all commands: sometimes both are available (usually for key commands), sometimes only a man page or an info page exists, sometimes neither of them.

8.2.4 Bash Shortcut Keys

When having entered several commands, your shell will soon be filled with all sorts of commands and the corresponding outputs. In the following table, find some useful shortcut keys for navigating and editing in the shell which help you to keep overview.

Shortcut Key



Clears the screen and moves the current line to the top of the page.


Aborts the command which is currently being executed.


Scroll upwards.


Scroll downwards.


Delete from cursor position to start of line.


Delete from cursor position to the end of line.


Closes the shell session.


Browse in the history of executed commands.

OpenSuSE 11.1 Quick Start Guide
Previous Page Home Next Page

  Published under the terms fo the GNU General Public License Design by Interspire