main | UNIX notes | Advanced UNIX | links

UNIX/Linux Applications

Last change: Dec 16, 2005 AD


command - directly may be typed
filename - replace by your own value
[] - text in the brackets is optional


NOTES about applications

List of useful applications

See also "Interesting Applications under Windows & Linux".

.> Net <.

Communication on-line

.> Graphics & Multimedia <.


Multimedia, Audio/Video

.> Config.& analytic tools <.

.> Other utilities <.

Desktop utilities

.> Programming <.

.> Office <.

.> Security <.


Not all are installed on all systems. Ex.Running nedit
$> nedit


ghostview - .ps and .eps files viewer


Motto: "Do you need something? Go to!"

GNU Project - development of free software for unix-like systems (see
Some GNU supported programs: gimp (like photoshop), gpaint (like Paint), gzip & tar - compression , Midnight Commander - file manager and much more (libraries, languages ...)


Program for ploting graphs. Run it by typing 'gnuplot' in the terminal command line.

Front-ends: UnignuPlot, xgfe.

To plot the graph, type command plot in gnuplot, followed by the name of the input files in single quotes, separated by commas.

gnuplot> plot 'input-file1', input-file2'

Input: a text file containing input values (one value per line). This will be on the y axis, on the x axis will be number of the line in which the value appears (0 for the 1st line etc.)

Ex2: file 'input'

In the graph, there will be points (x , y): (0,10), (1,20), (2, 15), (3, 30)

To have all files in one graph, just type 'w l' behind the file name:


gnuplot> plot 'file1' w l, 'file2 w l
If you want to print the graph, you can store it as a postcript file, if you write following commands before ploting the graph:
gnuplot> set data style lines

gnuplot> set terminal postscript

gnuplot> set outpout 'myfile.eps'
Where myfile is any name you wish. When you finish, just type command
$> ghostview myfile.eps
in the terminal's command line (supposing, that myfile.eps is stored in the work directory).


gcc and g++

Compiler for C. See manual (man gcc) or g++ is used for C++ (gcc doesn't work here sometimes).
Compiling program that is spread into more files: suppose I've some functions in the file 'library.c' that I want to use in the file 'main.c' (which aslo includes the function main() and, of course, appropriate header file: '#include "library.h" '). To create directly binary executable file:
1. $> gcc -Wall -o myprogram main.c library.c
Output: executable bin. file 'myprogram'

If I want only to compile the library, I must use flag '-c' (which tells gcc that it should stop after creating object file without linking it; otherwise you get a strange error, st. like "fatal ... symbol missing ... main ").
2. $> gcc -Wall -c library.c
Output: object file 'library.o'
If you want to make the executable file, type
3. $> gcc -Wall -o myprogram main.c library.o
(Note the suffix '.o')

Final notes: the flags '-Wall' and '-o' followed by 'myprogram' may be omitted. The former tells gcc to print all warnings (-Wall), the latter specifies the name of the output executable file (otherwise it would be a.out)

Explicit language:
If you don't want gcc (g++) to compile a source code according to its suffix (.c for c, cc or cpp for c++ ....) you can use flag -x followed by the language option (c++, c ...). To compile myfile.c as c++:
$> g++ -Wall library.c -x c++ myfile.c
Note: library.c is compiled as c file, because it's before the -x flag.

- if you want to use C and C++ files together, compile them both using g++, otherwise you'll have problems
- Third party libraries: if using such libs, it's not enough to have "include" in the source; you have to tell to the compiler to use the library (-l flag). For example for compiling a program that uses X Window System library Xlib (assuming it's in the path; X11 indicates Xlib. Confusing, I know ;-):
$> gcc -o xmyprogram xmyprogram.c -lX11


gprof - GNU tool for profiling


ld linker

man ld reads:

The linker will search an archive only once, at the location where it is specified on the command line. If the archive defines a symbol which was undefined in some object which appeared before the archive on the command line,the linker will include the appropriate file(s) from the archive. However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again.

See the -( option for a way to force the linker to search archives multiple times. You may list the same archive multiple times on the command line.

make & gmake

This utility (make; gmake is a better and smarter version of make by GNU) is very useful when compiling large projects. It uses information on dependences in 'makefile' or 'Makefile' (stored in the working directory) and executes appropriate actions.See links for more information.
Example- suppose following Makefile:

myprogram: main.c library.o
gcc -Wall main.c library.o
library.o: library.c
gcc -Wall -c library.c

When you run 'make' from the directory that contains Makefile, library.c and main.c (and also library.h), it does exactly the same as the sequence of commands 2. and 3. from the prevoius section (gcc or g++). One of the advantages is, that it first checks whether the file was changed since make was called the las time, and only if it was changed, the actions is executed (in other words, it doesn't recompile files which haven't changed, but only the changed ones => saves time).
Important note: before a command (e.g. " gcc -Wall main.c library.o" in this case), there must be TAB and nothing more/less (press the key 'tab' before writting the command.). Before anything else there can be nothing(?)

- make has very strange requirements on the input files (if you use TABulator at the wrong place ....) and hence gives sometimes indeed strange errors. In such case, try to use gmake.
See also
-Imakefile and xmkmf (generates Makefile from Imakefile). Some info should be at GNU homepage.

Advanced features of Makefiles

Makefile syntax:
VARIABLE = content
target: list-of-dependencies

Make starts processing a file at the target specified as a command line option ($>make mytarget) or at the first target (reading the file from the top).
Target may include wildcards, for example "%.class: mydirectory/" states that any .class file is dependent on a .java file of the same name (if there is "%" more times in the same dependency, it always means the same string), which is located in the directory mydirectory/ (with respect to the directory including the Makefile).

List of dependencies
consists of filenames and names of other targets separted by a space. May contain wildcards as well as variables. May be empty.
Ex: all: maintarget main.c main.h ${OBJECTS}

A command must be preceded by TAB (if it is the 1st one, see above).
Command is any shell command and may include any Makefile stuff like variables, wildcards etc. (Command may be ommited.)

Some wildcards
% - matches any string, if it is more times in the same dependency, it always have the same value
$< - refers to the dependency list that was matched by the rule

CFLAGS = -g -o
%.class: mydir/
javac $(CFLAGS) $<

Assume you have the files "" and "" in the directory "mydir/". This dependency than will be the same as the following :

main.class: mydir/
javac -g -o mydir/

test.class: mydir/
javac -g -o mydir/

Variables (also known as macros)
Before make starts "executing" the makefile, it first preprocess it and replaces all occurences of a variable by its content (if the variable is defined as above, the replacement is recursive, i.e. you can use other variables on the left side of the assignment).
Referencing a variable: a variable VAR is referenced by the string ${VAR} (see Ex1). If you want to prevent the variable from being substituted by its value (e.g. if you want the resulting command executed by the shell to be "$ echo $MYVAR"), put another '$' in front of it: $$MYVAR.

- influence what part of the file make "sees"
- conditionals have the form cond-directive text-if-true [else text-if-false] endif
Cond-directive is one of the following: ifeq(arg1,arg2), ifneq(arg1,arg2); ifdef variable-name, ifndef var-name.
- "ifdef VAR" is false only if there exists "VAR = "
- "ifeq (VAR,) is true if the right-hand side of "VAR = ..." is evaluated to be the empty string (notice there is nothing to the right of the comma)

inlude filename - inserts the file filename into the makefile

Other links:


Very very useful graphical interface for gdb. Just try it :-) It combines the command line for gdb (with gdb) and a graphical interfece which shows the source code (and the current position in it during debugging) and let you set break points etc. just by pressing a button, and much more (don't hesitate to click, using the right mouse button, on variables, functions etc. You will see).



Debugger for C. See manual (man gdb) or or a short intro(a local copy of the one mentioned in links).
Using gdb in 6 steps
(I) 1)compile the file using e.g. gcc (if you use gcc, don't forget to use the -g flag: $> gcc -g myfile.c)
1) run gdb ($> gdb)
2) specify the program you want to debug ((gdb) file myfile.exe)
3) set breakpoints etc. (e.g. (gdb) break myfunction) (use break info to show current breakpoints, and delete N to delete breakpoint number N)
4) run the program ((gdb) run)
- useful commands: step (execute next line), next (execute next line, don't step into a function being called), finish (do 'step' till the end of the current function or breakpoint), continue (go on running the program until a breakpoint encountered), printexpression ( show value of the expression, eg. (gdb) print myvariable to see the value of myvariable)
5) finish the execution using command kill ((gdb) kill)
6) quit gdb (command quit): (gdb) quit.


Some commands

finish run till the end of a function
kill finish debugging (do not quit gdb)
set args arglist set arguments for the program before starting it
run (re)start
break where set breakpoint; where = line number | function namethe
info break display current breakpoints
delete [n] delete all breakpoints / b. number n
p myarray@count print array with count elements
tbreak where set temporary breakpoint
ignore bp# count ignore breakpoint number bp# count times

Other links:


See manual. LINT checks language semantics and syntax errors much more carefully then an ordinary C compiler (LINT is not a compiler, it's a 'checker'). It checks correctness of the program. Good to use e.g. if you want better portability.


CVS - Concurrent Versions System

See homepage (manual, quick reference). A very good brief tutorial.

If you mean it seriously with programming, you must use it. CVS helps you to keep all versions of your source codes, thus enabling you to track a bug, return to the last working source, compare the sources and more. Its basic purpose is to enable more developers to work on the same project in parallel.

Using CVS in few steps:

------------- Set up CVS & create a project

  1. Create a CVS repository, e.g. in /usr/local/cvsroot:
    $ cvs -d /usr/local/cvsroot init

  2. For comfort, set the variable CVSROOT:
    $ setenv CVSROOT /usr/local/cvsroot or (bash, sh) $ CVSROOT=/usr/local/cvsroot

  3. Createyou project (to group sources that belong together):

    1. Create somewhere a directory [tree] and enter it (its name doesn't matter since the main project directory will be called according to the projectName set below), e.g.
      $ mkdir ~/mytmp; cd ~/mytmp

    2. Import it into the CVS repository (import projectName vendor_tag release_tag):
      $ cvs import MyProjectName MyName start

    3. Delete the directory (it's stored in the repository):
      $ cd ~/; rm mytmp

------------- Working on your project:

  1. Check out the project (copy it from the repository into your working directory):
    $ cvs -d /usr/local/cvsroot checkout MyProjectName or, if you have set CVSROOT:
    $ cvs checkout MyProjectName

  2. After having finished working on it, commit (save into the repository) the changes:
    $ cvs -m "Edited by Viking." commit
  3. You can remove the project directory (i.e. its local copy) safely from its parent dir: $ cvs release -d MyProjectName

More commands

Command Description
cvs status prints status of files in the current directory (whether it's up-to-date or modified etc.)

Add a directory into CVS without checkout:
If you want to add a directory into CVS and use it immediately without the need for checking it out, it may work to check out only the "CVS" subdirectory created by cvs into the dir. in question.

What The command
Checkout a particular revision (e.g. 1.1)
(into directory ~/mytempdir)
$ cvs co -r 1.1 -d ~/mytempdir project-name/
Create a new module and start using it
(TortoiseCVS does this; perhaps it also cd into the project dir. and out as appropriate)
$ cvs import -m "msg" ProjectDir tag-vendor tag-release
$ cvs checkout -d ProjectDir
Tagging: assign the same tag to all files so that they can be checked out as a unit later on $cvs tag unique_tag_name
See what file tags are there $ cvs log a_filename
See the section "symbolic names"

$ cvs status -v [a_filename]

Checkout a particular tagged version $ cvs co -r a_tag project_name


/CVSROOTccess <a directory> / No such file or directory
You may be trying to use windows cvs files with linux client - check that CVS/Root doesn't have windows-style end of line. Run cat -v CVS/Root and if you see ^M at the end it has got windows end of line and you must convert it to linux style - see e.g. the package tofrodos.


Compares line by line 2 files. See GNU (or man) for more detailed description.
More output formats, the best is probably 'context' format (flag '-c' or ('-C' followed by a number )) which looks like( everything behind '//' are my comments):

*** 61,70 **** // the numbers mark the range of lines in the first file, which we talk about

//3 (or number) lines common to both files
// lines from the first file, marked by '-' (they are not in the second file, they were 'deleted') or ' ' (lines which are same in both) or '!' (the line is in both files, but differs)
//3 (or number) lines common to both files
--- 71,96 ---- // the numbers mark the range of lines in the second file, which we talk about
//3 (or number) lines common to both files
// lines from the first file, marked by '+' (they are only in the second file, they were 'added') or ' ' (space; lines which are same in both) or '!' (the line is in both files, but differs)
//3 (or number) lines common to both files

//END of the example

To get such output, having 2 files 'original' and 'changed' (suppose that 'changed' was created by making some changes in 'original', write command
$> diff -B -b -i -c original changed
Flags: -B: ignore blank lines (empty lines added to or deleted from the 2nd file), -b:ignore different number of blank characters - tabs and spaces, -i: be case insensitive, -c: output in the context format
Note: GNU also developed wdiff - front-end for diff.

NET Applications

PureFTPd - A FTP Server

1. Setting up PureFTPd & virtual users

  1. Create system user - I'll use virtual users (= they exist only for FTP) but for all/each of them I need one real system user and group:

    root# groupadd pureftpgroup
    root# useradd -g pureftpgroup -d /dev/null -s /etc pureftpuser # -d home_directory, -s shell

  2. Configure PureFTPd (I assume it's started via pure-ftpd-wrapper that reads config. info from /etc/pure-ftpd/conf/ - every file corresponds to one command-line option):

    /etc/pure-ftpd# ln -s conf/PureDB 60puredb #now pure-ftpd-wrapper will enable virtual users

    I only want virtual users (PureDB authentification) => I delete all except 60puredb from /etc/pure-ftpd/auth/ and PAMAuth... form conf/

    /etc/pure-ftpd/conf# echo '5005' > Bind# the server will listen at port 5005 instead of the default 21

  3. Add users

    Note: Never forget '-m' at the end of any command regarding users otherwise the user database won't be updated

    Syntax: pure-pw useradd <virtual user name> -u <system user name> -d <home directory of the user (to which s/he connects via ftp)> -r <allowed IPs> -m (Of course there're more options).

    Ex: root# pure-pw useradd my_user_name -u pureftpuser -d /mnt/data/media/music -m
  4. Try it

    root# /etc/init.d/pure-ftpd start# pure-ftpd created by installation of PureFTPd *.deb package.



PurPureFTPd may be managed via Webmin module.
FTP for users
If you want non-root users to be allowed to run pureFTPd you can allow it via sudo.
/etc/pure-ftpd/conf# echo 'yes' > VerboseLog # Allow verbose log into /var/log/messages (via syslogd)
PurPureFTPd may be set to listen only on a particular interface, e.g. eth0.

Other utilities

webfsd - a lightweight http server

Webfsd is a good alternative to a [anonymous] ftp server, if you want only to export files.

It can be chrooted (the option -R, requires to be run by root) or you can set the document root directory (-r <dirr>), limit it to a certain ip [net interface] (-i <ip>), listen on a given port (-p 7777), run in the foreground (-F), print debug info (-d), use ssl and more.

example$ webfsd -r `pwd` -i -p 7777 -F -d -b aUserName:aPassword

ssh and sshd

SSH is a secure way how to connect to and work on another computer. The machine must be running a ssh server (e.g. sshd - ssh deamon).

ssh [-X] username@server
Used for remote connection, promts for the password. -X enables it to use graphical user interface (X is a win. system).: ssh

How to set up sshd on you machine

  1. download and install it (./configure, make, make install)
  2. if you are a root and run sshd, perhaps it signes up to be run on boot (see /etc/rc.d*). In the case it always generates its keys, so you can skip the rest (just reboot).
  3. sshd needs encryption keys for the secure communication, so you must generate them (but see 2.). It needs three of them: for RSA 1 (older version, shorter key), RSA and DSA. Run kyegen and do not enter any pass phrase (only press enter, when prompted for it):
    $ ssh -keygen -t type # where 'type' is one of these: rsa1, rsa, dsa; execute for all of them
  4. run sshd (/usr/sbin/sshd, I suppose) and it will tell you it can't find the keys. Move them into the mentioned files.
  5. edit /etc/ssh/ssh_config if you wish. You can determine what encoding to use (all 3, only DSA ...), allow only particular local users to connect remotely to the machine (insert there a line of the form "AllowUsers local_username@from_which_domain_he_can_log", e.g. "AllowUsers root@*
  6. Run sshd.

OFFICE Applications and Text Processing

LyX - the Document Processor (www) & [La]TeX

Do you want to create LaTeX documents and don't like the plain text view? Would you prefer a graphical representation of the LaTeX file? Then LyX is here for you.

This text applies to LyX version 1.3.4.

Spellchecker and latin2 accented characters

Nromally, when checking an iso8859-2 (latin2) file, the spellchecker (ispell/aspell) doesn't check correctly words with accented letters - it thinks the accented letter is a word separator and splits the word in two instead of checking it. To correct it, add all the accented characters - ̹ؾU - to: of checking it. To correct it, add all accented characters to

Edit > Preferences > Language settings > Spellchecker > Escape characters

[CZ] Pro sprvnou kontrolu pravopisu v Lyxu pidme psmena s diakritikou (viz ve) na ve uveden msto v preferencch aplikace.

Add a new environment to the environment selector (the very left of the buttonbar)

See LyX Quickstarter - the article "Making Your Own Layout". Let's see an example how to add a new environment. Assume we want the standard book class with an additional environment called indentedpar that creates a paragraph separated from others by vertical spaces. We want it to look as the Standard "environment" except for the vertical spaces.

Create a new style based on the class book in $HOME/.lyx/layouts/mybook.layout and define there the environment indenterpar:


#% Comment: Book style with a new environment
# \DeclareLaTeXClass[book]{mybook}

Style IndentedPar
  LatexType             Environment
  LatexName             indentedpar  
  Margin                Static
     { % start code:
        \list{}% will be based on the env. 'list'
           \setlength{\rightmargin}{\leftmargin} % rightm. == leftm.
           \setlength{\parsep}{\parskip}%          distance of 2 paragraphs
           \setlength{\listparindent}{\parindent}% indentation of 2+ par.
           %\setlength{\itemindent}{\parindent}%   indentation of 1st par.
     { % end code:

Then Edit->Reconfigure; quit and restart LyX.

Now you can select the environment IndetedPar providing you've set the style mybook for you document (Layout->Document->Layout tab->Document class). It shall be mentioned that this layout differs a bit from the Book layout regarding the Lyx display of the Bibliography env., see book.layout under the LyX installation directory.

Some explications:


See notes on LaTeX (hyphenation, vlnka).

To disable the automaticaly inserted '\usepackage{babel}' delete it from: Edit > Preferences > Language settings > Language > Language package: . You may want to replace it by '\usepackage{czech}'.

GUI: Window Managers & desktop utilities

Fluxbox - a light-weight window manager

Some useful hot keys (see ~/.fluxbox/keys):

My fluxbox desktops

Click the image for a detailed view & description.

My desktop, May 28 2005
My Fluxbox, May 28, 2005

xscreensaver - an enhanced screen saver & more

When the screen is locked by xscreensaver it doesn't prevent another user from logging in - you can either log back in or click "New login" to run - after a delay - a new instance of gdm (gnome display manager) that presents you with the login window. Perhaps it also works with kdm/xdm.

The program xscreensaver itself is a daemon that shall be run at the beginning of user's session. It can be controlled by xscreensaver-command, e.g. 'xscreensaver-command -lock' locks the screen. You can set the screensaver via its GUI settings panel - run xscreensaver-demo.

It's very good in conjunction with hibernation by suspend2 (software suspend 2) - if you set suspend2 to lock the user's session automatically upon hibernation ('LockXScreenSaver yes' in hibernate.conf) it tries to use xscreensaver - which won't prevent another user to use the computer when switched on. Note: It only works it the user already runs xscreensaver (the daemon), otherwise it's supposed it is not available and xlock is used instead.

created by Jakub Holy 2003AD