Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
F I N
Plus de contenu associé
Transcription de la présentation
UNIX/Linux CIS140U Winter 2009 Gary DeRoest Gary DeRoest
Schedule (general) Part 1: Ways to automate alias, script files, join, awk Part 2: Tools to organize pipes, redirection, grep, uniq, comm, sed, pr, cut, sort, tr Part 3: bash tools if, then, else, test, case, for, let, while, tput cup Part 4: Building an application Gary DeRoest
Schedule (general) Part 5: Installation - SLES 9 YAST, YOU, tar, rpm, cpio Part 6: Boot/Service/User Configuration setup, chkconfig, service Part 7: User/Group configuration tools useradd, usermod, userdel groupadd, groupmod, groupdel GUI tools Part 8: Configuration Documentation Gary DeRoest
Schedule (general) Part 9: Process Management fg, bg, jobs, ps, top Part 10: Administration Responsibilities Part 11: Security Concerns Gary DeRoest
Alias’s A keyboard shortcut for frequently used or long commands. Aliases are processed before internal and external commands Gary DeRoest
Alias Examples For Bash Shell • alias c=‘clear’ • alias ll=‘ls -lA | more’ • alias dir=‘c; ls -l’ • alias cd=‘who -iH’ • cd • unalias cd • alias Gary DeRoest
Viewing All Aliases • alias [garyd@bct2 bin]$ alias alias l.='ls -d .[a-zA-Z]* alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias vi='vim' [garyd@bct2 bin]$ Gary DeRoest
Remembering Aliases Aliases can be set automatically each time you log in Your home directory contains a hidden file named .bashrc which is the usual place where users define aliases .bashrc is executed each time you log in. Any alias definitions will then be defined automatically Gary DeRoest
~/.bashrc An unmodified .bashrc file might look like this # .bashrc # User specific aliases and functions # Source global definitions if [ -f /etc/bashrc]; then . /etc/bashrc fi Gary DeRoest
.bashrc - Adding Your Own Stuff A modified .bashrc file might look like this # .bashrc # User specific aliases and functions alias c=‘clear’ alias md=‘mkdir’ alias cp=‘cp -i’ # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi Gary DeRoest
/etc/bashrc • Aliases are generally assigned by individual users • Administrators may wish some aliases set for all users • Global aliases are set in a file in the /etc directory • /etc/bashrc • /etc/bashrc is owned and modified by root Gary DeRoest
FAQ I changed my .bashrc file - so why aren’t my aliases working? The .bashrc file is executed when you log into the server. Making changes to .bashrc will not be noticed until you exit and log back in to the server Gary DeRoest
Script file • A sequence of UNIX commands that you wish to execute can be saved to a text file • This text file must be executable • This text file should be in a directory named in the search PATH • The files ~/.bashrc and ~/.bash_profile are two examples of bash shell scripts (or programs) Gary DeRoest
Bash Scripts viscript1 clear echo -n Welcome to my world. date save the file :x make the file executable chmodu+x script1 execute the program [gd@bct2~]$ script1 or [gd@bct2~]$ ./script1 Gary DeRoest
Bash Scripts In addition to executing external programs like‘who’,‘cal’,and‘sort’,each UNIX or Linux shell has its own set of internal commands and functions. cd, alias, echo, history, set, fg, test, andpwdare internal commands to the bash shell and my not be available in other shell programs. Gary DeRoest
Search through Files fileE John Henry Joe Montana Henry Ford Sam the Eagle grep “John” fileE output John Henry Gary DeRoest
Search through Files grep -i “h” fileE fileE John Henry Joe Montana Henry Ford Sam the Eagle output John Henry Henry Ford Sam the Eagle Gary DeRoest
Search through Files output 2 grep -c “n” fileE grep -n “y” fileE output 1 John Henry 3 Henry Ford fileE John Henry Joe Montana Henry Ford Sam the Eagle grep “[HS]” fileE output John Henry Henry Ford Sam the Eagle Gary DeRoest
Search through Files grep “Jo..” fileE output John output John Joe Henry Sam fileF John Joe Henry Sam grep “...” fileE output Joe Sam grep -x “...” fileE Gary DeRoest
joincommand Used to combine files using key fields. Relational database tools. 4 Greg 1 Gary 2 Paul 3 Sam 2 McCartney 3 the Eagle 1 DeRoest 4 Brady Gary DeRoest
join command Step one: Sort files on their key fields first last 1 Gary 2 Paul 3 Sam 4 Greg 1 DeRoest 2 McCartney 3 the Eagle 4 Brady Gary DeRoest
join command Step two: use the join command to link key fields and display desired output. join -a1 -1 1 -2 1 -o 1.2 –o 2.2 first last 1 Gary 2 Paul 3 Sam 4 Greg 1 DeRoest 2 McCartney 3 the Eagle 4 Brady Gary DeRoest
join command join –a1 –1 1 –2 1 –o 1.2 –o 2.2 first last 1 Gary 2 Paul 3 Sam 4 Greg File 1 to be joined with file 2 File 1 has key in column 1 File 2 has key in column 1 Print out from file 1, field 2 Print out from file 2, field 2 1 DeRoest 2 McCartney 3 the Eagle 4 Brady Names of file 1 and file 2 Gary DeRoest
join command join –a1 –1 1 –2 1 –o 1.2 –o 2.2 first last 1 Gary 2 Paul 3 Sam 4 Greg 1 DeRoest 2 McCartney 3 the Eagle 4 Brady Gary DeRoest Paul McCartney Sam the Greg Brady Gary DeRoest
join command join –a1 –1 1 –2 1 –o 1.1 –o 2.2 first last 1 Gary 2 Paul 3 Sam 4 Greg 1 DeRoest 2 McCartney 3 the Eagle 4 Brady 1 DeRoest 2 McCartney 3 the 4 Brady Gary DeRoest
join command join –a1 -t: –1 1 –2 1 –o 2.2 –o 1.1 first last 1:Gary 2:Paul 3:Sam 4:Greg 1:DeRoest 2:McCartney 3:the Eagle 4:Brady DeRoest 1 McCartney 2 the Eagle 3 Brady 4 Gary DeRoest
join command 1:Gary 2:Paul 3:Sam 4:Greg join –a1 -t: -e “No Match” –1 1 –2 1 –o 1.2 –o 2.2 –o 1.1 first last 1:DeRoest 2:McCartney 4:Brady Gary DeRoest 1 Paul McCartney 2 Sam No Match 3 Greg Brady 4 Gary DeRoest
join command 1:Gary 2:Paul 3:Sam 4:Greg join –a1 -t: -e “No Match” –1 1 –2 1 –o 1.2 –o 2.2 –o 2.1 first last 1:DeRoest 2:McCartney 4:Brady Gary DeRoest 1 Paul McCartney 2 Sam No Match No Match Greg Brady 4 Gary DeRoest
join command 1:Gary 2:Paul 3:Sam 4:Greg join –a2 -t: -e “No Match” –1 1 –2 1 –o 1.2 –o 2.2 –o 2.1 first last 1:DeRoest 2:McCartney 4:Brady Gary DeRoest 1 Paul McCartney 2 Greg Brady 4 Gary DeRoest