Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Manual pages
http://linuxmanpages.com
man <command> man <section> <command> man uses the less pager Manual sections
Space Esc + V / Q
1 2 3 4 5 6 7 8 9
Excutable programs System calls Library calls Device files File formats Games Miscellaneous System administration commands Kernel routines
passwd command section 1 man passwd man 5 passwd /etc/passwd file section 5
rm, rmdir
Delete
Locate
find, locate
Compress
View
less, ls
tar, cpio
Copy
cp, dd
mv
General notions
Linux is case sensitive Filename.txt <> filename.txt Filenames can contain any character. Filenames can be 255 characters long. filesystem dependent Special filenames . current directory .. parent directory
$ $ $ $ $ $ cd /usr/bin pwd cd . pwd cd .. pwd
Filenames should never contain wildcards: * ? \ quotations: $ touch fileone filetwo path separator: / $ touch file*
$ rm file*
A wildcard stands in place of a group of characters Wildcards Wildcard expansion = file globbing * zero or more characters ? only one character Replacing an wildcard with chars to obtain [] character set file names in the current directory
Linux shell
Shell implementations Bourne Again Shell
bash bsh most common Bourne Shell In linux tcsh C Shell csh Korn Shell ksh Z Shell zsh
$ ls l /bin/sh $ ls l /bin/*sh
Linux shell
Command Completion TAB
$ less ~/.bash_history
~/.bash_history
Command History History Search
UpArrow
DownArrow history history c Line editing
Ctrl + P
Ctrl + N display all history clear history
move
delete
Ctrl+A
Ctrl+E
Del
Ctrl+K
Environment variables
means of passing named data set a variable
$ export HOSTNAME=lpic.credis.ro $ HOSTNAME=lpic.credis.ro $ export HOSTNAME When retrieving the value of a variable precede the variable name with a '$' character
read a variable
$ echo $HOSTNAME $ env
SHELL
ENV
CHILD SHELL
Common environment variables: USER/USERNAME - Username of current user SHELL - Path to the current command shell PWD - Present Working Directory HOSTNAME - TCP/IP name of the computer HOME - Home directory of current user PATH - List of directories where executables are found PS1 - Default prompt in bash DISPLAY - The display used by X (:0.0) EDITOR - The default text editor
append
<> program
>
>>
Discard errors
pipe
Exercises
1. An administrator runs a program and he wants to log the errors into the error.log file but also display them in the shell. What command could he use? 2. Consider the following command: $ touch data01 data02 data11 data12 data13 What are the commands (use different wildcards) for the following tasks: Delete data01 and data02 Delete data11 and data13 Delete all data files 3. One installs some programs in the /opt/progs directory. What could be done such that these programs can be executed without specifying the entire path? (Write a command). 4. Write a command that you could use to create a backup of the systems configuration files.