Lot of things written here I only guess and don't know them surely, take them as "possible truth".
Last change: Aux 17, 2005 AD
Sh, bash: $> export VARIABLE='value' // no spaces around
'='! Quotes prevent substitutions (for * etc). You can ommit "export" but
it's better to write it there (see man export)
Ksh: $> setenv VARIABLE 'value'
Set title of a terminal windows (works at least for xterm and aterm):
$ export PS1="\[\033]0;New terminal title\007\]\u:\W\$ "
\[ ... \] tells to bash that the characters in between are unprintable and
shouldn't be counted to the length of the prompt string
\033]0; ... \007 are special characters saying that the text in between shall become the terminal title
(<text> = replace by your own; [text] = optional)
basename <name> [<suffix>] strips
directory and suffix from filename. Ex: $> basename /bin/mkdir.exe
.exe produces 'mkdir'. See dirname
dirname <name> strips non-directory suffix from file name. See basename.
set <list> assigns elements of the list to the positional variables $1, $2 ... . $# contains the number of them. Attention: if the list is empty set prints all environmental variables, so make sure it is not empty.
shift removes the 1st positional variable, shifts the others to the left ($2 becomes $1) and decreases $#
tee [-a] <file> is used in pipe to copy what's going through to a file
average.sh - for loop ...
Bash can offer completions that take into account the current context; it means, that typing xpdf <TAB> offers only *.pdf files and directories.
To enable it source the file /etc/bash_completion:
bash$ . /etc/bash_completion
Now you can see all completions that are defined (look at the end of each line for the executable/... name):
bash$ complete -p
You can also look at definitions of the completion functions (named '_ImageMagic', '_ant' ...):
bash$ declare -f
For more information see a more extensive description.
GUI: if it's set, init starts a display manager in the end, which displays
a graphical login screen. Usually there are 3 disp. man.: xdm, kdm (KDE) and
gdm (gnome) - search /etc/rcLEVEL.d for their startup scripts (S??xdm ...);
all of them (on my system) check in /etc/X11/default-display-manager whether
and the one written there starts (or none). This file may not contain
anything else but the absolut path of the display manager to start.
If you want e.g gdm to offer more window managers on login screen (kde, gnome, twm ...) add for each of them a file into /etc/gdm/Sessions/ (having the same name as the manager); the file is a shell script that is run when user selects that manager.
Prevent a services from beiing run at boot:
root# update-rc.d portmap remove
You can execute a program (run a command) as another user (e.g. root)
using the command sudo. The proper permitions
must be set in the file sudoers (see man sudoers). To allow user pepa run
poweroff on your computer named popelnice which is in domain cvut.cz as a
root (degault) without giving password , you would type into sudoers this:
pepa popelnice.cvut.cz = NOPASSWD: /sbin/poweroff # allow pepa to run poweroff as a root without password
To allow all users run "lp" and "cat" as the user printer on all systems (the password for printer will be required):
ALL ALL = (printer) /bin/lp, /bin/cat # all users on all systems run lp as printer; "ALL" must be in capitals!
To allow users to run /sbin/halt run
visudo to edit
Important: the changes will not apply until visudo is closed, even if you save the file.
Host_Alias HOST = computer_name # without domain in my
User_Alias FULLTIMERS = username1, username2
Cmnd_Alias HALT = /sbin/halt, /sbin/reboot
FULLTIMERS HOST = NOPASSWD: HALT # do not require password to run halt commands
root2 ALL = (ALL) ALL # can run all commands via sudo
A user can run it (I suggest to set an alias for the command via
alias e.g. in .bash_profile):
username1$ sudo /sbin/halt
Normally it's necessary to mount and afterwards umount floppy/CD if you want to use it (or use dos emulator dosemu to access them). Consider using autofs& automount for them (autofs startes automount daemon for certain mount points according to its configuration, see man autofs) or better for cdrom only (you could remove not umounted floppy). Gnome and KDE desktop environments can work around this.
To use a hardware (HW)(device) you need to 1) have a driver for it 2) set the driver and 3) load it. It can be either compiled into the kernel or it may be loaded as a module (not part of the kernel) when the system boots up. In the best case your system detects HW automatically, has a driver for it and installs it so you don't need to care for anything, but HW producers' support for Linux is not very good and volunteers can't write all possible drivers so you may have problems (ideally buy ony HW supported by Linux).
Your device is not detected but a driver exists for it (look for it at google.com, rpmfind.net, packages.debian.org etc.). OK, find out a configuration of the device in BIOS or in Windows if you use them too, get and install the driver and set it manually (see Modules below and some HOWTOs).
modinfo utility examines the object file module_file
associated with a kernel module and displays any information that it can
insmod installs a loadable module in the running kernel (according to instructions in /etc/modules.conf, usually). See man insmod.
modprobe and depmod utilities are intended to make a Linux modular kernel more manageable for everybody (manage dependencies ...).
Unix/Linux is often server/client architecture. You need to run a server (=special program) for graphical user interface (X server, X window system), for using sound (e.g. Alsa), often it's used for management of fonts (needed to display special characters like "é"), likely you need one for printer ... .
For sound you need:
$> pnpdump -i -o -c /etc/isapnp.conf# scan for isapnp cards and create a file woth possible configuration, that will be used by isapnp (it must be /etc/isapnp.conf). The flag -i is necessary, otherwise some cards may not be discovered. -c = select (uncomment) a configuration, -o = specify output file.
$> /sbin/isapnp /etc/isapnp.conf# set the cards and subscribe itself to be run on each boot (see /etc/rc.d/rc.sysinit).
$> /sbin/modprobe ne io=0x240 irq=3" where the values correspond to those of the selected configuration in isapnp.conf; "ne" is the name of module for my Ethernet card).
= loadable drivers etc. (must be loaded before being used, e.g. during the
- see above isapnp;
- see /sbin/lsmod (list loaded modules), modprobe ... (loads a module), /etc/rc.d/rc.modules (specifies aliases, resources?)
created by Jakub Holy 2003AD