Now in the 21st century computers have graphical user interfaces (GUI). However if something goes wrong, you can find yourself in front of a text console and now?

Additionally embedded devices can have Linux inside and offer a console! Dedicated PC's for servers, routers, or multimedia boxes should not have too much functionalities for reasons of security and maintenance effort, therefore a text console for maintenance might be the way to go.

It is not the idea here to give a complete list of all commands, this would create a book on itself and would not be very useful, since simply typing man <command> does it better. Knowing the commands, bash scripts can be written.

Midnight commander

The midnight commander mc is similar to the DOS Norton Commander.

To have mouse support start gpm and use a terminal that can deal with this as xterm

When working under X11, use terminal that supports the mouse as konsole.

lxterminal does not support the mouse and conflicts with the F10 key. However the F10 key feature in lxterminal can be switched off.

To enable exiting to latest working directory, put this into your ~/.bashrc

 . /usr/libexec/mc/

Text Web browser Links

In text mode you can even browse around the Internet and download files using links the text based web browser. Within links press ESC to get the menu. An other text based browser is lynx. To download something from the web use wget<url>


to show contents of a text file. Use cat instead of opening files in /proc

cat /proc/cpuinfo (shows you the bogomips of your computer)

Since such files are not real, they can crash a text editor => result text editor will never finish to open the file.

Copy this into a shell and type return

cat > << "EOF"


echo "Hello World"


Now you have a file and run it:


Looking at the details, since no input file is given cat takes the console and routes it into the output file until EOF is read.


change directory.


is the copy command. The

cp -arT <directory 1> <directory 2 >

copies directory 1 to directory 2 and makes an exact copy including subdirectories, links, owner rights.

Important options are:

-p (preserve) to keep owner timestamp and so on

-r (recursive) to copy also contents of subdirectories

There is also rcp (remote copy available).


Cut can be used to cut out text coming from a pipe. It can therefore be used to format things derived using grep. A line of text is considered to have text fields with the TAB delimiter. The -d option allows to use an other character as =. The -f <n> defines the field not being cut (n>0).


Per default dd reads raw bytes from stdin and writes them to stdout and allows some formatting and conversion. The dd options if and of are passed to read from a file and write to a file instead.

Instead of reading a file also a device can be given, so commands as:

dd if=/dev/hda3 of=/backup/mybackup-07-July-08-hda3.bak.dd

write an entire disk and save them to a file.

A classic example is reading the master boot record:

dd if=/dev/hda of=/backup/mbr.bak bs=512 count=1

and restore it:

dd if=/backup/mbr.bak of=/dev/hda bs=512 count=1

Often dd is also used for other kinds, when the whole data has been read see MD5 checksum verification.


To find a file

find <path where to look> -name <filename>

But also other criteria than the file name can be selected. Look for files in the users directory that belong to root.

find ~ -group root

Look for files larger than 100MBytes

find ~ -size +100M

To see files in home directory that got modified within the last 10 min

find ~ -mmin -10

To see files created more than 1 year ago

find ~ -mtime +365

To see files accessed more than one year ago

find ~ -atime +365

And now a challenge

find /usr/bin -type l ! -xtype f ! -xtype d -ok rm -f {} \;

It looks in the /usr/bin directory and makes some tests, since no operators are given all test have and operators meaning all test need to be true. -type l tests if the file is a link. The following tests need their result to be inverted, this is done with the ! sign put in front. So ! -xtype f gets true if the link found by -type l does not point to a regular file and -xtype d if it does not point to a directory. Finally -ok<command> ; runs a command requiring the user to confirm it with a y. The {} characters are replaced by the file found. The \ character is an escape charter to prevent the shell to interpret the ; character.


lets you print out just certain lines of a file. Example find errors in /var/log/Xorg.0.log

grep -n3 "(EE)" /var/log/Xorg.0.log

or in a combination wit cat

cat /proc/cpuinfo | grep bogo

Or to find in files grep -rnw '<path>' -e '<text>'

The options are:

Table 2.1. grep

n number of lines before and after to be printed
C As n but without line number
A number of lines after to be printed
w Match whole words only


to list the stuff in a directory.

ls -l or ls -la including hidden files

gives you a nice list with file details. The first character identifies what it is:

- regular file

d directory

l link

p pipe (or FIFO)

s socket

c character device

b block device

To list all files and directories that have the name ebuild and go recursive into the subdirectories:

ls -R Urs/ApplicationData/overlay/ | grep ebuild

This are two commands connected via pipe, the ls command prints everything out and the grep filters.

more or less

Commander Data from Star Trek does not need the programs more and less, since he is able to read faster than the computer puts text on the screen. He would type cat /var/log/Xorg.0.log and would be able to read and remember all the lines.

Regular human beings would miss the first lines, so they can type:

more /var/log/Xorg.0.log or less /var/log/Xorg.0.log. The command less is more advanced than the command more and therefore called less, it allows you to scroll back. Q quits from everywhere. Both more and less can be used with other programs as. An other example how to use less:

ls /dev -l |less

Note to the insiders: The program man is configured to use the program less.

An alternative is using a video camera and record a movie on the things that come to the screen too fast. It is the only way to get the text that BIOS puts to the screen when it boots.


Move files or rename them. The -f option allows to overwrite files that have the same name.

rm and rmdir

Two different commands exists:

The command rm removes files what basically means delete them. A useful option is -i that asks before it does the delete.

To delete directories, the directories must be empty before rmdir removes them. There is the --ignore-fail-on-non-empty option to make the damage.


strings - print the strings of printable characters in file. It is a hacker trick to find e.g. expected paths in programs.

strings /bin/bash | grep


Shows where bash expects the bashdb scripts to be.


Tail can be used to see the last lines of a file. It is useful to observe what the message logger writes:

tail -f /var/log/messages


time <command> executes <commend> and returns the time it used.


To see about your computer (Linux, cpu, ....) type:

uname -a

Linux sempron 2.6.21-gentoo-r4 #1 SMP PREEMPT Mon Jul 23 09:11:32 CEST 2007 i686 AMD Sempron(TM) 3000+ AuthenticAMD GNU/Linux

Or to see just the Kernel version

uname -r


and might be used in script programs dealing with the kernel.


Watch executes a program periodically (default 2 seconds). Example to see live what is going on watch grep \"cpu MHz\" /proc/cpuinfo.

Linurs Hosttech startpage