BasicCommands

BasicCommandsSample.png

"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are." -- from man intro(1)

Using this page

Starting a Terminal

In Gnome (Ubuntu)

The terminal can be found at Applications menu --> Accessories --> Terminal.

In Xfce (Xubuntu)

The terminal can be found at Applications menu --> System --> Terminal.

Commands

sudo: Executing Commands with Elevated Privileges

File & Directory Commands

System Information Commands

user@computer:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 6.06 LTS
Release:        6.06
Codename:       dapper

Adding A New User

Options

The default behavior for a command may usually be modified by adding a --option to the command. The ls command for example has an -s option so that "ls -s" will include file sizes in the listing. There is also a -h option to get those sizes in a "human readable" format.

Options can be grouped in clusters so "ls -sh" is exactly the same command as "ls -s -h". Most options have a long version, prefixed with two dashes instead of one, so even "ls --size --human-readable" is the same command.

"Man" and getting help

/!\ command --help and man command are the two most important tools at the command line.

Virtually all commands understand the -h (or --help) option which will produce a short usage description of the command and it's options, then exit back to the command prompt. Try "man -h" or "man --help" to see this in action.

Every command and nearly every application in Linux will have a man (manual) file, so finding them is as simple as typing "man "command"" to bring up a longer manual entry for the specified command. For example, "man mv" will bring up the mv (Move) manual.

Move up and down the man file with the arrow keys, and quit back to the command prompt with "q".

"man man" will bring up the manual entry for the man command, which is a good place to start!

"man intro" is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.

There are also info pages, which are generally more in-depth than man pages. Try "info info" for the introduction to info pages.

Searching for man files

If you aren't sure which command or application you need to use, you can try searching the man files.

Other Useful Things

Pasting in commands

Often, you will be referred to instructions that require commands to be pasted into the terminal. You might be wondering why the text you've copied from a web page using ctrl+C won't paste in with ctrl+V. Surely you don't have to type in all those nasty commands and filenames? Relax. Middle Button Click on your mouse (both buttons simultaneously on a two-button mouse) or Right Click and select Paste from the menu.

Save on typing

Up Arrow or ctrl+p

Scrolls through the commands you've entered previously.

Down Arrow or ctrl+n

Takes you back to a more recent command.

Enter

When you have the command you want.

tab

A very useful feature. It autocompletes any commands or filenames, if there's only one option, or else gives you a list of options.

Change the text

The mouse won't work. Use the Left/Right arrow keys to move around the line. (is this correct? I'll check at home).

When the cursor is where you want it in the line, typing inserts text - ie it doesn't overtype what's already there.

ctrl+a or Home

Moves the cursor to the start of a line.

ctrl+e or End

Moves the cursor to the end of a line.

ctrl+b

Moves to the beginning of the previous or current word.

ctrl+k

Deletes from the current cursor position to the end of the line.

ctrl+u

Deletes the whole of the current line.

ctrl+w

Deletes the word before the cursor.

More Information

For more detailed tutorials on the Linux command line, please see:


Head back to UserDocumentation

last edited 2007-01-17 20:52:06 by Facttech