Basic Bash

From LXF Wiki

Basic Bash

Bash is the default shell on almost every Linux distribution -- it provides the text-based prompt at which you type commands. If you've used DOS before, you'll find it a familiar environment. The essential commands you can enter at a Bash prompt include:


ls -- list files in a directory

cd directory -- switch to a directory

cp filename location -- copy a file into another location

mv filename location -- move a file into another location or rename a file

rm filename -- delete a file (you cannot undo this!)

df -- view disk space usage

du -- show the space used by the current directory

Every one of these commands will accept lots and lots of options in the form of flags. For example to get more info about the files in a directory do:

ls -alh

Which means:

a = all, including hidden ones
l = long, show times filesize permissions etc
h = human readable, size in Kb/Mb real times rather than seconds

To see the list of options for a command you can do:

man command

Where command is the one you want (use q to quit the page), or you can do:

command --help

Which will print a list of options.

Bash includes some features to make command line usage faster and more efficient. As you're typing a command or filename, you can press the Tab key to make Bash complete the line. For instance, if you want to switch to 'verylongdirectoryname', you can enter 'cd very', press Tab, and it will fill in the 'longdirectoryname'.

Additionally, Bash includes a command history, so you can recall previous commands you've entered. Use the Up and Down cursor keys to navigate between earlier entries.