text:
Applied Science BTEC Nationals/Chemical Laboratory Techniques/Kastle-Meyer

The Kastle-Meyer test is a forensic presumptive blood test, where the chemical indicator phenolphthalein is used.

 * By the way, 'Phenolphthalein' is pronounced 'fee-nolf-THAY-leen'.

A dry sample is collected with a swab or filter paper. First a few drops of ethanol, then a few drops of reduced phenolphthalein reagent solution, and, finally, a few drops of hydrogen peroxide are applied to the swab. If the swab turns pink then it is a positive test. This test is nondestructive to the sample, which can be kept and used in further tests at the lab. This test has the same reaction with human blood and animal blood so further testing would be required to determine which one it is.

Preparation of reduced phenolphthalein
The phenolphthalein used in this test has been modified from its conventional form, in that it has been reduced by two electrons and is pre-dissolved in alkaline solution. This is typically achieved by boiling an alkaline solution of phenolphthalein with zinc powder, which acts as the reducing agent. Upon reduction, the very intense pink colour of the cationic form of phenolphthalein fades to a faint yellow colour. It is this form of phenolphthalein that is present in Kastle-Meyer test kits. In order to generate the intense pink colour indicative of a positive test, the reduced phenolphthalein must be oxidised back to its normal, coloured form.

Mix the following reagents in a 250 cm3 round-bottomed flask:

 * Phenolphthalein 2.0 g
 * Potassium Hydroxide 20.0g
 * Deionised Water 100 cm3
 * Zinc Dust 20.0 g
 * A few anti-bumping granules

Boil under reflux for 2–3 hours until the solution has lost its pink colour. Cool and decant into a bottle containing some zinc to keep in the reduced form. Stored in a fridge, in the dark, the shelf life is 6 months.

Alternative mixtures
The preparation can be scaled-up and the low-concentration solution with ethanol created in one step:

 * Phenolphthalein 4 g
 * Sodium Hydroxide pellets 40 g
 * Zinc dust 20 g
 * Deionised water 1000 cm3
 * Ethanol to bring the total volume up to 1200 cm3

Reflux in a 5000 cm3 round-bottomed flask. After reflux, restore to 1200 cm3 with ethanol.

Another method uses similar proportions but avoids refluxing:

In a 1 dm3 beaker, add

 * Phenolphthalein 1 g
 * Sodium Hydroxide pellets 10 g
 * Zinc dust 5 g
 * Deionised water 250 cm3

Using a stirring hot plate, mix and heat until the solution loses its pink colour. Do not boil. This process may take 2 to 3 hours.

Decant the liquid into a 500 cm3 measuring cylinder. Add ethanol to make 300 cm3 of solution.

Add a small amount of zinc powder to a brown bottle, and pour the phenolphthalein solution into this bottle. Label, date, and store the bottle in a refrigerator.

Safe disposal of zinc
Zinc powder or dust in contact with water or damp air evolves hydrogen. The heat of the reaction is sufficient that the hydrogen may ignite. Therefore the zinc should not be discarded in the wastebasket. The following disposal procedure should be followed for less than 20 g of zinc:

Follow standard laboratory procedures of wearing gloves and safety aprons. Add dilute hydrochloric acid to the zinc dust in a beaker. Allow bubbles to form and slowly add more acid till no more bubbles are seen.

When all the zinc has dissolved add sodium carbonate solution to the mixture. Bubbles will be formed. Keep on adding the sodium carbonate small quantity at a time till the zinc precipitates as zinc carbonate.

The zinc carbonate can be now filtered and disposed of as it is non-toxic.

Working Solutions
Solution 1:

Ethanol 10 cm3

Solution 2:

Reduced phenolphthalein stock 2 cm3 Distilled Water 10 cm3 Ethanol 2 cm3

(Or use the alternative mixture noted above with no extra water or ethanol).

Solution 3:

3% Hydrogen Peroxide 10 cm3

Procedure

 * 1) Using a piece of filter paper or paper towel, rub the stain suspected to be blood to collect a sample. If the stain is dry, you may moisten the paper slightly with distilled water. You will not see a visible blood stain on your filter paper.
 * 2) Lay the paper out so that the spot that you rubbed is exposed.
 * 3) Two or three drops of Ethanol (solution 1) are placed on the stain.
 * 4) Two drops of working phenolphthalein solution (solution 2) are added to the stain.
 * 5) After waiting to ensure that no color develops at this stage, two or three drops of 3% Hydrogen Peroxide (solution 3) are added.
 * 6) An intense pink color is a positive test for peroxidase activity, indicative of hemoglobin. This is not a confirmatory test for blood.
 * 7) A positive reaction is indicated by the development of a pink color within 5 seconds. Reactions occurring after 5 seconds, or before the addition of the hydrogen peroxide are inconclusive. A pink colour after phenolphthalein has been applied but before hydrogen peroxide has been applied normally indicates a false positive due to an oxidizing agent being present. Rust could cause a false reading of this type.

Standards and Controls: Standards should include a known blood stain (positive control) and a known blood-free sample (negative control). These controls will be run before analysis and recorded in the laboratory notes.

In the relevant reaction, hydrogen peroxide reacts with the hemoglobin in the blood, with the phenolphthalein not participating in this first process. In its reaction with hydrogen peroxide, the haem centre of haemoglobin undergoes the following O-O bond homolysis reaction:

 * HOOH + Fe3+[haem] → Fe4+=O[haem] + OH· + H+

The products of this reaction are one equivalent each of a high-valent iron-oxo species and hydroxyl radical, either of which can oxidise the reduced phenolphthalein back to its coloured form. The amount of acid produced in this reaction is insignificant in comparison to the concentration of base present in the phenolphthalein reagent solution. In addition, this reaction of haem with peroxide is catalytic, making this test very sensitive to small quantities of blood present on the test swab.

This test has some limitations. Namely, the enzymes in some vegetables (especially tomato, potato, cucumber, horseradish) can cause a false positive test result. Other non-blood substances which give positive results are: some fruit extracts, some metallic substances, or any other peroxidase-like substances.


text:
LPI Linux Certification/Work On The Command Line

Detailed Objective
(LPIC-1 Version 5.0)

Weight: 4

Description: Candidates should be able to interact with shells and commands using the command line. The objective assumes the Bash shell.

Key Knowledge Areas:
 * Use single shell commands and one line command sequences to perform basic tasks on the command line.
 * Use and modify the shell environment including defining, referencing and exporting environment variables.
 * Use and edit command history.
 * Invoke commands inside and outside the defined path.

The following is a partial list of the used files, terms and utilities:
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting
 * Quoting

Command line
Command lines have a common form:

command [options]  [arguments]

Examples:

pwd ls -ld or ls -l -d or ls -d -l rm -r /tmp/toto cat ../readme helpme > save more /etc/passwd /etc/hosts /etc/group find. -name *.[ch] -print date "+day is %a"

Command lines can be stored into a file for a script.

To display a string to the standard output (stdout) use echo.

echo [-n][string|command|$variable] echo my home directory is: $HOME echo I use the $SHELL shell

Shells and Bash
The order of precedence of the various sources of command when you type a command to the shell are:
 * Aliases
 * Keywords, such as if, for and more.
 * Functions
 * Built-ins like cd, type, and kill.
 * Scripts and executable programs, for which the shell searches in the directories listed in the PATH environment variable.

If you need to know the exact source of a command, do:

$ type kill kill is a shell builtin

Not the same as:

/bin/kill

To list all the built-in commands use help.

/bin/bash

/bin/bash can be invoked at login time or explicitly from the command line. At login time the following script files will be executed: When bash is executed the following script files will be executed When a user explicitly invokes a bash shell, the following script files will be executed: The history of commands typed from the bash shell are stored in ~/.bash_history. A script is a list of commands and operations saved in a text file to be executed in the context of the shell. The bash scripts intend to setup your environment variables and more.
 * /etc/profile default system file
 * $HOME/.profile if it exists
 * $HOME/.bash_profile if it exists
 * /etc/bash.bashrc if it exists
 * $HOME/.bashrc if it exists
 * /etc/bash.bashrc if it exists
 * $HOME/.bashrc if it exists

Overlay /bin/bash

Each time you execute a program a new process is created. When the program terminates, the process will be terminated and you get back your prompt. In some cases you can run a program in background with the '&' following the command.

myscript &

In some situations, it is also possible to overlay the running process bash. exec [program] This is usefull when you don't need to get the prompt back. The login program for example can be a good example to overlay the bash process in which it has been started.

exec login

Shell variables
All local variables to the bash session can be viewed with set.

To declare a local variable, do:

VARNAME=foo

To unset a variable, do:

unset VARNAME

All the environment variables can be viewed with env. To declare a variable that will be seen by other shells use export. export VARNAME=foo or VARNAME=foo export VARNAME The variable will only be seen by the shell that has been started from where the variable has been declared. Here are some important variables:
 * HOME: Home directory of username logged in.
 * PATH: Command search path.

Man pages
The online manuals describe most of the commands available in your system.

man mkdir man cal

If you are looking for a key word in all the man pages, use the -k option. man -k compress apropos compress

The location of all the man pages must be set in the MANPATH variable.

echo $MANPATH /usr/local/man:/usr/share/man:/usr/X11R6/man:/opt/gnome/man

Exercises

 * 1) Get information on the useradd and userdel commands.
 * 2) Create two new accounts user1 and user2 and set the passwords to those accounts with the passwd command. As root lock the accounts and check if you can still log in.
 * 3) What is the command to concatenate files?
 * 4) Declare and initialize the following environment variables: NAME and LASTNAME. Use echo to print them out.
 * 5) Start a new bash (type bash) and check that you can still see those declared variables.
 * 6) Use exec to start a new bash session. Can you still see those declared variables?
 * 7) Use date to display the month.
 * 8) Add a new user named notroot with root's rights and lock the root account.

 * Exercises results

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
LPI Linux Certification/Process Text Streams Using Filters

Detailed Objective
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to apply filters to text streams.

Key knowledge areas:
 * Send text files and output streams through text utility filters to modify the output using standard UNIX commands found in the GNU textutils package.

The following is a partial list of the used files, terms and utilities:

Pattern matching and wildcards
Wildcards are pattern matching characters commonly used to find file names or text within a file. Common utilizations of a wildcard are: locating file names that you don't fully remember, locating files that have something in common, or performing operations on multiple files rather than individual.

The shell interprets these special characters: ! @ # $ % ^ & * { } [ ] | \ ; ~ ' " ` ?

The characters used for wildcard are: ? *  [  ]  ~

If you use the wildcard characters the shell will try to generate a file from them. Try the following: echo all files *

Special wildcard characters ? match any one character. * Any string [abcfghz] One char set [a-z] One char in range [!x-z] Not in set ~ Home directory ~user User home directory

Examples: ? One character filenames only [aA]??? Four characters, starting with a or A. ~toto pathname of toto home directory [!0-9]* All string not starting with a number.

What about these commands? ls [a-z][A-Z]??.[uk] ls big* ls a???a ls ??*

Shell and wildcards
A shell command line can be a simple command or more complex. ls -l [fF]* ls *.c | more ls -l [a-s]* | mail `users`

The first event in the shell is to interpret wildcards. Only the shell interprets unquoted wildcards.

Quoting
Do quote to prevent the shell interpreting the special characters and to transform multiple words into one shell word.

echo 'He did it, "Why?"' echo 'Because "#@&^:-)"' echo '$VAR='Me
 * 'string' - Nearly everything within the quote is literal:

echo "What's happening?" echo "I don't know but check this $ANSWER"
 * "string" - Like 'string', however it interprets $, \, !:

echo \$VAR=Me echo What\'s happening\?
 * The backslash (\) treats the following character as literal:

echo \\
 * How could we display the backslash? With the following line:

Comments
You can add comments in a command line or a script. Use the character #. A white space must immediately precede #.

Examples: echo $HOME # Print my Home directory echo "### PASSED ###" # Only this part is a comment echo The key h#, not g was pressed.

Commands

 * cat, tac: Concatenate files and print on the standard output, from beginning to end or end to beginning, respectively.
 * head, tail: Output the first and last part of files.
 * nl: Number lines of files.
 * wc: Print the number of lines, words, and bytes (in that order) in files.
 * cut: Remove sections from each line of files.
 * tr: Translate or delete character.
 * expand, unexpand: Convert tabs to spaces and space to tabs.
 * paste: Merge lines of files.
 * join: Join lines of two files on a common field.
 * uniq: Remove duplicate lines from a sorted file.
 * split: Split a file into pieces.
 * fmt: Simple optimal text formatter.
 * pr: Convert text files for printing.
 * sort: Sort lines of text files.
 * od: Dump files in octal and other formats.

Concatenate files
To concatenate files, use cat. cat [options] [files...] tac [options] [files...]

The results are displayed to the standard output.

Common options: -s: never more than one single blank line. -n: number all output lines.

Examples:

cat file # Display file to the standard output. cat chapter* # Display all chapters to standard output. cat -n -s file # Display file with line number with single blank line.

To concatenate files in reverse order, use tac.

View the beginning and the end of a file
To view only few lines at the beginning or at the end of a file, use head or tail. head [options] [files...] tail [options] [files...]

The results are displayed to the standard output.

Common options: -n: number of lines to be displayed. (head and tail) -c: number of bytes to be displayed (head and tail) -f: append output. (tail) -s #: iteration for new data every # sec. (tail)

Examples:

head file # Display the first 10 lines of file. head -n 2 file # Display the first 2 lines of file. tail -c 10 file # Display the last 10 bytes of file. tail -f -s 1 /var/log/messages Display the last 10 lines of messages, block and check for new data every second.

Numbering file lines
To add the line number to a file, use nl. nl [options] [files...]

The results are displayed to the standard output.

Common options: -i #: increment line number by #. -b: numbering style: a: number all lines t: non-empty lines n: number no lines -n: numbering format: rz: right justified ln: left justified.

Examples: nl file # Add the line number in each line in the file. nl -b t -n rz file # Add the line number to each non-empty line with zero-completed format.

Counting items in a file
To print the number of lines, words and bytes of a file, use wc. wc [options] [files...]

The results are displayed to the standard output.

Common options: -c: print the size in bytes. -m: print the number of characters. -w: print the number of words. -l: print the number of lines. -L: print the length of the longest line.

Examples: wc *.[ch] # Display the number of lines, words, and characters for all files .c or .h. wc -L file # Display the size of the longest line. wc -w file # Display the number of words.

Cutting fields in files
To remove sections from each line of files, use cut. cut [options] [files...]

The results are displayed to the standard output.

Common options: -b #: Extract the byte at position #. -f #: Extract the field number #.

Examples: cut -b 4 file # Extract and display the 4th byte of each line of file. cut -b 4,7 file # Extract and display the 4th and 7th byte of each line. cut -b -2,4-6, 20- file # Extract characters leading up to 2 (1 and 2), 4 to 6, and 20 to the end of the line for each line of file. cut -f 1,3 -d: /etc/passwd # Extract the username and ID of each line in /etc/passwd.

The default delimiter is TAB but can be specified with -d.

Character conversion
To translate the standard input (stdin) to standard output, use tr. tr [options] SET1 SET2

Common options: -d: delete character in SET1. -s: replace sequence of characters in SET1 by one.

Examples: tr ‘a‘ 'A' # Translate lower a with A tr ‘[A-Z]’ ‘[a-z]’ # Translate uppercase to lowercase tr -d ‘ ‘ # Delete all spaces from file

To convert tabs to spaces, use expand and to convert spaces to tabs, use unexpand. expand file unexpand file

Line manipulation
To paste multiple lines of files, use paste. paste [options] [files...]

Common options: -d #: delimiter: Use # for the delimiter. -s: serial: paste one file at a time.

Examples: paste f1 f2 # Display line of f1 followed by f2. paste -d: file1 file2 # Use ':' for the delimiter.

To join multiple lines of files, use join. join file1 file2

To remove duplicated line, use uniq. uniq [options] [files...]

Common options: -d: only print duplicated lines. -u: only print unique lines.

Examples: uniq -cd file # Display the number of duplicated line.

Splitting files

To split big files, use split. split [options] file

Common options: -l #: split every # lines. -b #: split file in bytes or b for 512 bytes, k for kilobytes, m for megabytes.

Examples: split -l 25 file # Split file into 25-line files. split -b 512 file # Split file into 512-byte files. split -b 2b file # Split file into 2*512-byte files.

Formatting for printing
To format a file, use fmt.

fmt [options] [files...]

Common options: -w #: maximum line width.

Examples:

$ fmt -w 35 file # Display lines with a maximum width of 35 characters.

To format a file for a printer, use pr.

pr [options] [files...]

Common options: -d: double space.

Examples:

$ pr -d file # Format file with double-spacing.

Sort lines of text files
To sort the lines of the named files, use sort.

sort [options] file

The results are displayed to the standard output.

Common options: -r : Reverse -f : Ignore case -n : Numeric -o file: Redirect output to file -u : No duplicate records -t; : Use ';' as delimiter, rather than tab or space.

Examples: sort file -r sort file -ro result

Binary file dump
To dump a binary file, use od. od [options] file

The results are displayed to the standard output and start with an offset address in octal format.

Common options: -c: each byte as a character -x: 2-byte in hex -d: 2-byte in decimal -X: 4-byte in hex -D: 4-byte in decimal

Examples:

$ od -cx /bin/ls 0000000 177  E   L   F 001 001 001  \0  \0  \0  \0  \0  \0  \0  \0  \0 457f 464c 0101 0001 0000 0000 0000 0000 0000020 002 \0 003  \0 001  \0  \0  \0     224 004  \b   4  \0  \0  \0 0002 0003 0001 0000 9420 0804 0034 0000 0000040  °   ²  \0  \0  \0  \0  \0  \0   4  \0      \0 006  \0   (  \0        b2b0 0000 0000 0000 0034 0020 0006 0028 0000060 032  \0 031  \0 006  \0  \0  \0   4  \0  \0  \0   4 200 004  \b        001a 0019 0006 0000 0034 0000 8034 0804

Exercises

 * 1) Use wildcard characters and list all filenames that contain any character followed by 'in' in the /etc directory.
 * 2) Use wildcard characters and list all filenames that start with any character between 'a' and 'e' that have at least two more characters and do not end with a number.
 * 3) Use wildcard characters and list all filenames of exactly 4 characters and all filenames starting with an uppercase letter. Do not descend into any directory found.
 * 4) Use wildcard characters and list all files that contain 'sh' in /bin.
 * 5) Display your environment variable HOME preceded by the string "$HOME value is:"
 * 6) Display the contents of $SHELL with two asterisk characters before and after it.
 * 7) How would you display the following string of characters as is with echo using double quote and \.
 * 8) Compose echo commands to display the following two strings:
 * 9) * That's what he said!
 * 10) * 'Never Again!' he replied.
 * 11) Display the number of words in all files that begin with the letter 'h' in the /etc directory.
 * 12) How would you send a 2M (megabyte)  file with two 1.44 M floppy. How would you put back together the split file?
 * 13) What is the command to translate the : delimiter in /etc/password by #?
 * 1) What is the command to translate the : delimiter in /etc/password by #?

 * Exercises results


text:
LPI Linux Certification/Perform Basic File Management

Detailed Objective
(LPIC-1 Version 5.0)

Weight: 4

Description: Candidates should be able to use basic Linux commands to manage files and directories.

Key Knowledge Areas:
 * Copy, move and remove files and directories individually.
 * Copy multiple files and directories recursively.
 * Remove files and directories recursively.
 * Use simple and advanced wildcard specifications in commands.
 * Use  to locate and act on files based on type, size, or time.
 * Usage of,   and.

The following is a partial list of the used files, terms and utilities:
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing
 * file globbing

Create and Remove directories
To create a directory, use mkdir.

mkdir [options] dir

Common options: -m mode: set permission mode. Default use umask. -p parent: create parent directory as needed.

Examples: mkdir -m 0700 bin mkdir -p bin/system/x86

To delete an empty directory, use rmdir.

rmdir [options] dir

Common options: -p parent: remove empty superdirectories.

Examples: rmdir tmp rmdir -p bin/system/x86

Copy files and directories
To copy one file to another, or to a directory, use cp.

cp [options] source target

Source and target can be a file or a directory.

Common options: -i interactive: prompt to overwrite -r recursive: copy the subdirectories and contents. Use -R for special files. -f force: force the overwriting

The default is to silently clobber the target file. (This does not alter the source.

Examples: cp *.[a-z] /tmp cp readme readme.orig cp ls /bin cp -ri bin/* /bin

Move & Rename files
To rename a file or directory or to move a file or directory to another location, use mv. mv [options] source target Source and target can be a file or a directory.

Common options: -i interactive: prompt to overwrite -f force: force the overwriting -v verbose The default is to silently clobber the target file.

Examples: mv *.[a-z] /tmp mv readme readme.orig mv ls /bin mv -fi bin/* /bin

Listing filenames and information
The command to list files in the current directory is ls. ls [options] [filenames] Common options are: -l For a long format -F Append a file type character -a All files, including hidden files -R Recursive listing of subtree -d Do not descend into directory

The ls is equivalent to the dir command on DOS.

Examples of ls output: $ ls -l /bin/ls -rwxr-xr-x   1   root  root  46784 mar 23  2002 /bin/ls $ ls -ld /bin drwxr-xr-x   2 root   root   2144 nov  5 11:55 /bin $ ls -a. .bash_history .bash_profile .bashrc ... $ ls -dF /etc .bashrc /bin/ls .bashrc /bin/ls*  /etc/

File types
The long format means: $ ls -l /etc/hosts   #List a long format of the file hosts -rw-r—r-- 1 root root 677 Jul 5 22:18 /etc/hosts File content and location Linux/Unix does not distinguish file by filename extension, like Windows. To determine the file content use file. $ file /etc .bashrc /bin/ls /dev/cdrom /etc:      directory .bashrc:   ASCII English text /bin/ls:   ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped /dev/cdrom: symbolic link to /dev/hdc

To determine if a command is a built-in shell command or a program, use type, and use which to find its location. $ type cp cd ls which type cp is /bin/cp cd is a shell builtin ls is aliased to `ls $LS_OPTIONS' which is aliased to `type -p' type is a shell builtin $ which cut /usr/bin/cut

Creating and using filenames
Filenames can be created with: cat chapter1 chapter2 > book vi mynewfile cp file newfile netscape touch memo
 * I/O redirection
 * An editor, such as vi.
 * Many of the Unix utilities
 * An application
 * The touch command, which creates empty files (or updates the "date modified" of existing files)

The valid filename may have (or be):
 * Maximum 255 characters per filename
 * Any character except forward '/'
 * Recommended alphanumeric characters as well as plus, minus, and underscore characters.
 * Case sensitive ('A' and 'a' are treated differently)

Characters to avoid touch my-file -lt touch more drink touch "more drink" touch memo*
 * Hyphen character.
 * White space.
 * Most other special characters !@#$%^&*:;"'}{|\<,>.?~`

Remove files or directories
To remove files or subtree directories, use rm. rm [options] files Files can be a file or a directory.

Common options: -i interactive: prompt for each removal -f force: force the overwriting -r recursive: remove subtree directories and contents There is no 'unremove' or 'undelete' command.

Examples: rm *.[a-z] rm readme readme.orig rm ls /bin rm -rfi /bin cd; rm -rf * .* # This removes all files in the home directory of the current user, as well as those in the subdirectories therein!

Locating files in a subtree directory
To search for a file in a subtree directory, use find. find [subtrees] [conditions] [actions] The command can take multiple conditions and will search recursively in the subtree.

Some possible conditions are: -name [FNG] # Search for the FNG name -type c     # Type of file [bcdfl] -size [+-]# # Has a +- size in blocks (c: bytes, k: kilobytes) -user [name] # Own by user -atime [+-]# # Accessed days ago. +n means the file has not been accessed for the last n days. -n means the file has been accessed in the last n days. -mtime [+-]# # Modified days ago -perm nnn   # Has permision flags nnn Some possible actions are: -print # Print the pathname -exec cmd {} \; # Execute cmd on the file -ok cmd {} \;  # Same as -exec but ask first

Examples: find. -name '*.[ch]' -print find /var /tmp. -size +20 -print find ~ -type c -name '*sys*' -print find / -type f -size +2c -exec rm -i {} \; find / -atime -3 -print find ~jo ~toto -user chloe -exec mv {} /tmp \;

To locate a binary, source file, or man page, use whereis. whereis [options] Common options: -b: Search only for binaries. -m: Search only for manual sections. -s: Search only for sources. Examples: $ whereis host host: /usr/bin/host /etc/host.conf /usr/share/man/man1/host.1.gz $ whereis -m host host: /usr/share/man/man1/host.1.gz

To locate a file located somewhere defined by the PATH variable, use which. $ which -a ls /bin/ls The -a will look for all possible matches in PATH, not just for the first one.

Exercises

 * 1) Compose an interactive command to remove all .tmp files in your home directory. Respond y to every prompt.
 * 2) List all the files in the user's home directories ending with .pdf that are bigger than 50 blocks and have not been accessed for a month.
 * 3) Create a file file.h that will contain all the filenames ending with .h found in the /usr directory.
 * 4) Do a touch on all the c files found in /usr/src/packages directory.
 * 5) What are the default permissions when you create a new file and a new directory?
 * 6) How would you create a new file or directory that contains a space in the filename? (Example: 'new dir')
 * 7) What is the command to remove all the files of types char and block in your home directory?
 * 8) How would you find the location of the program find?
 * 9) Delete all files in /tmp which are not owned by root and have not been accessed for a week.

 * Exercises results


text:
LPI Linux Certification/Use Streams, Pipes And Redirects

Detailed Objective
(LPIC-1 Version 5.0)

Weight: 4

Description: Candidates should be able to redirect streams and connect them in order to efficiently process textual data. Tasks include redirecting standard input, standard output and standard error, piping the output of one command to the input of another command, using the output of one command as an argument for another command and sending output to both standard output and a file.

Key Knowledge Areas:
 * Redirect standard input, standard output and standard error.
 * Pipe the output of one command to the input of another command.
 * Use the output of one command as an argument to another command.
 * Send output to both standard output and a file.

The following is a partial list of the used files, terms and utilities:

Standard input and standard output
For each command executed in a terminal, there is: a standard input value 0 (default keyboard), a standard output value 1 (default terminal), and a standard output for errors value 2 (default terminal).

Each channel can also be identified by an address: &0 for input, &1 for output, And &2 for errors.

Each channel [n] can be redirected. [n]< file: Default value of n is 0 and it reads standard input from file. [n]> file: Default value is 1 and it sends standard output to file, overwriting the file if it exists. (Thus clobbering the file.) [n]>>file: Default value is 1 and it appends standard output to file. < file # out=file, in=none, error=terminal

cat chap* >book # out=book, in=none, error=terminal

mv /etc/*. 2>error # out=terminal, in=none, error=error

echo end of file >> book # out=book, in=none, error=terminal

set -o noclobber # Shell does not clobber existing files.

ls > list 2>&1 # ls and errors are redirected to list.

ls 2>&1 > list # Errors are redirected to standard output and ls output is redirected to list.

cat `ls /etc/*.conf` > conffile 2>>/tmp/errors

Concatenate all the configuration files from /etc dir in conffile and append errors in file /tmp/errors.

Redirecting with pipes

Pipes are an efficient way to apply multiple commands concurrently.

command1 | command2

The standard output of command1 will be piped to the standard input of command2. The standard error is not piped.

Examples: ls -l /dev | more ls -l /etc/*.conf | grep user | grep 500 ls -l /bin | mail `users`

To redirect the standard output to a file and to the terminal at the same time, use tee. ls -l /dev | tee file ls -l /etc | tee -a file # Append to the file

Building arguments

The xargs utility constructs an argument list for a command using standard input.

xargs [options] [command]

The xargs command creates an argument list for command from standard input. It is typically used with a pipe.

Common options: -p: prompt the user before executing each command.

Examples: ls f* | xargs cat # Print to standard output the content of all files starting with f. find ~ -name 'proj1*' print | xargs cat

Search in the home directory for files starting with proj1 and send it to the standard input of cat.

Use the /dev/null device file to discard output or error messages.

Try the following: grep try /etc/* grep try /etc/* 2> /dev/null grep try /etc/* > /dev/null 2> /dev/null

Exercises
1. Create a file list.bin that will contain all the filenames from the /bin directory. 2. Write a command that will append the list of files from /usr/local/bin to the file named list.bin and discard any error output. 3. Split your list.bin file into files that are 50 lines long and remove list.bin. 4. From the split files recreate list.bin (but with inversed order). 5. Simplify the following commands: ls *.c | xargs rm ls [aA]* | xargs cat cat `ls *.v` 2>/dev/null 6. Use find to do the following command: more `ls *.c` 7. Write a command that will create a file list.sbin with the contents of /sbin and at the same time display it to standard output. 8. Create a file that within the filename you include the creation time. 9. Create a file that will contain all the filenames in reverse order with extension .conf from the /etc directory.

 * Exercises results


text:
LPI Linux Certification/Create, Monitor And Kill Processes

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 4

Description: Candidates should be able to perform basic process management.

Key Knowledge Areas:
 * Run jobs in the foreground and background.
 * Signal a program to continue running after logout.
 * Monitor active processes.
 * Select and sort processes for display.
 * Send signals to processes.

The following is a partial list of the used files, terms and utilities:

Create processes
A running application is a process. Every process has: a process ID, a parent process ID, a current directory PWD, a file descriptor table, a program which it is executing, environment variables (inherited from its parent process), stdin, stdout, stderr (standard error), and possibly even more (optional) traits.

Bash is a program that when it is executed becomes a process. Each time you execute a command in a shell a new process is created. Except for the built-in shell command. They run in the shell context. Use type to check if a command is a built-in shell command.

Example:

type cp ls which type

Monitor processes
To monitor the processes in real-time, use top.

top - 9:20am up  2:48,  4 users,  load average: 0.15, 0.13, 0.09 78 processes: 75 sleeping, 3 running, 0 zombie, 0 stopped CPU states: 15.3% user, 0.3% system,  0.0% nice, 84.2% idle Mem:  254896K av,  251204K used,    3692K free,       0K shrd,   27384K buff Swap: 514072K av,       0K used,  514072K free                  120488K cached PID USER    PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND 1517 rarrigon  0   0 40816  39M 17372 R    15.0 16.0   2:59 mozilla-bin 1727 rarrigon 19   0   988  988   768 R     0.3  0.3   0:00 top 1 root     20   0   220  220   188 S     0.0  0.0   0:04 init 2 root     20   0     0    0     0 SW    0.0  0.0   0:00 keventd

RSS is the total amount of physical memory used by the task. SHARE is the amount of shared memory used by the task. %CPU is the task's share of the  CPU  time. %MEM is the task's share of the physical memory. Once top is running it is also possible to execute interactive commands:
 * Type N to sort tasks by pid.
 * Type A to sort tasks by age (newest first).
 * Type P to sort tasks by CPU usage.
 * Type M to sort tasks by memory usage.
 * Type k to kill a process (NOTE: You will be prompted for the process' pid).

Once the system is up and running from a terminal it is possible to see which processes are running with the ps program.

To display a long format of all the processes in the system, use the following:

ps -Al F S  UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD 004 S    0     1     0  0  80   0 -   112 do_sel ? 00:00:04 init 004 S    0   381     1  0  80   0 -   332 do_sel ? 00:00:00 dhcpcd 006 S    0  1000     1  0  80   0 -   339 do_sel ? 00:00:00 inetd 044 R    0  1524  1222  0  79   0 -   761 -      pts/3    00:00:00 ps

The ps program will display all the processes running and their PID numbers and other information. To see a long format of the processes in your login session, use:

ps -l F S  UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD 000 S  500  1154  1139  0  80   0 -   724 wait4  pts/1    00:00:00 bash 002 S  500  1285  1283  0  77   0 - 24432 wait_f pts/1    00:00:00 soffice.bin 040 R  500  1442  1435  0  79   0 -   768 -      pts/4    00:00:00 ps F: Process Flags 002: being created, 040: forked but didn't exec, 400: killed by a signal. S: Process States: R: runnable, S: sleeping, Z: zompbie UID: User ID, PID: Process ID, PPID: Parent Process ID, C: Scheduler, PRI: priority NI: Nice value, SZ: size of routine, WCHAN: name of routine

Kill processes
The ps program will display all the processes running and their PID numbers. Once the PID is known, it is possible to send signals to the process:
 * SIGSTOP to stop a process.
 * SIGCONT to continue a stopped process.
 * SIGKILL to kill a process.

The program to send a signal to a process is called kill.

kill -SIGKILL [pid] kill -63 [pid] kill -l

By default a process is started in the foreground and it is the only one to receive keyboard input. Use CTRL+Z to suspend it.

To start a process in the background use the &. bash & xeyes &

In a bash process it is possible to start multiple jobs. The command to manipulate jobs is jobs. jobs     # List all the active jobs bg %job  # Resume job in background fg %job  # Resume job in foreground kill %job # Kill background job

When bash is terminated all processes that have been started from the session will receive the SIGHUP signal. This will by default terminate the process.

To prevent the termination of a process, the program can be started with the nohup command.

nohup mydaemon

Exercises
1. How can you control CPU usage for PID 3196

 * Exercises results


text:
LPI Linux Certification/Modify Process Execution Priorities

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to manage process execution priorities.

Key Knowledge Areas:
 * Know the default priority of a job that is created.
 * Run a program with higher or lower priority than the default.
 * Change the priority of a running process.

The following is a partial list of the used files, terms and utilities:

Priorities
To start a command with an adjusted priority, use nice. nice -n +2 [command] nice -n -19 [command] The program nice changes the base time quantum of the scheduler. This means it informs the scheduler of how important a process is, which is used as a guide to how much CPU time to give it.

For example, if you wanted to perform another task (such as listening to music) while ripping another CD, you could use the following: nice -n +5 oggenc Were you listening to music, you would not get any “hops” in the music playback, as the scheduler “knows” the oggenc process is less important.

The values can go from -19 (highest priority) to +20 (lowest priority). The default value is 0. Only root can set a value below zero. To modify the priority of a running program, use renice. renice +1 -u root # Change the priority for all root processes. renice +2 -p 193 # Change the priority for PID 193

Exercises

 * Exercises results

 * 1) Which user and root processes are using most of the memory?
 * 2) Same start as 2), but make the print out stop for 3[s] and to continue for 1[s] repeatedly.
 * 3) Make a shell script to renice all processes called apache to a value of 19.
 * 4) Do a print from ps formatted as: “username”, “command”, “nice value”
 * 5) Kill all the processes called “bash” that are owned by user polto.
 * 6) Open two terminals. In one terminal type the following, and from the other terminal see that you can stop and continue the print out:

while [ 1 ] do echo -n The date is:; date; done


text:
LPI Linux Certification/Search Text Files Using Regular Expressions

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to manipulate files and text data using regular expressions. This objective includes creating simple regular expressions containing several notational elements as well as understanding the differences between basic and extended regular expressions. It also includes using regular expression tools to perform searches through a filesystem or file content.

Key Knowledge Areas:
 * Create simple regular expressions containing several notational elements.
 * Understand the differences between basic and extended regular expressions.
 * Understand the concepts of special characters, character classes, quantifiers and anchors.
 * Use regular expression tools to perform searches through a filesystem or file content.
 * Use regular expressions to delete, change and substitute text.

The following is a partial list of the used files, terms and utilities:

Pattern matching
There are two kinds of pattern matching:
 * Wildcards (File Name Generation)
 * Regexp (Regular Expression)

Wildcard characters are mainly applied when they are used in the current directory or subdirectories. When wildcard characters *, ?, [ - ], ~, and ! are used in regexp they no longer generate filenames.

Some of the utilities that use regexp are:
 * grep, egrep
 * vi
 * more
 * sed
 * Perl

Limited regexp search patterns used by all utilities able to use regexp.

 * Any 1 char . Ab.a  Abla or Abca
 * 1 char set [   ] Ab[sd]a  Absa or Abda only
 * 1 char range [ - ] Ab[a-z]a Abaa or Abba or ...
 * Not in set [^ ] Ab[^0-9]a  Abaa or Abba or ...
 * 0 or more * Ab*a  Absala or Aba or ...
 * Begin line ^ ^Aba  Line starts>Aba
 * End line $ Aba$  Aba<line ends
 * Literal \ Aba\$  Aba$

Example: Ab[0-3]s ^Ab\^bA [01]bin$ ^..\\ [^zZ]oro

Combinations of limited regexp combination used by all utilities using regexp.

 * Any string .* Ab.*a  Abrahma or Abaa or ...
 * String from [   ]* th[aersti]* There or This or ...
 * Multi range [ - - ] Ab[0-2][a-c]a Ab0aa or Ab1aa or ...
 * Match \ \\ \\[a-zA-Z]* \Beethoven

Examples: Ab[0-3][a-z]s ...$ ^[01]\^2 [0-9][a-z] \$ [a-zA-Z]* ^[^c-zC-Z]* ^[a-zA-Z0-9]$

Modifier patterns Replace strings matched by regexp patterns

 * Match m \{m\}  b[0-9]\{3\} b911
 * One or more \{m,\} b[0-9]\{2,\} b52
 * Up to n \{m,n\}  b[0-9]\{2,4\} b1234
 * Beginning of word \< \ [0-9]\>  bin01

grep
To find text in a file, use grep.

grep [options] [string] [files]

It is best to quote the string to prevent misinterpretation.

Common options:
 * -i: Ignore case
 * -E: Extended, use regular expressions
 * -l: List filename only if at least one matches
 * -c: Display only count of matched lines
 * -n: Also display line number
 * -v: Must not match.

Examples: grep host /etc/*.conf grep -l '\<mai' /usr/include/*.h grep -n toto /etc/group grep -vc root /etc/passwd grep '^user' /etc/passwd grep '[rR].*' /etc/passwd grep '\<[rR].*' /etc/passwd

sed
To apply a command on a stream, use sed.

sed [address1][,address2][!]command[options] [files...]

The program sed will apply a command from address1 to address2 in a file. The address1 and address2 format is a regular expression.

The sed program is a noninteractive editing tool.

Examples: sed '1,3s/aa/bb/g' file              # Replace in file from lines 1 to 3 'aa' with 'bb'. sed '/here/,$d' file                 # Delete line from here to the end. sed '/here/d' file                   # Delete lines including the word 'here'. sed '1,/xxx/p' file                  # Print lines 1 to xxx. sed '/ll/,/ff/!s/maison/house/g' file # In file replace words 'maison' with 'house' excluding lines from ll to ff.

Exercises

 * Exercises results

 * 1) Process your bookmarks.html file to produce a list containing just the web sites' titles in a file called mywebsites.txt.
 * 2) Copy all the files from /etc into your home directory etc/. Display the contents of all the *.conf files by replacing the word 'host' with 'machine'.
 * 3) Display the contents of all the *.conf files that don't contain the word 'root'. What is the command using grep and sed?
 * 4) Print out all the group names that root belongs to.
 * 5) List all the group names that are 4 or 5 characters long.
 * 6) List all the files that contain character lines without spaces (blank lines).
 * 7) List in the etc/ directory all the files that contain numerical characters.
 * 8) Print with ls only the directory names in /.
 * 9) Do “ps -aux” and replace user r_polto with root and print it to a file called new_process.txt
 * 10) List all processes called 'apache' that are owned by usernames starting with “p” or “P”.


text:
LPI Linux Certification/Perform Basic File Editing Operations Using Vi

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 3

Description: Candidates should be able to edit text files using vi. This objective includes vi navigation, vi modes, inserting, editing, deleting, copying and finding text. It also includes awareness of other common editors and setting the default editor.

Key Knowledge Areas:
 * Navigate a document using vi.
 * Understand and use vi modes.
 * Insert, edit, delete, copy and find text in vi.
 * Awareness of Emacs, nano and vim.
 * Configure the standard editor.

The following is a partial list of the used files, terms and utilities:
 * vi
 * h,j,k,l
 * i, o, a
 * d, p, y, dd, yy
 * ZZ, :w!, :q!
 * ZZ, :w!, :q!

vi
When using X-Windows, you can use mouse oriented editors such as xedit. In a cross-development environment, users use their favorite editor. On a non-windowing system, you only need a keyboard editor such as vi. The vi editor on Linux is the same as on any Unix systems. vi has two modes:
 * Command mode: Anything you type will be interpreted as a command
 * Input mode: Anything you type will be inserted into the file

To transition from Command mode to Input mode, use the i, I, a, A, o, and O keys. To transition from Input Mode to Command Mode, use the ESC key.

The default starting mode is the Command mode.

The file configuration .exrc can be created in your home directory to set up some vi behaviors. set ignorecase # vi will not be case-sensitive set tabs=3    # each tab will be three spaces long set ai        # auto indent set nu        # show line numbers

To perform basic file editing using vi, use the following keys:

 * Move cursor
 * l one space right
 * h one space left
 * j one line down
 * k one line up
 * $ end of line
 * ^ start of line
 * w next word
 * e end of word

 * Enter Input Mode
 * i before cursor
 * I at start of line
 * a after cursor
 * A at end of line
 * o open line below
 * O open line above

 * Delete
 * dw delete word
 * dd delete line
 * D delete to end of line
 * x delete char at cursor

Exercises

 * 1) Use vi from any directory to begin editing an empty buffer.
 * 2) Enter a few lines of text into this buffer.
 * 3) Save the contents of the buffer to the directory.
 * 4) Open the file again with vi.
 * 5) Create a new line beneath what you typed earlier. (Without using i from command mode.)
 * 6) Exit vi without saving these changes.

 * Exercises results


text:
LPI Linux Certification/Create Partitions And Filesystems

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to configure disk partitions and then create filesystems on media such as hard disks. This includes the handling of swap partitions.

Key Knowledge Areas:
 * Manage MBR and GPT partition tables
 * Use various  commands to set up partitions and create various filesystems such as:
 * ext2/ext3/ext4
 * XFS
 * VFAT
 * exFAT
 * Basic feature knowledge of Btrfs, including multi-device filesystems, compression and subvolumes.

The following is a partial list of the used files, terms and utilities:

Partitions
Media can be divided into partitions. Partitions are usually created at installation time but can also be created with the fdisk program or other utilities. This will divide the media into partitions where different filesystems can be built and different operating systems can be installed.

IDE is recognized as follows:

 * Primary Master:
 * /dev/hda : Full disk
 * /dev/hda1: First partition
 * /dev/hda2: Second partition

 * Primary Slave: /dev/hdb
 * Secondary Master: /dev/hdc
 * Secondary Slave: /dev/hdd

SCSI is recognized as follows:

 * ID1:
 * /dev/sda: Full disk
 * /dev/sda1: First partition

 * ID2: /dev/sdb

The Personal computer systems does not support more than four primary partitions, to overcome this limitation, the concept of extended partitions are used.
 * Hard Disk
 * /dev/sda1 : First primary
 * /dev/sda2 : Second Primary
 * /dev/sda3 : Third Primary
 * /dev/sda4 : Extended Partition
 * /dev/sda5 : First extended/Logical
 * /dev/sda6 : Second extended/Logical

USB and FireWire disks are recognized as SCSI disks.

Once it is partitioned it is possible to build a filesystem on every partition.

Filesystems
Filesystems exist to allow you to store, retrieve and manipulate data on a medium. Filesystems maintain an internal data structure (meta-data) that keeps all of your data organized and accessible. The structure of this meta-data imparts the characteristics of the filesystem. A filesystem is accessed by a driver through the organized meta-data structure. When Linux boots it reads in /etc/fstab all the filesystems that need to be mounted and checks if they are in a usable state.

When a power failure occurs Linux won't be able to unmount the filesystem properly and some data in the cache won't be synchronized on the media.

As such, the meta-data may be corrupted.

Once you reboot the system, it will detect this and do a fsck to the full meta-data structure for a consistency check. This can take a very long time. Few minutes to few hours in proportion of the media size. Journaling a filesystem is adding a new data structure called a journal. This journal is on-disk and before each modification to the meta-data is made by the driver it is first written into the journal. Before each meta-data modification the journal maintains a log of the next operation.

Now, when a power failure occurs there is only the need to check the journal. A journaling filesystem recovery is very fast. It just needs to go through the logs and fix the latest operation. Journaling filesystem recovery can take only few seconds.

On a cluster systems, journaling allows to quickly recover a shared partition of a node that went down.

Linux filesystems
...
 * ext2: Old very stable Linux filesystem. Efficient for files larger than ~2-3K.
 * ext3: Journaling extension for ext2. Possible to move a filesystem back and forth between ext2 and ext3.
 * Reiserfs: Journaling filesystem. 8-15 time faster than ext2 when manipulating small files.
 * XFS: A powerful journaling filesystem with possible quota and ACL
 * Msdos: MS-Windows FAT filesystem type. (mainly used for floppy)
 * Vfat: MS-Windows FAT filesystem type. (mainly used for large hdd partitions)
 * NTFS (ReadOnly but loop files): MS-Windows journaling filesystem
 * SMBFS: A filesystem to mount windows or samba sharing from Linux
 * NFS: Network File System

Filesystem tree
A Linux file system has one top directory called root (/) where all sub directories of the entire system is stored. The sub directories can be another partition, a remote directory, or a remote partition accessible through the network with NFS protocol.

Create filesystems
To create a file system on a partition, use mkfs.

mkfs [options] -t [fstype] device [blocksize]

Common options:
 * -t: fstype: File system type.
 * -c : Check the device for bad blocks before building the filesystem.

The full partition will be ereased and organized to the type of filesystem requested. There is no undo command. The fstype possible are: msdos, ext2, ext3, reiserfs,minix,xfs

The blocksize allows to customize the block size for your filesystem.

Examples: mkfs -t msdos /dev/fd0 mkfs -t reiserfs /dev/hdd1 4096

Create extended filesystems
To create an extended (ext2, ext3) filesystem on an partition, use mke2fs.

mke2fs [options] device [blocksize]

Common options:
 * -b: Specify the block sizefstype: File system type.
 * -c : Check the device for bad blocks before building the filesystem.
 * -j: Create the filesystem with an ext3 journal.
 * -L: Set the volume label for the filesystem.

With mke2fs it is possible to store the super-block the journal information on another device. Examples:

mkefs -b 2048 /dev/fd0 -L floppy mkfs -V mke2fs 1.26 (3-Feb-2002) Using EXT2FS Library version 1.263

Monitoring disk usage
To print the disk usage, use du.

du [options] [files...]

Common options:
 * -a: All files not just directories
 * -b: Print size in bytes
 * -c: Total
 * -h: Human readable format. (1K, 20M,...)

Examples:

$ du -ch Documents 112k   Documents/Cours/LPI101 4.0k   Documents/Cours/LPI102 4.0k   Documents/Cours/LPI201 4.0k   Documents/Cours/LPI202 124k   total

du -sk ~ # Sums up your total disk usage in kilobytes

du -ak ~ | sort -n | more # Display every file and its disk space in numerical order.

Filesystem disk space
A filesystem is composed of a meta-data structure plus a list of blocks. To print the filesystem disk space usage, use df.

df [options] [files...]

Common options:
 * -a: All included filesystems with 0 blocks.
 * -t: Limit listing to a filesystem type.
 * -h: Human readable format. (1K, 20M,...)
 * -i: List inode information instead of block usage

Examples:

$ df -t reiserfs -h F          1k-blocks      Used Available Use% Mounted on /dev/hda3             28771528   3121536  25649992  11% /

$ df -t ext2 -h Filesystem           Size  Used Avail Use% Mounted on /dev/hda1              15M  3.8M   10M  27% /boot

$ df -ih /boot Filesystem    Inodes IUsed IFree IUse% Mounted on /dev/hda1        126K   402  125K    1% /boot

Exercises

 * Exercises results


text:
LPI Linux Certification/Maintaining The Integrity Of Filesystems

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to maintain a standard filesystem, as well as the extra data associated with a journaling filesystem.

Key Knowledge Areas:
 * Verify the integrity of filesystems.
 * Monitor free space and inodes.
 * Repair simple filesystem problems.

The following is a partial list of the used files, terms and utilities:

Checking filesystems
To check filesystems consistency, use fsck.

fsck [options] -t [fstype] device [fsck-options]

Common options:
 * -A: Go through the /etc/fstab file and try to check all file systems. Typically  used  at boot time from a script.
 * -t fslist: Specify the type of file system to be checked. With -A,  only  filesystems  that match fslist are checked
 * -C: Display completion/progression bar.

Common fsck-options:
 * -a: Automatically repair.
 * -r: Interactively repair.

Examples:

fsck -t msdos /dev/fd0 -a fsck -t reiserfs /dev/hda2 -r

Checking extended filesystems
To check extended filesystems consistency, use e2fsck.

e2fsck [options] device

Common options:
 * -b: Use an alternate super block filename.
 * -c: This option makes badblocks program to run and marks all the bad blocks.
 * -f: Force checking even if the filesystem seems clean.
 * -a or -p: Automatically repair.
 * -y: non-interactive mode

Examples:

e2fsck -ay /dev/fd0 e2fsck -f /dev/hda2

Debugging extended filesystems
The debugfs program is an interactive file system debugger. It can be used to examine and change the state of an ext2 file system.

debugfs device

Common commands:
 * Help: Give an help on all the command available.
 * Stats: Give a statistics of the media.
 * Stat file: Give a statistic of the file on the media.
 * logdump: Dump the journal's media into a file

Example: stat haut.gif Inode: 14  Type: regular    Mode:  0644   Flags: 0x0   Generation: 67558 User:    0   Group:     0   Size: 3786 File ACL: 0   Directory ACL: 0 Links: 1  Blockcount: 8 Fragment: Address: 0    Number: 0    Size: 0 ctime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 atime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 mtime: 0x3ddf3840 -- Sat Nov 23 09:11:44 2002 BLOCKS: (0-3):55-58 TOTAL: 4

Dumping extended filesystems info
To print the super block and blocks group information of an extended filesystem, use dumpe2fs.

dumpe2fs [options] device

Common options:
 * -b: print the bad blocks of the filesystem.
 * -h: Display only the superblock information.

Example: dumpe2fs -h /dev/fd0 dumpe2fs 1.26 (3-Feb-2002) Filesystem volume name:  floppy Last mounted on: Filesystem state:        clean Errors behavior:         Continue Filesystem OS type:      Linux Inode count:             184 Block count:             1440 Reserved block count:    72 Free blocks:             1258 Free inodes:             168 First block:             1 Block size:              1024 First inode:             11 Inode size:              128 ...

Tuning extended filesystems
To tune an extended filesystem, use tune2fs.

tune2fs [options] device

Common options:
 * -i#: Interval between filesystem checks [d|m|w].
 * -l: List the contents of the filesystem superblock.
 * -L: Set the  volume  label  of  the  filesystem.

Examples: tune2fs -L floppy /dev/fd0 tune2fs -l /dev/fd0 (Same output as dumpe2fs -h /dev/fd0)

tune2fs 1.26 (3-Feb-2002) Filesystem volume name:  floppy Block count:             1440 Reserved block count:    72 Free blocks:             1258 Free inodes:             168 First block:             1 Block size:              1024 First inode:             11 Inode size:              128 ...

Exercises

 * Exercises results

 * 1) Build an ext2 file system, with a block size of 2048 bytes, on a floppy.
 * 2) Change the label of the floppy to BACKUP.
 * 3) Try to add a journal on the floppy media.
 * 4) Use debugfs to validate your floppy file system information, and check when it was last accessed.
 * 5) Use watch to monitor the size when you copy a big file.
 * 6) Create a shell script to list all files on the floppy bigger than 100 Kb.
 * 7) Display file system usage for all MSDOS file systems.
 * 8) Which directory MUST exist in / to qualify this OS as Linux?
 * 9) What is the file system usage of /proc?


text:
LPI Linux Certification/Control Mounting And Unmounting Of Filesystems

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 3

Description: Candidates should be able to configure the mounting of a filesystem.

Key Knowledge Areas:
 * Manually mount and unmount filesystems.
 * Configure filesystem mounting on bootup.
 * Configure user mountable removeable filesystems.
 * Use of labels and UUIDs for identifying and mounting file systems.
 * Awareness of systemd mount units.

The following is a partial list of the used files, terms and utilities:

Attach a filesystem
The mount command serves to attach the file system found on some device to the big file tree.

mount [options] mount [options] [-t vfstype] [-o options] device dir

If the device or directory is listed in /etc/fstab you can use the following:

mount [options] [-o options [,...]] device | dir

Normally only root has the privilege to mount devices unless it is specified in the /etc/fstab file. Examples: mount
 * 1) Print all the mounted filesystems (/etc/mtab).

mount -a
 * 1) Mount devices or dirs listed in /etc/fstab.

mount -n -o ro /dev/hdc /mnt
 * 1) Mount /dev/hdc partition in read only mode without updating /etc/mtab.

mount /media/cdrom mount /dev/cdrom
 * 1) Allow a user to mount the CDROM if the following line is in /etc/fstab:
 * 2) /dev/cdrom /media/cdrom iso9660 ro,user,noauto,unhide

mount -o sync /dev/sdb1 /mnt/usb
 * 1) Sync in realtime

Detach a filesystem
To detach a filesystem from the file tree, use umount.

umount [options] umount [options] [-o options [,...]] device | dir

A busy filesystem cannot be unmounted.
 * Open files
 * Working directory of a process.

Examples: umount -a # Unmount devices or dirs listed in /etc/fstab. umount /mnt # Unmount the filesystem attached to /mnt. umount /media/cdrom # Allow a user to unmount the CDROM if the following line is in /etc/fstab: /dev/cdrom /media/cdrom  iso9660  ro,user,noauto,unhide

File system information
The file /etc/fstab contains all the file systems and related information that will be used when doing a mount -a. (Boot time)

The file /etc/mtab is maintained by the kernel and keeps track on what is or isn't mounted. The /etc/fstab format is:

/dev/hda3  /              reiserfs defaults            1 2 /dev/hda1  /boot          ext2     defaults            1 2 /dev/cdrom /media/cdrom   auto     ro,noauto,user,exec 0 0 usbdevfs   /proc/bus/usb  usbdevfs noauto              0 0 /dev/hda2  swap           swap     pri=42              0 0
 * 1) Device    Mount point    Fs type  Options             1 2

Common options:
 * ro:     read only
 * noauto: Don't mount automatically
 * exec:   Can execute binary on the filesystem
 * suid:   Allow to setuser bit
 * user:   Allow a user to mount/unmount it
 * unhide: hidden file visible
 * async:  All operations will be done asynchronously
 * default: rw, suid, dev, exec, auto, nouser, and async

Exercises

 * Exercises results

 * 1) Create a line in /etc/fstab that allows any user to access the floppy disk. Check that you can mount the floppy and can create a file with touch.
 * 2) Do the following manipulation:
 * 3) * Create a ext2 file system on the floppy.
 * 4) * Mount the floppy.
 * 5) *Copy all the files /etc/*.conf into the floppy.
 * 6) * Unmount it. What's happening?
 * 7) * Mount it back and check that all the files are there.
 * 8) * Issue the following command:
 * 9) * Tar cvf /dev/fd0 /etc/*.conf
 * 10) * Try to mount it back. What's happening?
 * 11) * Use tar to view the contents of the floppy.


text:
LPI Linux Certification/Managing Disk Quota

Detailed Objective
Weight: 1

Description: Candidates should be able to manage disk quotas for users.

 * Key knowledge area(s):
 * Set up a disk quota for a filesystem.
 * Edit, check and generate user quota reports.

 * The following is a partial list of the used files, terms and utilities:
 * quota
 * edquota
 * repquota
 * quotaon

Quotas
On a system, root can manage the usage of disk space per user and per filesystems. The two limits that can be setup are: The soft limit (soft =) specifies the maximum amount of disk usage a quota user is allowed to have. The hard limit (hard =) specifies the absolute limit on the disk usage a quota user can't go beyond it. There is also the possibility to setup a grace period that will enforce the soft limit only after an amount of time specified.

Setting up quotas for users
1) The keyword usrquota or/and grpquota must be added in file /etc/fstab for the partition interested.

/dev/fd0 /home/yann/mnt auto    rw,noauto,user,usrquota 0 0 /dev/hda5 /home    ext2    defaults,usrquota,grpquota 1 2

2) Add in each root filesystems the file user.quota or/and group.quota.

touch /mnt/aquota.user touch /home/aquota.user touch /home/aquota.group chmod 600 /mnt/aquota.user chmod 600 /home/aquota.user chmod 600 /home/aquota.group

Only root can do the quota administration and once the empty files have been created some disk quota can be set such as:
 * Soft limitation on number of files and inodes.
 * Hard limitation on number of files and inodes if the grace time is set.

Setting up quotas for users
3) Check the setting

quotacheck -v mnt quotacheck: Scanning /dev/fd0 [/home/yann/mnt] done quotacheck: Checked 6 directories and 1 files

4) Enable quota on the disk

quotaon -av /dev/fd0 [/home/yann/mnt]: user quotas turned on

5) Customize the disk quota limits:

$ edquota -u yann Disk quotas for user yann (uid 500): Filesystem   blocks       soft       hard     inodes     soft     hard /dev/fd0      15          0          0          4        0        0

$ edquota -g yann

$ edquota -t Grace period before enforcing soft limits for users: Time units may be: days, hours, minutes, or seconds Filesystem            Block grace period     Inode grace period /dev/fd0                     7days                  7days

List quotas
To list quotas for an user or group, use quota.

quota [options] [user|group]

Common options:
 * -u:Default, print user quotas.
 * -g:Print group quotas for the group of which the user is a member.
 * -q: Print a more terse message, containing only information on filesystems where usage is over quota.

Example: quota -u yann

Display a quota report
To display a quota report, use repquota.

repquota [options] [user|group]

Common options:
 * -a: Report on all filesystems indicated in /etc/mtab to be read-write with quotas.
 * -g: Report for group.

Example:

$ repquota /dev/fd0 *** Report for user quotas on device /dev/fd0 Block grace time: 7days; Inode grace time: 7days Block limits                  File limits User           used    soft    hard  grace    used  soft  hard  grace -- root  --       8       0       0              2     0     0 yann  --      15       0       0              4     0     0

Exercises

 * Exercises results

 * 1) Setup a soft limitation for any users that have their home directory in /home to 500M.
 * 2) Change the grace time to 0.
 * 3) Log as the user and check if the limitation works.


text:
LPI Linux Certification/Manage File Permissions And Ownership

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 3

Description: Candidates should be able to control file access through the proper use of permissions and ownerships.

Key Knowledge Areas:
 * Manage access permissions on regular and special files as well as directories.
 * Use access modes such as suid, sgid and the sticky bit to maintain security.
 * Know how to change the file creation mask.
 * Use the group field to grant file access to group members.

The following is a partial list of the used files, terms and utilities:

Changing file owner and group
To change the owner of a file or directory, use chown.

chown yann mon_fichier.txt

To change the group of a file or directory, use chgrp.

chgrp dialout caller

The programs gpasswd and yast2 allow you to administrate groups.

gpasswd [-A user,...] [-M user,...] group
 * -A: Add users with group administrator privileges.
 * -M: Add members in group.

Group administrators can add or delete members of the group

gpasswd -d toto users gpasswd -a toto users

Group administrators can set or remove the password for the group.

gpasswd users gpasswd -r users

More privileges
It is possible to give more privileges to an user when it executes a particular script or program by setting the uid or gid bit of the file.

If the bit is set, the process will inherit the permissions of the owner of the file not the permissions of the user. To set the effective uid or gid, use chmod.

chmod 2640 [file] # (2) gid is inheritable for group. chmod 4640 [file] # (4) uid is inheritable for user.

Example of such program is /bin/passwd.

The sticky bit can also be set and can make the program text segment resident in RAM. chmod 1640 [file] (1) The file program stays in RAM.

File and Directory Permissions
The permission of a file or of a directory can be viewed with ls -l.

Examples of file permissions:

ls -l readme -rwxrw 1 toto users 14 Jul 5 10:00 readme

This means read,write, and execution permissions for user toto, read and write permissions for members of group users. No permissions for others. (0760)

ls -l /etc/hosts -rw-r--r-- 1 root root 14 Jul 5 10:00 /etc/hosts

This means read and write permissions for user root, read permissions for members of group root and all others. (0644)

Examples of directory permissions:

ls -ld /bin drwxr-xr-x 2 root root 4096 Jul 5 10:00 /bin

This means read,write, and execution permissions for user root, read and execution permissions for members of group root and others. (0755)

ls -l /home/toto drwxr-xr-x 10 toto users 4096 Jul 5 1:00 /home/toto

This means read, write, and execution permissions for user toto, read and execution permissions for members of group users and others. (0755)

Default permissions
The default permissions when creating a file are 0666 and when creating a directory are 0777. Most of the systems overwrite this at boot time with the program umask. Generally the mask value is 022. It means the write for group and other will be blocked. To check or change the mask value, do:

umask umask 066

Examples for file: default: rw- rw- rw- (0666) umask: 0 2 2 (0022) Block result: rw- r-- r-- (0644)

Examples for directory: default: rwx rwx rwx (0777) umask: 0 2 2 (0022) Block result: rwx r-x r-x (0755)

Calculating umasks
Finding the correct umask is not all that easy of a process, but certainly doable. The final permission of a file is the result of a logical AND operation between the negation of the umask and the default permission. (The same applies to directories)

In order to visualize this, we translate the octal default permissions into binary form first:

octal: 0666 binary: 000 110 110 110

octal: 0777 binary: 000 111 111 111

Then we take the umask. This time we'll use 0027 for our umaks and translate that into binary. Then invert (~) it.

octal: 0027 binary: 000 000 010 111 ~:     111 111 101 000

Now, to get the actual permission for a file, we logically AND it with the default permissions and translate back into octal:

default permission: 000 110 110 110 ~ umask:           111 111 101 000 logical AND:       000 110 100 000 octal representation: 0640

And the same for directories:

default permission: 000 111 111 111 ~ umask:            111 111 101 000 logical AND:       000 111 101 000 octal representation: 0750

Changing file permissions
To change permissions on a file or directory, use chmod. To overwrite the existing permissions, do:

chmod 0755 /tmp #rwx for user, rx for group and others

To change add or cancel some permissions without overwriting all the existing permissions, do:

chmod u+w readme # Add write permission for user chmod +r readme # Add read permission for everybody chmod -r readme # Remove read permission for everybody chmod u+x,g=r readme # Add execution for user and set read for group chmod u=rwx,go=rx readme # Set read write and execution for user, read and execution for group and others

To change in recursive mode, use the -R option.

chmod -R +x /sbin/*

Exercises

 * Exercises results

1) Write the command line by using letters with chmod to set the following permissions:

rwxrwxr-x : rwxr--r-- : r--r- : rwxr-xr-x : rwxr-xr-x : r-x--x--x : -w-rx : -xrwx :

2) Write the command line by using octal numbers with chmod to set the following permissions:

rwxrwxrwx : --x--x--x : r---w---x : -w--- : rw-r- : rwx--x--x :

3) With the following umask values what would be the files and directories creation permissions?

umask = 0027 File permissions: Directory permissions:

umask = 0011 File permissions: Directory permissions:

umask = 0541 File permissions: Directory permissions:

umask = 0777 File permissions: Directory permissions:

4) Create two user accounts

Logging in id: tst1, group users, with bash shell, home directory /home/tst1 Logging in id: tst2, group public, with bash shell, home directory /home/tst2 For the two accounts set a password.

Logging in as tst1 and copy /bin/ls into tst1 home directory as myls. Change the owner of myls to tst1 and the permissions to 0710. What does this permission value mean?

Logging in as tst2 and try to use /home/tst1/myls to list your current directory. Does it work ?

Create in /etc/group and /etc/gshadow a new group labo with tst1 and tst2. Change the owner group of myls to labo.

Try again from tst2 account to execute /home/tst1/myls to list your current directory. Does it work?

Exercises results


text:
LPI Linux Certification/Create And Change Hard And Symbolic Links

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to create and manage hard and symbolic links to a file.

Key Knowledge Areas:
 * Create links.
 * Identify hard and/or softlinks.
 * Copying versus linking files.
 * Use links to support system administration tasks.

The following is a partial list of the used files, terms and utilities:

Links
Use link when: You want to create a pathname to a file. Set a shorter or fixed pathname to a file.

To link one file to another, use ln:

ln [options] filename linkname ln [options] filename linkdirectory

Common options:
 * -f force: clobber existing link
 * -s symbolic link

The default links are hard links (ln without an option). A hard link can only be created to an existing file on the same physical device, after creation no visible association can be displayed between a link name and a file name.

Symbolic links are like shortcuts in Windows, in the sense that the file may be removed but the link will remain (although useless). Unlike in Windows however, a symbolic link can be created on a file that doesn’t exist yet. The association between the link name and the file name can be viewed with the ls command.

Linking to a file
The symbolic and hard link can be displayed with ls -l. Symbolic link are indicated with an arrow: link_name->real_filename.

$ ls -l /dev/midi lrwxrwxrwx  1   root   root        6    Jul 4 21:50   /dev/midi -> midi00

Hard links are indicated with the number of links counter (3-1=2 in this case).

$ ls -l readme -rwxrwxrwx  3   yann   users       677  Jul 4 21:50   readme

When removing a link name, use rm. Only the link will be removed not the linked file.

Exercises

 * Exercises results

 * 1) Create a directory etc and bin in your home directory.
 * 2) Copy all the files in recursive mode from /etc to your etc directory  and do the same for /bin to bin.
 * 3) In your local etc directory rename all files *.conf by *.conf.bak
 * 4) Create in your home directory a symbolic link called dir that points to your local bin/ls. Check if dir do execute ls.
 * 5) Remove the dir link. Is bin/ls still there?


text:
LPI Linux Certification/Find System Files And Place Files In The Correct Location

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be thoroughly familiar with the Filesystem Hierarchy Standard (FHS), including typical file locations and directory classifications.

Key Knowledge Areas:
 * Understand the correct locations of files under the FHS.
 * Find files and commands on a Linux system.
 * Know the location and propose of important file and directories as defined in the FHS.

The following is a partial list of the used files, terms and utilities:

Filesystem Hierarchy Standard
Filesystem Hierarchy Standard (FHS) defines standard locations for different file types and was adopted by many Unix and Linux distributions. Full description can be found here.

In essence FHS divides files based on 2 criteria: Shareable/unshareable
 * shareable - files which can be stored on one host and used on others. This files do not contain any host specific information. Some examples are binaries under /usr/ or home directories
 * unshareable - files which should not be shared between hosts, for example lockfiles under /var/run define states of processes on a given host so it would make no sense for this information to be shared in normal scenarios (this might be different for software which is aware of existence of other servers sharing the same directory/filesystem)

variable/static
 * static - this are libraries, binaries, documentation and other files which normally do not change without administrator intervention
 * 'variable - this files can change during normal operation. One example are files in /var/run/ directory which might change when services are started and stopped

Below table summarizes main distinction between file types:

Main directories which can be found under / (root) filesystem in Linux are: bin - essential command binaries, required for system to boot boot - static files of the boot loader. See Boot the System section for more information dev - special device files etc - host-specific system configuration lib - essential shared libraries and kernel modules. Files within this directory are required during boot media - mount point for removable media like CD-ROM or USB drives mnt - mount point for mounting a filesystem temporarily opt - add-on application software packages. Usually used by third party software sbin - essential binaries used for system administration, required during boot srv - data for services provided by this system tmp - temporary files var - variable data which includes logfiles and some other frequently changing files usr - secondary hierarchy which might look like: /usr/ ├── bin ├── include ├── lib ├── lib64 ├── local ├── sbin ├── share └── src

Reason for having separate /usr hierarchy is historical. In the past disk space was very limited and many systems were sharing filesystems for example using NFS. /usr was one of the directories shared this way. Because of that reason all files, libraries and kernel modules required for network and NFS to be operational had to be outside of /usr tree.

Most of the files in directories like /bin/, /sbin/ , /usr/bin/ , /usr/sbin/ , /usr/lib/ come from Linux packages (see Use Debian Package Management and Use RPM and YUM package management) and almost never have to be changed manually.

If administrator needs to build software from source normally the best place to install it is under /usr/local/ hierarchy which might look similar to: /usr/local/ ├── bin ├── etc ├── games ├── include ├── lib ├── sbin ├── share └── src

So custom binary files would end up in /usr/local/bin/, libraries in /usr/local/lib/ , configuration files in /usr/local/etc/ and so on.

Find Files and Commands on a Linux System
find - can be used to search directory tree for files and directories meeting certain criteria. It is very powerful command and expressions can be quite complex. find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression] Normally no options are used so command can be similar to: find /var/log -type f -mtime -1 In above example /var/log is path which will be searched. Path is optional and if it is not specified current directory will be used. The rest of the command above is expression. Explicit AND operator is assumed between parts of the expression so in above example command will print files (-type f) which were modified within the last 24 hours (-mtime -1).

Examples List logfiles which were not written to in the last 2 days: find /var/log -type f -mtime +2 List directories within /etc which are owned by UID 0 OR GID 0: find /etc -type d \( -uid 0 -o -gid 0 \) Find files within current directory and subdirectories which do not end with .conf: find -type f ! -name "*.conf" List files bigger than 1MB in /var/log find /var/log -type f -size +1M Find can also be used to perform actions on result files or directories. Command below will remove all backup files from root's home directory: find /root -type f -name "*.bak" -exec rm '{}' \;

locate - reads one or more databases prepared by updatedb and writes file names matching at least one of the PATTERNs. This command is much faster than find because it uses prebuilt database but has some limitations. First of all because it uses static database results are not guaranteed to be accurate. If files were removed or added after the database was created locate will not know about it. Second limitation is search pattern. Find allows for very complex expressions while locate permits only simple pattern match. locate [OPTION]... PATTERN... Common options:
 * -i, --ignore-case - perform case insensitive search
 * -b, --basename - match only the base name against the specified patterns. This is the opposite of --wholename
 * -w, --wholename - match only the whole path name against the specified patterns

Examples Show location all files matching "rc.local": locate rc.local

updatedb - creates or updates a database used by locate. If the database already exists, its data is reused to avoid rereading directories that have not changed. updatedb [OPTION]... Common options:
 * -v, --verbose - output path names of files to standard output, as soon as they are found
 * -e, --add-prunepaths - exclude whitespace separated list of directories from the database

Examples Rebuild the database excluding logfiles: updatedb -e /var/log

/etc/updatedb.conf is a configuration file used by updatedb command described above. It customizes default behavior of updatedb which is normally executed using cron once a day. Example file from Ubuntu Linux looks like: PRUNE_BIND_MOUNTS="yes" PRUNEPATHS="/tmp /var/spool /media" PRUNEFS="NFS nfs nfs4 rpc_pipefs afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf fuse.glusterfs fuse.sshfs ecryptfs fusesmb devtmpfs" Above directives exclude some directories from being indexed (/tmp /var/spool and /media) as well as some filesystems.
 * 1) PRUNENAMES=".git .bzr .hg .svn"

whereis - whereis locates  source/binary  and manuals sections for specified files. whereis [-bmsu] [-BMS directory... -f] filename... Common options:
 * -b - search only for binaries
 * -m - search only for manual sections
 * -s - search only for sources

Examples Display location of binaries and manpages for cp command: whereis cp Print location of tar command manpages: whereis -m tar

which - which returns the pathnames of the files (or links) which would be executed in the current environment. which [-a] filename ... Common options:
 * -a    print all matching pathnames of each argument

Examples Show location of rm binary: which rm


text:
LPI Linux Certification/Install And Configure X11

Detailed Objectives
(LPIC-1 Version 5.0)

Weight: 2

Description: Candidates should be able to install and configure X11.

Key Knowledge Areas:
 * Understanding of the X11 architecture.
 * Basic understanding and knowledge of the X Window configuration file.
 * Overwrite specific aspects of Xorg configuration, such as keyboard layout.
 * Understand the components of desktop environments, such as display managers and window managers.
 * Manage access to the X server and display applications on remote X servers.
 * Awareness of Wayland.

The following is a partial list of the used files, terms and utilities:

Configuration
1. XFree86

type "XFree86 -configure", it will scan your hardware and auto. generate a configuration file matching to your hardware. However, FOR PS/2 MOUSE, you might need to modify this config file manually from ""Device" "/dev/mouse"" to ""Device" "/dev/psaux""

2. Xorg

"Xorg -configure"

Starting and stopping X
To start X you can use: startx - terminal command used at level 3; edit /etc/inittab to run default at level 5; xinit - when there is no .xinitrc file; init 5 - to change manually runlevel to 5 (and run display manager); xdm - (X Display Manager) - graphical login manager, which run automatically at boot process when starting Linux at level 5 (there are also external graphical login managers ex. kdm, gdm).

To stop X you can use: ++; init 3 - at lower level than 5 Linux will stop X-Windows; kill the XFree process.

Configuring X To configure X on a system use XF86Setup. The program will generate a configuration file that will be used by the XFree86 server. To tune the screen under X use Xfine2.

Under X, the user can configure every conceivable aspect of graphic display. Screen font size, styles Pointer behaviour Screen colors Window manager

The tuning can be done on a system-wide or per-user. .xinitrc contains the default window manager and style information to be used by the startx command. This file is usually located under /home/username when defined on a per-user basis. .Xdefaults used to setup pointer behaviour, colors, fonts, etc...

Exercises

 * Exercises results


text:
LPI Linux Certification/Setup A Display Manager

Detailed Objective
Weight: 2

Description: Candidates should be able setup and customize a display manager. This objective covers the display managers XDM (X Display Manger), GDM (Gnome Display Manager) and KDM (KDE Display Manager).

 * Key knowledge area(s):
 * Turn the display manager on or off.
 * Change the display manager greeting.
 * Change default color depth for the display manager.
 * Configure display managers for use by X-stations.

 * The following is a partial list of the used files, terms and utilities:
 * /etc/inittab
 * xdm configuration files
 * kdm configuration files
 * gdm configuration files

Exercises

 * Exercises results


text:
User talk:Bkuhn

Donating "Picking Up Perl" to Wikibook
Hello, I just saw your comment on Talk:Perl Programming and wanted to say you can donate your book here, if your willing to release it under the terms of the GNU Free Documentation License with no invariant sections, no front-cover texts, and no back-cover texts. The best way to provide proof that you agree to releasing it under the GFDL is to change Picking Up Perl so that its clear that anyone can use, modify and redistributed it under the terms of the GFDL and include a link to a copy of the GFDL available on that website. --dark lama  12:41, 23 September 2007 (UTC)

 * Of course it is already licensed that way, and if you download the book text itself indicates clearly the license information in the document. The question is whether or not it should be brought in as its own book or another one.  -- bkuhn 19:59, 21 June 2008 (UTC)

 * If I understand your question, You can donate it as it's own book. You don't need to merge into an existing book or anything. I would even be willing to help with the upload, if you need the help. --Whiteknight (Page) (Talk) 02:34, 7 July 2008 (UTC)

 * Honestly, it seems it is better than the existing Perl Programming book so I have been merging it in. If you think that's a bad idea, let me know.  -- bkuhn 02:38, 7 July 2008 (UTC)

 * Hey, you're the author! Whatever you think is better probably is, and you're right that the Perl Programming book isn't in the best condition. It used to be a good example of progress and collaboration, but it's long been abandoned. Anything you do to make it better will be well appreciated.
 * On a side note, I'm planning to start a book soon about Perl 6. I figure it's significantly different enough from Perl 5 to warrant a separate book. I've been doing some work on a book about Parrot too. If you are interested in either of these projects, let me know. --Whiteknight (Page) (Talk) 02:44, 7 July 2008 (UTC)

title: User talk:Bkuhn


text: User:YinyangJedi

title: User:YinyangJedi


text:
User talk:EvanCarroll

Come introduce yourself at the new users page. If you have any questions, you can ask there or contact me personally. --dark lama  13:19, 23 September 2007 (UTC)

VIN page updates
Looks great. Thanks for creating these!THD3 (talk) 02:36, 8 December 2007 (UTC)

Active Server Pages/What Is ASP
If you still want this page deleted, please provide a reason for deletion, referencing the speedy deletion policy or nominate the page for WB:VFD instead. Thanks! – Mike.lifeguard  | talk 19:26, 5 March 2008 (UTC)

Hi, I was categorizing your pages in the book category of you book (now I created it). --Ramac (talk) 09:28, 2 June 2008 (UTC)

Programming with Moose
Great work on this book! I don't know what all you've seen, but we also have a nice Perl Programming book which is in nice shape, but is becoming a little bit outdated. I've also been working on a Parrot Virtual Machine book, and I've been outlining a book that I want to write about Perl 6. If you're interested in any of these other projects, let me know because it would be awesome to get more perl people working on them. --Whiteknight (Page) (Talk) 23:35, 1 October 2008 (UTC)

Copyright problems with |File:File:BitCardCPAN.png|File:BitCardCPAN.png}}
Please note that screenshots are derived works of the software they depict and need to conform with the stipulations in the software license. Non-free licenses require a valid fair-use rationale. Cheers, --Swift (talk) 19:57, 25 March 2009 (UTC)

title: User talk:EvanCarroll


text:
User:Tomokostone

How can teachers motivate students?

Tomoko Stone

Introduction

Students have different work habits, different abilities, and levels of motivation to learn. These factors influence student’s achievement. Yet, studies show that students who are motivated to learn are the ones to succeed. For this reason, teacher must create the desirable environment and use effective activities to motivate students.

Motivation

Motivation is factors or reasons for engaging in a particular behavior. There two different kinds of motivation – intrinsic motivation and extrinsic motivation. Intrinsic motivation is the inherent tendency to seek out novelty and challenges, to extend and exercise one’s capacities, to explore, and to learn which is related to a positive feature of human nature and curiosity. Extrinsic motivation refers to the performance of an activity in order to attain some separable outcome (Deci & Ryan). When students are intrinsically motivated, they are willingly doing something for enjoyment. When students are extrinsically motivated, they are doing something in order to earn a reward or to avoid a punishment.

Researches

Today students seem to get bored very easily in traditional classroom procedures that are material reading, note taking, and workbook assignment. Today’s students are technology experts. They know how to operate a computer, create PowerPoint, and use software. They play games and are stimulated by visual effects. A national longitudinal study, sponsored by the National Center for Educational Statistics (Rothman, 1990), indicated that too many students believe school-work is boring. When students feel bored, they usually do not have motivation to participate in the learning process. Teachers need to learn new strategies to get students motivated and engage them with the tasks.

How to Motivate Students

How can teacher motivate students? Motivating students is not very easy, but there are many way to motivate students. One of the strategies teachers can use is positive feedback to a student’s tasks. The study of Deci &Ryan showed “positive performance feedback enhanced intrinsic motivation, whereas negative performance feedbacks diminish it (Deci & Ryan). Teachers can catch good things and praise students when they accomplish something instead of giving attentions to mistakes and bad behaviors. Students would be most willing to participate in class rooms where teachers expressed enthusiasm about learning, communicated a belief that all student, can learn, and provided academic and emotional support for students’ understanding (Patrick & Turner). When students understand teacher’s expectations toward them and enthusiasm about learning, they would motivate to participate in the classroom. According to the article of Business Wire (April 13, 2007), teachers who want to motivate students to stay on task, increase their knowledge and skills and improve their ability to process information, must guide the initiation, direction, intensity and persistence of learning behavior. Teachers need to be ready for everyday lesson for well prepared lesson plan, have clear direction and smooth transitions, and handle student’s behaviors to get students on tasks.

Both personal motivation and instructional practices influence a student’s willingness to participate in learning activities (Patrick & Turner, 2004). Hootstein, the author of “Motivating students to learn.” suggests that teachers need to know both what strategies are effective and why they are effective. He indicates the research of eighteen U.S. history teachers at the eighth-grade level in seven schools located in middle-class suburban neighborhoods about what strategy they use to motivate students to learn U.S. history? Table 1 contains the ten most frequently identified motivational strategies. Strategies Used by Teachers to Motivate Students to Learn Number of teachers mentioning strategy Strategy                                        (N = 18) Have students role-play characters in simulations. 15 Organize projects that result in the creation of products. 11 Play games with students for reviews. 8 Relate history to current events or students' lives. 8 Assign students to read historical novels. 8 Use thought-provoking questions. 6 Invite guest speakers from the community. 6 Show videos and films. 5 Organize cooperative learning activities. 5 Provide small-scale hands-on experiences. 5 Note: The interview format used in this study enabled the teachers to identify as many strategies as they wished. (Hootstien)

Hootstien summarized teacher’s motivational strategies. Teacher should •	Provide activities that help students to participate in realistic situations such as participating in events and visualizing clear images. •	Provide students with opportunities for social interaction, hand-on experiences with real materials. •	Provide opportunities that allow students to solve problems in their learning                                                                                activities. •	Make learning relevant by relating the content to the students' needs, goals, interest,                values, and experiences. Another strategy is the use of technology at the middle and high school level. Teacher can use technology to engage and motivate students. Using technology can enhance higher thinking skills. Simulation and interactive software programs give students an opportunity to develop problem solving skills and creative solutions (Case & Dooling, 1997) Conclusion

To be successful in school, students should be motivated and engaged in the task in their learning process. Students learn better with real situation, hand-on activities and technology. Teacher must be aware of motivational strategies to keep students on task by providing challenging, interesting, and interacting learning environment.

Sources

Case, Karen I. & Dooling, Judith O’Donnell. “Integrating Technology into Teacher Preparation Programs.” Teaching Education(Columbia, S.C.) v8 p9-14 Wint/Spr 1997

Deci, Edward L. & Ryan, Richard M. “Self-determination Theory and the Facilitation of Intrinsic Motivation, Social Development, and Well-Being.”  (2000) American Psychologist Vol. 55, No1, 68-78

Hootstein, Edward W. “Motivating students to learn.” The clearing House 67.n4 (March-April 1994): p.p213 (4).

Patrick, Helen; Turner, Julianne C. “Motivational Influences on Students Participation in Classroom Learning Activities.”  Teachers College Record 106 no9 1759-85 S 2004

Rothman, R. 1990. Educators focus attention on says to boost student motivation. Education Week (Nov. 7): 11-13.

“Technology and Motivation: Can computer motivate students to Read?” Business Wire (April 13, 2007)

Website: (http://en.wikipedia.org/wiki/motivation) Do not train children to learning by force and harshness, but direct them to it   by what amuses their minds, so that you may be better able to discover with accuracy the peculiar bent of the genius of each. -- Plato Multiple Choice Questions

1) Marina is always doing more than what is required in her classes. She has the desire to get good grades and to be a lawyer.  What type of motivation does Maria have?

A. extrinsic motivation B. intrinsic motivation C. self motivation D. social motivation

2) In order for John to pass math class, he has to get a B on his next test. John wants to avoid failing and consequence, so he studies every day for a week.  What types of motivation does he demonstrate? A. extrinsic motivation B. intrinsic motivation C. self motivation D. social motivation

3) Lisa is having a hard time with school. Her parents promise to give a reward if she gets 2 A’s.  This motivation is an example of:

A. extrinsic motivation B. intrinsic motivation C. self motivation D. social motivation

4) Paul is a fifth grader and checks out three books at the library about dinosaurs because he enjoys learning about this subject. Paul demonstrates which type of motivation?

A. extrinsic motivation B. intrinsic motivation C. self motivation D. social motivation

5) What way would be best to prevent boredom in students during a history lesson?

A. Class notes taken from the overhead B. Role play and dressing up to act out the real event C. Questions given on a worksheet to be answered during a lecture D. Reading a textbook

Answer to Multiple Choice Questions

1. B   2. A 3. A 4. B 5. B

Essay Question:

What is the best strategy to prevent boredom in students in the class based on your experiences or knowledge?

I think the best strategy is to keep students engaged with challenging tasks or interesting activities related to the teaching content area. Teachers should motivate and encourage students to be engaged with technology, hand-on activities, role play or field trips. When students take notes or read a material to do worksheets, they get bored very easily. Today students are surrounded by technology in their everyday lives. Teachers need to integrate technology into the lessons. When students use computers and search for the answer, they seem to be very engaged. When students respond using respond pad or smart board to answer questions, they seem to be occupied. Another way to motivate students be engaged is to integrate real materials for the subject. As a language teacher, I introduce the culture of the language. When students learned about food, I brought chop sticks and cotton boll (you can use marshmallows) for students to experience chop sticks. They were so excited. Since I think that reading materials and writing sentences are parts of the lessons and important as much as hand-on activities, role-play, or field trip, I try to integrate reading, writing, hand-on activities, role play, and technology to keep students engaged.

title: User:Tomokostone


text:
Template:Quotes

—

title: Template:Quotes