The Linux Clues guide to using the Linux command-line prompt and the 'root' login.

InformationWeek Staff, Contributor

December 8, 2004

4 Min Read

Welcome to Linux Clues--friendly, informed, understandable advice about Linux, written by Linux users, for Windows users or anyone who wants to test the Linux waters.

This continuing series comes to you courtesy of LinuxClues.com. Most of the material you'll find here comes from Bruno of Amsterdam, one of the moderators of the popular All Things Linux forum at Scot's Newsletter Forums, along with contributions from other fourm members.

Scot Finnie, author of Scot's newsletter and caretaker of the Scot's Newsletter Forums, is the editor of the Linux Clues content.

The folks at LinuxClues.com are always on the lookout for new tips, tricks, and how-to articles designed to help new Linux users get up to speed. Feel free to send feedback, suggestions and contributions to [email protected].

The Linux Clues Cheat Sheet
The tips listed below are designed to help you follow many of the instructions provided with future installments of Linux Clues. It won't take long for all of this to become second nature as you get more familiar with the Linux command-line prompt. But we'll also make it easy for you to go back and review this information whenever you need it.

Linux Prompt Basics
The Linux command-line prompt is more complex and more useful than, for example, the DOS prompt. It shows the name of the user who is logged in, and whether that user is logged in as a standard user, or as "root," which is loosely equivalent to a Windows NT/2000/XP "administrator."

Most Linux prompts follow this basic structure:

[localhost@localdomain:~]$

The localhost and localdomain in the above example are placeholders for the names specific to your Linux login and directory location. The prompt varies slightly with different distros and settings, but this actual prompt (from Linux Mandrake) is representative:

[bruno@jupiter bruno]$

The prompt ends with the $ symbol when you're logged in as a standard user. When you're logged in a root (or "administrator"), the prompt ends with the # symbol. (Note: In SuSE, when you're logged in as a standard user, the Bash prompt ends with a > symbol, like DOS.)


Linux Command-Line Nomenclature
When they're shown in printed instructions, Linux command-line commands entered from a terminal or console window start with the Linux prompt, which is represented as $ or #. The $ prompt tells you you're logged in as a standard user and the # prompt tells you that you're logged in as root. (See Linux Prompt Basics.)

The following command printed in instructions tells you to ensure that you're logged in as a standard user and then type "man help" and press Enter:

$ man help

The key point is: This nomenclature does not tell you to type "$ man help" and press Enter. Again, the $ prompt tells you where to start. You type what's after the $ prompt. Long-time DOS and Windows users are often confused by this way of explaining Linux commands, so it's important to get clear on it early on.


Logging in and out as Root
In Linux, you should not be logged in as "root," the all-powerful administrator to the operating system all the time. It's far too easy to accidentally damage your Linux installation. The prudent way to operate is to log in as Linux root when you need to for something specific and then log back out. This is easy to do. To log in, open a terminal or console window. Execute this command (remember, you don't type the "$"):

$ su

Linux will respond with this request to enter your root password:

Password:

Simply type your root password and press Enter. The prompt will now change so that it looks something like this:

[root@localhost scot]#

If you've lost or forgotten your root password, please see Lost Password! for a tip on how to get it back.

To log out of root, either type "exit" on the command line and press Enter, or just press the Ctrl-D keyboard combination.

Never Miss a Beat: Get a snapshot of the issues affecting the IT industry straight to your inbox.

You May Also Like


More Insights