Mandrake Linux tips for free
Because the best things in life are free

Home Switch with success Acquisition Installation Configuration Learning to use Linux Links About Contact

Google
Search: Mandrake Linux Tips for Free WWW

About the command line interface, console, terminal, x-term, shell,..,..

Index

Background info about the shell
Filesystem and structure
Using bash
Useful shell commands and programs
The standard text editor vi that everyone loves to hate
About processes, background, foreground, the ampersand "&"

Note:
commands to type have this colour and font
keystrokes/presses have this colour and font
cli = command line interface
lmb = left mouse button, mmb = middle mouse button, rmb = right mouse button

The linux shell -- some background information

This first section holds some theory, the rest explains on how to give the system commands. Since there are a lot of things that you can/need to use at the same time, and I´m not writing this as a linear tutorial, you are welcome to jump back and forth in this page to whatever interests you.
For instance, you may want to skip this theoretical intro unless you are really interested.. ;-)
This part will explain what is meant with: the shell, the prompt, the console, an x-term, the command line interface, bash. There are suble or not so subtle differences between all of the aforementioned, but I will not go into more detail than I find necessary.

The shell is the part that 'hides' the core of the operating system (OS) from the user, or that what lets the user interface in the most direct way with the OS. In a way, it is one of the things that makes an OS (linux in this case) useable. The OS basically takes care of all data flows, if you write a file to disk, rename a file, etcetc. The programs or processes take care of the processing of that data. Of course, the processes and programs also run on top of the OS. For instance, a word processor offers the user an interface to adapt a document, and the underlying OS offers that program a platform to display, store or print that document.
Instead of a program, that lets the user manipulate files and start processes or programs, the user can talk to the OS via the shell to have certain tasks executed.
For those who were happy to see the DOS prompt disappear this might seem a bit backward, why typing in a black and white box if any decent/recent computer can easily display all information graphically?
Well, firstly, the standard linux shell is not really to be compared to the old DOS prompt in the sense that it is much more powerful and useful.
Secondly, by using a shell, there is much more information displayed in case something goes wrong, which can then help you figure out how to fix things (as opposed to a box that pops up and says: general error); especially in case a program doesn't even start up, or you have no sound (example of my win-tv card under win98se, works fine, but no sound... beats me why, and can't be bothered anymore).
Thirdly, some things are really much easier done with a shell than graphically.
On the other hand, people that have never used the shell, and don't want to can get by without any problem with any linux flavour that is properly set up.

I mention 'the shell' here, but in fact there are different flavours of (UNIX) shells, the bourne shell, the korn shell, the c-shell (note the pun :-), the tc-shell, the bourne again shell (which is the default one in linux), the z-shell. These are normally abbreviated as follows: bsh, ksh, csh, tcsh, bash, zsh. The differences are quite subtle; some commands are different, scripts written for one shell don't usually execute (or unexpectedly) on another shell. Just stick with the basic shell on linux, bash.

The console is basically a shell, but often the word console is used to indicate that it is without any kind of graphical interface, so it really looks like the good old DOS machines. Try a ctrl-alt-F1 (or any F-key from F1 to F6 actually) once linux is up and running, and ctrl-alt-f7 to get back to your graphical desktop; you can have graphical desktops from F7 to F12, contrary to more popular systems that allow you 1 (one) graphical desktop at a time, and no console.
Prompt is the word for the blocky cursor indicator, that shows you where you will type next, and often is used to refer to the DOS prompt as opposed to the windows graphical environment. Needless to say that linux has a shell with a Command Line Interface, instead of DOS with a prompt.
An x-term is a shell in a window, so on top of a graphical environment.

Useful shell/x-term features:

  • x-terms usually have scrollbars, so you can scroll back up to see what was written before; this is not possible on the console (ctrl-alt-F1).
  • the shell has a notion of history, if you use the arrow-up key (or page-up), you will find the last command repeated on the command line. Bash keeps track of all the commands you execute in the history list, which is limited to 1000 commands. You actually find this list in your home-directory in the file .bash_history. Use page-down or arrow down to move through the list in the other direction
  • the cli/command line interface can be edited, meaning that you can actually use the home-key to jump to the beginning and the end key to jump to the end of the line
  • you can resize x-terms so that you see more of the output
  • bash has tab completion, meaning that once you type the beginning of a command or filename, followed by the tab-key, bash will try to finish the word/term by whatever it thinks you could mean to write. If there is only one option, bash will fill this in; if there are several, bash will show them. If there are more than 50 (or 100?) bash will ask you if you really want to see all options before clogging up your x-term or console.


File system and structure

File system
What you need to know is that linux has support built in for several file systems; normally ext2 or ext3 are used to install the system on. If you want to know more about that, just surf the web; all I want to say at this point is the following:

  1. ext3 is a journalised filesystem, so it is to be preferred over ext2; basically 'journalised' means you normally don't have to run a lengthy diskcheck program in case your computer was not cleanly shut down.
  2. it is not necessary to defragment ext2 or ext3
  3. Full partitions are a sure guarantee for system instability (this goes for any Operating System)!

File structure and general notions of file paths
Linux uses a very logical and straightforward (well, more or less, there's naturally plenty of things to criticise) file structure. If you want to know more about it, read this; you may also want to read the page before (general intro) and after that one (about the /etc, /home, /var directories).

For now, I'll just say that all user files are in the home directory of the respective user,
/home/[user] and that the beginning of it all the the system root directory: /
Suppose my login name is artee, then all my data is in /home/artee. As long as I'm logged on as user 'artee', the directory tree /home/artee can be replaced by the character ~
For instance: suppose I have a folder (directory) in my home dir (=folder = directory) download and in that directory the file Mandrake9.1disc1.iso, then the absolute 'path' of that file is: /home/artee/download/Mandrake9.1.disc1.iso but it can be referred to by user artee as ~/download/Mandrake9.1.disc1.iso
As a relative path, if I'm in my home dir (/home/artee), I can refer to that file with download/Mandrake9.1.disc1.iso. Basically, any indication to a file or directory that starts with "/" is an absolute path (including ~/ since the ~ stands for /home/[current user] ).

Complicated? Confused? Take your time. You will gain it back tenfold once you get the hang of this!

One more thing about the directory structure you need to know: the . (single dot) indicates the directory you are in, and the .. (two dots) indicates the directory one level up (towards the root / ).
So if I have another dir in my home dir with the name "My Documents" containing the file "mywebsite.html" and I am in this 'My Documents' directory, I can refer to the file in the download dir by the expression ../download/Mandrake9.1.disc1.iso since the .. (two dots) indicate one dir up (which is my homedir), and then download indicates the dir where the file resides.

The single dot "." is used to indicate the current directory, which can be necessary to execute scripts. This is actually a security measure that you can never execute scripts in a dir that you are currently in.

File properties
One of the things that makes linux and other unixlike systems less sensitive to viruses is the way files are tagged. Each file is tagged with (amongst others) the following information:

  • the file owner
  • the file group
  • whether the owner, group or anyone who has access to the file can
    • read,
    • write/append to/delete,
    • or execute the file
  • stuff about the date the file was created, when it was last accessed etc.
The property that makes the file executionable or not is not set on any file that is recieved, be it via email or ftp. So all viruses that are normally sent via email cannot be executed even if they are perfectly good shell scripts that would actually delete all files the user executing it has write access to.
First the file would have to be made executable. Some people may find this unnecessarily complicated, they would prefer to receive files via email, then click on them to execute them. These are often the same people that cry when they lose all their files due to a virus. It is much easier to force users to pay attention and only make those files executable that you really want to execute (and that you know are safe), then to install virusscanners, keep those up to date, have them slow down your multi-gigaherz system needlessly etc because your system is vulnerable due to bad user actions.

The property that makes a file writable (giving the user the right to delete or modify its contents) is usually only set for the owner. This means that when user A on a system is stupid enough to make malicious code (like a virus or so) executable, that code (running with all the abilities of the user executing it) can only harm those files that that user has write-rights of, and it can only read files that that user has read-rights to.
If you are the only user on your system, there´s only a small difference; ok, as a user you stand to lose all your own data, but not the system files -- no need to fear you have to reinstall if you were to be stupid enough to run malicious code, but you did lose your personal data.
But now imagine that you aren´t the only one using that one particular machine (as happens so often in families, where the kids wreck the machine, or mom gets an email virus that she executes without knowing etc), all data from all other users, plus all system data is safe from harm. You could even make an extra user that you can use to run code that you don´t trust 100%...
In fact, this is exactly what happens with for instance web-servers or deamons; they run under a different user, and so are normally not capable of destroying the system or user data.
Maybe not less important is the fact that different users sharing the same machine cannot read each others data (email or files) unless they tell the system that the other should have read-rights to those particular files.
In short, the linux filesystem is intrinsically a multi-user oriented system, which makes it both less vulnerable to viruses and easier to set up for several users.
One more remark: the linux filesystems are case sensitive, so the following files are different and can exist next to each other without a problem: FileOne, fileone, fiLEonE, (etc).
Below I will explain the commands to view and modify (some of) the file properties.


Using bash

As I have mentioned before, the standard linux shell, bash, has some interesting features that make it very userfriendly, once you get to know it. In fact, once you have learned how to use it, it will become (in some cases) the preferred tool for the management of your linux system, since all other ways (with graphical tools) will not give you the refinement you may want.

Tab-completion
Bash (like many other shells) has a feature called tab-completion. This means that at any point of typing a command or filename (also a filename as an argument to a command), say after 2 or 3 letters, you can hit the [tab]-key, and bash will either finish the command/filename for you, or show which different possibilities start with the characters you have typed.

History
Another feature that is really handy is the history, which I use mostly by typing the arrow-up key, which then puts the former command on the command line. You can keep hitting that arrow-up key for quite a bit (it stores 1000 commands, also from previous sessions, so when you have just booted the system, you can do arrow-up to go back to the last commands used in the previous session, before you shut the machine down)... Arrow-down takes you back and ctrl-c puts you back on a clean line. Note that you can use the page-up and page-down keys instead of the arrow-keys.

Wildcards
The most common wildcard is the asterisk: *
It can be used to substitute any string/sequence of characters, including zero characters. This in contrary to the questionmark, ? which substitutes any single character.
If you have the following files in a directory:
test, test1, test2
then the command to delete them could be:
rm *
(see below for the syntax of rm ) but that would indicate any file in the working/current directory. You could try:
rm te[tab]
which in case there are no other files starting with te bash will complete to: rm test
followed by all options that are still open: test, test1, test2
If you want to delete all three files, you can just type the asterisk and hit enter:
rm test*
If you would use:
rm test?
this would actually exclude the file test so bash would only delete test1 and test1.
Other wildcard possibilities are the use of ranges: [0-9] indicating any number from 0 to 9; in the light of the former explanation, you could type:
rm test[1-4]
if you would want to delete test1, test2, test3 and test4. This also works with [a-z] or [A-Z].

Escape character
The character: \ is known as an escape character, you can use it in file/directory names that contain spaces and other special characters:
cd My\ Documents
Alternatively, you could put the file/directory name between quotes:
cd 'My Documents'

Keyboard shortcuts
To stop any running task (running in foreground, see also below), use ctrl-c
You can also use this if there is something on the command line that you don´t want to execute, ctrl-c will let you jump to a next, clear line.
To logout (for instance, if you logged on as another user with the su command) you can use ctrl-d. If you are using an x-term (in the graphical environment) and you didn´t log on as someone else, this will close your x-term.

Go here: http://tille.soti.org/training/bash/book1.html for more info about bash, scripting etc.


Useful commands

I use a different font and colour to indicate what are things you actually have to type into the shell, and words between brackets: [terms] to indicate where you have to fill in what is applicable in your situation.
Note that due to the meaning of the dot [.] I will often not end the sentence with one, to avoid confusion about whether it is part of the command string.
I will give a very short description and an example of how to use the following commands in this format:

command
Used for ...
common use/example:
command -options [file]

The most important command (well, arguably):
man [command]
To find out how to use the command [command], what options it has etc. Actually, man is short for manual or manual page.
Common use: man ls
BTW hit the key q to exit the manual page reader.
One of the (perceived) downsides of linux is that the output of the man command is scientific, and therefore needs getting used to. Once used to it, however, it is a very powerful way of implementing online documentation. If you are running a graphical environment, you may want to try putting the following in konqueror:
man:
and then browse the commands. By the way, read about the character "&" below.
Also, if any of my explanations below are not clear to you, don't hesitate to do man [command]
Another system is being put in place: info [command] so you can give that a try too.

File related commands:

ls
Used to get the listing of the files in the current directory. Shorthand versions are: l, ll
ls -alrt (equivalent of ls -a -l -r -t) to get the listing of the current directory, including all hidden files (files that start with a dot [.] these are normally hidden) with (almost) all properties, sorted in reverse order of time of last modification. Note that the options -l -a -r -t can be concatenated together as -alrt or -lart or any other order.
ls -ld [dirname] to see the properties of the directory [dirname] instead of the listing of the files inside it.
ll [filename] (or: ls -l filename) to see the properties (read\write\execute, owner, group, filesize, date and filename) of [filename] such as:
-rwxr-xr-x 1 artee family 1423 Feb 5 22:50 testfile
Meaning: the owner is user artee, the group is family (usually, the group is the same as the user on linux systems, I just changed it as an example). From the first part -rwxr-xr-x you can make out the following: the first character is used to indicate whether the file is a directory, link or special character (used much for devices), the following three indicate the owner rights: -rwxr-xr-x mean this file is readable, writable and executable for user artee, -rwxr-xr-x mean it is readable and executable (but not writable) for all members who are in group family and the last three characters -rwxr-xr-x mean that anyone else who can get to this file can also read and execute it. See also chmod to set the rwx flags, chown and chgrp to change ownership and group properties of the file or directory.
ls -ulrt lists the current directory reverse sorted by access time.

cd [dirname]
Change working directory to dirname. Without any argument takes the user to his own homedir, meaning: if user artee executes it the working directory will become: /home/artee
cd ..
goes one dir up.

mkdir [dirname]
Used to create the new directory [dirname] in the current working directory. Can also be with a whole path:
mkdir /path/to/newdir
supposing that /path/to/ exists; or
mkdir -p /path/to/newdir even if /path/to exist or not (if not, they will be created).

rmdir [dirname]
Used to remove the (empty) directory [dirname]. If the directory is not empty, but you want to get rid of it anyway, including all contents, try rm -r

mv [filename] [newfilename]
or:
mv [filename] [directory]
The mv command can be used to rename files or to move them to different directories. [filename] [newfilename] and [directory] can be relative or absolute paths, as in:
mv /home/artee/test.html /www/artee/
or
mv test.html /www/artee/index.html

cp [filename] [newfilename] To copy files, use the command cp which works quite like the command mv
cp -p [file] [newfile] lets you keep the properties with the file, such as owner, group, last time of editing and last time of access.

rm [filename]
To remove files or folders.
rm -f [filename] to force the remove action without any question; rm -rf [filename] to remove a whole directory with all its subdirectories and files, without having the shell ask if you are sure about what you are doing. To be used with caution, and at your own risk!

cat [filename]
To see the contents of a textfile inside the console. If you want to easily scroll back and forth, less is to be preferred.
cat > [filename] can be used to put anything you type after this command into the file [filename] which, in case it exists is overwritten, so be careful. Stop puttting text into the file and return to the shell with ctrl-c
cat >> [filename] can be used to append anything you type after this command to the file [filename] which, in case it doesn´t exist, is created. Stop puttting text into the file and return to the shell with ctrl-c

less [filename]
Prints the contents of the (text) file [filename] to the shell, allowing the user to scroll back and forth and to search. Exit this mode by hitting the key q. You can search the file for strings by typing /searchstring followed by enter, and if you want to search for the same string again, just type / followed by enter.

chmod -options [filename]
Change properties of [filename]
chmod +x [filename] to make the file executable, -x to make it not-executable. Same with +w, -w, +r, -r. For limited writability, use for instance: chmod a-w filename (a=all, -w=not writable) to make a file not writable for any user, or chmod a=x filename to make it only executable for all (so it can´t be read nor written/modified/deleted), or chmod g+rw filename to make it group read- and writable, or chmod u+rwx filename to make it user read- write- and executable.

chown [user] [filename]
Change ownership of a file; you must have write-rights to the file to be able to do this. Note that if you give away a file in this way, you may not be able to delete or edit it anymore, depending on your rights as a user and what group you and this file belong to...

chgrp [group] [filename]
Change the group property of a file.

find [path] [expression]
The command find can do much more than find files with certain strings in their names, but that´s how I mostly use it.
find . -name *.png -type f
for instance will find me all files that end with .png in the directory I´m in (the dot [.] indicates this) or in any subdirectory.

ln -s [target] [linkname]
Somehow not always as intuitive in the order of the target and new linkname, ln lets you make a link (with -s a softlink, that is to be preferred over making a hardlink, which you could make when using ln without adding the -s... but shouldn´t because I told you so.)
You can tell if you succeeded by doing a ll [linkname] which should then show clearly that it´s a link to [target].

pwd
To know where in the system you are you use this command, which is short for print working directory. The system will respond with the whole absolute path.

System related commands:

su - [username]
Set user (su) lets you change user. It will ask you for the password of [username] after which you can then operate with the rights of [username]. Note that this is often used to issue commands as the root administrator. In that case you can use the shorter version of this command which is just su
The root user is in many system related commands the only user who can issue them. Be careful with what you do as root, since you can actually do as much damage to the system as a windows virus can do to a windows system... Be warned!
Note that as root, you can su to any user without having the system ask you for a password.

top
This will give you the current tasks that the system is working on, sorted by process ID (PID), user, % of cpu time the process is currently using and total accumulated system time the process has had sofar.

free
To see how your memory is being used, use free
If you notice large amounts of swap being used, increasing your system RAM would be adviceable. On the other hand, if you don´t see any swap being used, an increase of your system RAM will not do anything for the speed of your computer. Even at times where RAM is dirt cheap, not buying it will always be better on your expense account...

df -h
Of course you can use this command without the -h (human-readable), but it´s up to you to decypher the results then... Anyway, this gives you the usage of all mounted devices (basically: your harddisk partitions, mounted NFS network drives, cdroms etc). As I mentioned before, no Operating System functions well if it´s running out of diskspace. So make sure it doesn´t.

du -s .
To see how much diskspace the current directory is using, including all subdirectories, and the -s means you just want the end result (if not, all files and subdirs will be listed with their respective size).

mount [device] [dir]
Mounts a device like a cdrom onto a dir in your filesystem (which must exist, it doesn´t get autocreated or so). Not necessary to mount a cd/dvd since the advent of supermount, but very handy to mount the .iso images (that you kept on the harddrive) of the linux version you are using if you want to install some programs from them:
mount -t iso9660 file.iso /mnt/cdiso -o loop will mount the file.iso onto /mnt/cdiso so you can then just do ls /mnt/cdiso and find the contents of your cdrom image, completely readable. I use this with:
mount -t iso9660 MandrakeLinux-9.1rc1-CD1.i586.iso /mnt/cdrom -o loop
is what I use when I install extra programs that are included on the 3cd download version of Mandrake, so I don´t have to fetch the cd and put it in the drive...

umount [dir]
Use umount (note that the ´n´ is missing from the word unmount....) with only the directory where you mounted something to unmount it.

lsof [mounted mountpoint]
Shows who/which process is using a mounted device/filesystem, which could be blocking your attempts to unmount it.

urpmi [program]
If any website tells you to execute a certain command or use a certain program, and the system responds to you ´command not found´ it may well be that you don´t have it installed. As root use the command urpmi [program] to have the system install the program for you (assuming it is known to the system). In case [program] could mean more than one option, the shell will show you the options. Also, it will solve any dependencies for you, asking if it´s ok to install all other packages that [program] depends on. BTW I prefer to use it with the noclean switch: urpmi --noclean [program] so that it doesn't delete the downloaded files (if any).

ps -fu [user]
This lists the processes that are currently running for/initiated by [user]. The first column is the process ID (PID) which you can use with the command kill

kill [PID]
If you see a process that´s going wild, hogging all system resources etc, your processor load is at 100% when it shouldn´t be etc, use the command kill. Make sure the program really should be killed and cannot be made to stop in an orderly manner. kill -9 [PID] is a stronger (the strongest) way to tell the system to finish off a process.

who
Tells you who is logged onto the system.

which [command]
Tells you the location of [command].

whereis [command]
Much like which, this tells you the location of the binary, source and manual page of [command].

whoami
Tells you as what user you are currently known to the system (so you know what rights you have etc.)

Auxiliary commands:

One thing that is nice to use is the pipe | (next to the enter-key on most keyboards), to send the output of one command to another command. Some examples will follow that use this.

grep [string]
Use grep to find a certain string (line containing a certain string), can be useful for instance with ps to find the process status:
ps -fu [user] | grep mozilla
will show you if [user] is actually running an instance of mozilla (and if so, how much system time it is using etc).

wc -l To count lines, use wc -l and to count words use wc
cat [textfile] | grep [string] | wc -l for instance will tell you how many lines in [textfile] contain [string].

head [textfile]
To quickly view the first 10 lines of a textfile use head
Use head -c 50 [textfile] to get the first 50 characters (bytes really) or head -n 25 [textfile] to get the first 25 lines.

tail [textfile]
To get the last ten lines use tail, and use tail -c 50 [textfile] to get the last 50 characters, or tail -n 15 [textfile] to get the last 15 lines; for logfiles that are actually written to while you read them (for instance the logfile from wget, a download program), use tail -f [textfile] (-f=follow) (stop with ctrl-c).

export [variable]=[value]
Certain variables are set in the shell to a certain value. The ones I use are DISPLAY and PATH; the DISPLAY variable is used by the shell to determine onto which graphical display/xsession/xserver a programwindow or graphical output should be opened if started from the shell, and PATH contains all directories where the shell will look for executables.
export DISPLAY=:1
makes sure any program or command with graphical result (executed in the shell where you set this variable) will be redirected to the Xsession 1.
export DISPLAY=othermachine:0
takes you to the realm of unexpected possibilities, since this allows you to output the graphical results from one machine on the display of another. More precisely put, I can logon to a remote machine over the network and have that machine run (for instance) a cd-burning program (suppose it has a burner, and the machine I am working on doesn´t) that then gets displayed in my graphical session, so I can just click the right buttons etc to burn the cd.
export PATH=/home/artee/scripts adds /home/artee/scripts to the paths where the shell should look for executables.

echo [string] will actually just have the shell write [string] on a new line. But you can use echo to tell you to what values the shell variables are set: echo $DISPLAY and echo $PATH

Other useful commands and shell programs:
Just use man [command] to find out how these may be useful to you: lynx, wget, ncftp, rpm, tar, bunzip2, bzip2, gzip, gunzip, ping, ftp, ifconfig, hdparm (note that installation of hdparm on mandrake 9.0 leads to your cd-burner DMA being turned off, this can be fixed easily)

And one of my favourite commands ever...
fortune
gives a random quote, funny, philosophical, stupid or whatever. To be used with the arrow-up for easy repetition...

Text editing on the console

Console text editing usually means you´re going to have to use vi. In the early days, I used to say I didn´t like vi, and that it didn´t seem to like me...
Now I learned to live with it. If you can avoid using it, feel free. I think it is handy to know the few things that are needed to be able to use it in a minimalistic way, just to edit a file, change or add something simple.
Vi is an editor that works in the console, you use it by entering: vi [filename] which then opens the text in the editor. The next thing you need to know is that there are 2 modes in vi: insert (edit) mode and command mode.
In insert mode you can edit the text, anything you type will appear as usual at the prompt.

In command mode, you can delete whole words, lines, search for strings etc. You can even write one-line shell scripts. for instance to get text from another file into the buffer. I won´t go there (actually I have never done that, not needed it and not felt the need to figure it out...).
Whenever you are in insert mode, you can go back to command mode by hitting the escape key; hitting it more than once doesn´t hurt and many unix/linux users seem to do this, probably to blow off steam.
In insert mode, normal character keys will make the corresponding character get inserted, which is the point. If your mouse is working, you can copy-paste as usual (select/copy with lmb, paste with mmb). Remember that pasting always happens where the cursor is, you cannot displace the cursor with the mouse.

When in command mode, you can get into insert mode by typing i or a (insert or append), where insert will let you write in front of the character that the cursor is on, append will let you input text after the character that the cursor was on.

Other usefull command: dd to delete the whole line, x to delete the character that the cursor is on, /{string} to search a string and jump to it, /[enter] to search again for the same string, :q! to exit without save (yes that is colon-q-exclamation mark), :q to exit, :w to save/write, :wq to save and quit.

Use page-up/page-down to go up and down, arrowkeys, [home], [end] to navigate etc. There are keys/keystrokes to jump one word forward or back, but I won´t bore you with that.

There are alternatives to vi, for instance pico (part of pine, a mailclient) and nano (much like pico), easier to use for the new user, but not always present, and also, vi is not that hard. Just accept that it´s different. (Btw most power users claim that it is one of the most powerful tools available. Me, I just learnt to live with it and survive...:-)


Foreground and background

The programs and commands you launch from the shell or console are normally directly executed by the system. Some programs, like top give continuous information, and they will occupy the whole shell, for all the display space you give them. Some others, for instance wget don't necessarily give information that you want to see directly, you may just want to continue using the shell/console for other things. wget is a download client, and it may take some time before it finishes (depending on the size of the downloaded data and the speed of your internetconnection etc), so you may just want to start this program from the cli without wanting to wait for it to finish. In that case, you have to start it in the background; this is done by appending the character "&" after the command: wget& (which more precisely you would use like this: wget -a [logfile] -i [file containing ftp links] & )
(Note that you don't need a space between the & and the former characters.)
Sometimes, you forget this; you may try to temporarily suspend the process that you just started without the "&" by typing a ctrl-z in the shell window that started it, which the shell should answer with: [3]+ Stopped (supposing the command you started was the 3rd one, but never mind that number..) and then typing bg in the shell. Now the shell should say: [command]& to indicate that that process has been continued in the background. (Use fg to resume the process in foreground.)

Processes/programs like top that are meant to give direct information to the user cannot be run in background, they must always be executed in foreground (they would be quite useless in background, since they are the tools the administrator uses to check on the system).


Valid HTML 4.0!

Page first created: Feb 2003. Page last updated: Nov 30 2003

Pages tested with but not specifically made for: lynx, konqueror, galeon, Opera, Mozilla, Firefox using OpenOffice.org, Bluefish and the Gimp on Mandrakelinux by aRTee
All contents © copyright 2003 and 2004, unless mentioned otherwise, published under the GNU Free Documentation License (FDL) by aRTee. Artwork and CSS don't fall under the FDL, standard copyright applies. Tux image from Larry Ewing. You may use anything published under the FDL on this site freely, as long as you include a reference to the main address of this site: www.mandrake.tips.4.free.fr.

Site-counter Mandrake Linux Get counted! Get native linux games here! Get Firefox!