LINUX
Welcome page - Command Quicklist - Troubleshooting - LINUX installation
These pages contain documentation of how to work in our LINUX
environment. We hope you find all necessary information. Moreover, we
hope that you inform
us about all usefull suggestions to complete this documentation.
Everything
indicated with is for advanced users, freshmen can
skip these parts.
About Linux
First of all our machines run under
Linux.
This is a Un*x-like operating system that is freely available from the
internet.
Although this operating system is free it is a full fledged OS which
provides
everything a serious system administrator looks for. Due to its free
nature
Linux is not subjected to the laws of the free market. As a result
Linux
is update and enhanced almost every day since there are no investments
that
should pay-off before the introduction of new technology.
In the beginning a Un*x-like operating
system may look much more
difficult to use than other systems like MacO$ or M$ Windows. With a
little patience you will discover that this not the case and the you
can even do more with the same machine simply by using a good OS on it.
But the following 'things' are confusing at first:
- Most if not all the command lines interpreters are case
sensitive. This means that LS does not mean the same
as ls. For M$ users this one of the strangest things
and it get even more annoying when
you know that filenames are also case sensitive. So be careful
when
you save something on disk.
- A command interpreter is called a shell under Un*x, not a
prompt. It is also called a Console or Terminal.
- A Linux mouse has three
buttons: the third middle button for copying and pasting. Select
something to copy it, click the middle button for pasting (in a console
or emacs). When your (Windows) mouse has only 2 buttons, you can do
this by clicking both simulaneously.
- Each user has its own home directory. This is part of the
security features provides by the OS. This means the other users can
not remove your files and you can not remove theirs if the permissions
are set correctly.
All your files should be in your home directory, this is the only place
where you have the permission to write, rename or delete files.
- There are no drives! Everything is a file. This uniform view has
the advantage requiring no new command for accessing different drives.
In fact
you, as a normal user, can not see the difference between one drive and
another. This drive can be a floppy, a hard disk but also network drive
yet there is
no difference. I mention this, but this is not really important for
your
PVM programming.
- M$ users watch it! Under Un*x the slash used to define a path to
a
file is the normal slash (/) not the back slash (\)
like in M$ OS-es. In other words everything is like this: '/path/file'
and not like this '\path\file'.
- What to do if you have a problem with a Un*x command? Easy, most
of
the commands have a so called man page (from manual page).
This page describes the functions of the command and its different
options. You just open a shell and type 'man xxx'.
Learn more about UNIX and linux
- Introduction to Unix
(downloaded
from here)
- chapter 3: learn the basics about the filesystem!!
- chapter 5: learn important UNIX basics like pipes, redirection,
filters
- chapter 7: utilities
(see also below: console commands)
- chapter 8: about shell scripts
- Linux Forum: a lot of
info!
- GNU
manuals online
- advanced commands (like sed)
- For a good linux manual, look under emacs:
- select menu-item Help => Manuals => Browse Manuals With
Info
- or CTRL-h-i (keep CTRL button down, press h followed by i)
- see under Miscellaneous
- move your cursor on a bold word and press ENTER to
select
it
- press 'u' for up, 'n' for next and 'p' for previous page
We use the
KDE
environment in LINUX.
It has a Windows look, so using it should be straight forward.
- Note that it is Single-click to start a program or
file!
To prevent a program or file to activate, keep the Control
button pressed when you click. For example when you want to move or
copy your file(s) to
a different directory or you want to delete it. To select multiple
files, also keep the Control button down.
- You have 4 desktops or workspaces, denoted by
One, Two, Three & Four. A program is opened in the current desktop.
They are efficient to organise your work. Just click them in the
toolbar to change between them.
Use a different desktop for each task you are doing (programming,
internetting,
experimenting, ...)
- Use Alt-TAB to change between windows in your workspace.
- The most important application are placed in the toolbar, more
can
be found under the big K (down left).
Environment Variables
A lot of the configuration of your
system is done by so-called environment
variables. These are variables -like any variable in a program-
that are
known in your whole environment, like makefiles, programs etc. You can
view
all these variables with the command env (type in a console).
Create/assign them with setenv var value, use them with a $
sign, for example to view the content, type echo $var in
a
console.
Important predefined variables:
- HOME or home : the pathname of your home
directory
.
- PATH or path: specifies the path that the
shell searches when asked to execute a command. If an executable is not
found in
the path, you must specify its full pathname. Under Un*x you can only
execute
the file the are in your path. This path is stored in
the PATH environment variable of every shell. So don't be surprised if
you can see a file but you can not execute it even if you 'stand' in
the same directory. There are two solutions to your problem: give
the full path to the executable
on the command line or change your PATH environment variable. Ex:
/home/my_self/a_directory_my_program
- USER or user: contains you login userid.
Linux configuration
You have 2 important configuration
files, they are placed in your home
directory
and start with a dot.
- .cshrc: contains the definition of important
environment variables
These are called hidden files
(start with a dot), to view
them:
- in a console: use ls -all
- in the file manager: menu View => Show Hidden
Files
Login at the PC's of the 3rd floor
- Choose one among the following computers (use this IP-address when creating the
tunnel with putty instead of localhost):
10.0.16.101 to 10.0.16.108
- Choose Port according to wanted resolution and color depth:
Resolution
|
Color depth
|
Port
|
800x600
|
24bit
|
5911
|
800x600
|
16bit
|
5912
|
1024x768
|
24bit
|
5921
|
1024x768
|
16bit
|
5922
|
1280x1024
|
24bit
|
5931
|
1280x1024
|
16bit
|
5932
|
- Troubleshooting
(known problems):
- Specify the tunnels correctly (see
doc), don't forget to save your putty configuration.
- Too high resolutions are sometimes not accepted.
- Sometimes you'll better delete the xxx.rnd file in which putty
stores your configuration.
- Check whether cluster computer is still 'alive'. Try an ssh node01 when connected
with putty.
Work at
home For security reasons we don't put the
correct addesses on the web, you'll have to ask us.
login graphically with
VNC
VNC under Mac
textual terminals
You can connect to our Linux system from your home PC, using
ssh (not Telnet, because it doesn't
give a secure connection).
Install putty as a terminal (
homepage,
download
PuTTY exe).
Connect to one of the above computers. You get a console, no graphical
user
interface is available. Use for example
nano myfile as simple editor
(see
below, console commands).
You can access your files on our system with
secure ftp (more
secure
than the simpe ftp), use for instance
WinSCP (freeware).
Work with Floppy's
Before you can read from or write to
floppy's, you'll have to mount
the floppy, type in a console:
mount /floppy
Now you can read your files from this
with the file manager or console (cd
/floppy and ls *).
When finished, don't forget to unmount with:
umount /floppy
Important remarks:
- if mount /floppy doesn't work, consult the mount table (more
/etc/fstab) and look for the entry with floppy and vfat,
on some machines
you have to mount /mnt/floppy
- you must be logged in on the machine you're working on
Software
- Console or terminal (in toolbar)
- File manager Konqueror
(in toolbar)
- Your personal files are under 'My Home'
- Use the right mouse click for folder and file operations
- Keep the Control key down to prevent the file to be started
(remember that it is a Single-Click environment)
- Configure it
- set in the View menu item: Show Tree & Text View
- Push the Reload button to view the changements of the directory
content
- a simple text editor Kedit (in toolbar)
- Mozilla: for browsing the net and reading your
mail
- Kwrite or use the more professional Kate
- a simple file editor, with colouring of C++, html, xml, ...
files
- F11: show Line Numbers
- Ctrl+I: Indent, Ctrl+Shift+I
to Unindent (also when multiple lines are selected)
- Ctrl+D: Comment, Ctrl+Shift+D to
Uncomment (also when multiple lines are
selected)
- Ctrl+B: Toggle bookmark
on current line<>
- Alt+PageDown: go to
next bookmark, Alt+PageUp: go
to previous bookmark
- Emacs
- use Ksnapshot to make snapshots of screens
- look under Graphics => Snapshot
- use Kview to view images
- look under Graphics => Image Viewer
- use mpg123 or XMMS to listen to
mp3 files
- for ftp and its commands, look here
Configure your desktop: add links to programs
- Open the templates window (on your desktop). Drag the "Program"
icon
to your desktop, keep the Control button pressed & select copy!. It
will be copied to the desktop.
- Now you have a program link, to configure it, right-click on it
and select "Properties"
- Under the 'General' Tab, you can specify the name of the link (eg
netscape.kdelnk)
- under the 'Execute' Tab, you should specify the program you want
to
run (see higher for the right path). You can also select a different
icon by clicking the icon.
Console Commands
As Linux is a UNIX clone, the commands are the same.
Here is a list of the most usefull commands (look here for
detailed
info!! or man
pages ):
- ls: list contents of directory
- ls -al: also show hidden files (start with a dot)
- lc: show all c++ files (makefile, c files, header
files, ...)
- cd directoryname: change directory
- when you ommit the directory, you go to your home directory
- cd .. : go back to the parent directory
- cd ~: go to your home directory
- pwd: show the path of the current directory
- mkdir directoryname: create a directory
- ssh hostname: go to another machine (eg ssh info9) and work on that
computer
- use exit to go back
- the first time you connect to that specific machine, answer yes
when
he asks for a secure connection and give your password.
- with hostname you
get
the name of the computer you are working on
- cp pathname-filename pathname: copy file to a different
location
- ~/ is your home directory (eg cp mydoc.txt ~/docs/)
- mv pathname-filename pathname: move file to a different
location
- nano filename: offers
a simple command-line based text editor. Below you see the major
commands, ^ means the ctrl key, eg. ctrl-x to quit, (it will ask for
saving
your file)
- use Control-c to stop a running program!!.
- use the Up & Down Keys to repeat commands
(the command history)
- copy: just select a text, it is automatically copied to
the clipboard
- paste: click on both mouse buttons at the same time
- TAB: to complete the name of a program, file or
directory, press TAB again to get a list of all possibilities.
- grep (look for a word in
files), diff (compare
2 files for
differences): see documentation
- ex: grep -r "blabla" * for
recursive (search subdirectories) search of blabla in all files
- for counting the number of lines in which a word occurs:
- grep blabla <file> | wc
-l
- wc = word count,
-l option is for
the number of line
- vi is a command-line based text
editor, looks very strange if
you are used to window-based editors
- edit file with vi file
- commands that should be typed on a line:
- i to go in insert mode on that line
- Escape to quit this mode
- dd delete current line
- commands:
- :w save file
- :q quit vi
- :q! quit vi without saving the file
- archive your
files with
for example tar:
- create an archive (myfiles.tgz): tar -czvf myarchive.tgz *.*
(or multiple files, or in directories, like dir/*.*, etc)
- with the -z option, the archive is also compressed
- type tar --help
for all options
- extract archive: tar -zxf myarchive.tgz
For more details, check the above links.
Hints:
- use the TAB to complete incomplete directory and
filenames
(if you don't remember the full name of your file or you're just lazy)
- use the keys up & down to redo commands you
typed before (very usefull!!)
- use the middle mouse button for copying, as explained here.
- for help about commands:
- command --help
- man command: consult the manual pages
Scripts
Scripts are very powerfull to automate some tasks. Run them by simply
typing there name in a console.
There are many shells you can use to write scripts:
- C Shell:
- start script with line #!/bin/tcsh (tcsh instead of
csh!!!)
- DO
NOT FORGET: make it an executable with command: chmod +x
myscript.csh
- doc or
documentation
or this
(Unfortunately, not everything seems to apply for our system)
- check the examples:
- sed.csh: use sed to replace a
string
by another in a file
- sed_arg.csh: use program
arguments
- files.csh: scans all files
of
a directory
- forallfiles.csh: runs
a command of all files, and recursively on all directories
- convert_filenames.csh:
convert all filenames of a directory to lower case names
- multiple_experiments.csh:
run multiple experiments with different parameters
- $$ find out following scripts: check file extension, use
special characters in grep & sed, replace windows-EOL with UNIX-EOL
- for calculations: @
y=$a + $b (watch out for the spaces !!!)
- sh
- fl.sh: remove all files from
floppy and copy files from directory to floppy (very fast!)
- run.sh: run program mutiple
times with different parameters
- crunch.sh: send
commands
to all machines
Linux Links