CIS 90 Lesson 14 Lesson Module Status Slides

  • Slides: 71
Download presentation
CIS 90 - Lesson 14 Lesson Module Status • Slides – • Properties •

CIS 90 - Lesson 14 Lesson Module Status • Slides – • Properties • Flash cards – • No-stress quiz – • Web calendar summary – • Web book pages – • Commands – • Lab – done • Supplies () • Class PC's – • Scripts () –

CIS 90 - Lesson 14 Quiz No Quiz Today !

CIS 90 - Lesson 14 Quiz No Quiz Today !

CIS 90 - Lesson 14 The UNIX/Linux File System Objectives Agenda • Use conditionals

CIS 90 - Lesson 14 The UNIX/Linux File System Objectives Agenda • Use conditionals in scripts • Transfer files between computers • Archive directories using tar • No Quiz - warmup exercise instead • Questions from last week • scp • More scripting • Tarballs • Wrap up = hands on exercise for topic

CIS 90 - Lesson 14 Previous material and assignment 1. Questions? 2. No labs

CIS 90 - Lesson 14 Previous material and assignment 1. Questions? 2. No labs due today 3. Check grades page 4. Check your class/labs/ directory on Opus for graded work

CIS 90 - Lesson 14 Warmup Exercise Find the hidden treasure trove • Find

CIS 90 - Lesson 14 Warmup Exercise Find the hidden treasure trove • Find the treasure buried in you Hidden folder. • When you find it make sure only you can read it and nobody can modify it.

CIS 90 - Lesson 14 scp

CIS 90 - Lesson 14 scp

CIS 90 - Lesson 14 Classroom PC's, VMs and Remote Server Opus One RHEL

CIS 90 - Lesson 14 Classroom PC's, VMs and Remote Server Opus One RHEL 5 server per class Internet One RH 9 Linux VM per laptop One Windows laptop per student SSH is a network protocol that enables secure connections between computers

CIS 90 - Lesson 14 Telnet and SSH (Secure Shell) Opus SSH - encrypted

CIS 90 - Lesson 14 Telnet and SSH (Secure Shell) Opus SSH - encrypted Telnet - all clear text Sniffer view of a Telnet session Sniffer view of a SSH session username password cat secret exit Local computer

CIS 90 - Lesson 14 ssh protocol Secure Shell Protocol • Allows secure (encrypted

CIS 90 - Lesson 14 ssh protocol Secure Shell Protocol • Allows secure (encrypted connections between computers) • ssh command – secure login and terminal sessions • scp command – secure file copies between computers /

CIS 90 - Lesson 14 scp Copy commands copy file(s) to a Destination •

CIS 90 - Lesson 14 scp Copy commands copy file(s) to a Destination • cp ‒ copies files on the same computer ‒ examples: cp myscript. v 1 backups/ cp /home/cis 90/simmsben/bin/myscript benscript • scp ‒ copies files between computers: ‒ examples: scp roddyduk@opus. cabrillo. edu: myscript. / scp lab 45 roddyduk@opus. cabrillo. edu: lab 45 scp lab 45 roddyduk@opus. cabrillo. edu:

CIS 90 - Lesson 14 scp command 1 st argument (from) 2 nd argument

CIS 90 - Lesson 14 scp command 1 st argument (from) 2 nd argument (to) scp roddyduk@opus. cabrillo. edu: bin/myscript scp lab 45 roddyduk@opus. cabrillo. edu: lab 45 scp lab 45 roddyduk@opus. cabrillo. edu: .

CIS 90 - Lesson 14 scp Remote scp roddyduk@opus. cabrillo. edu: bin/myscript Copy the

CIS 90 - Lesson 14 scp Remote scp roddyduk@opus. cabrillo. edu: bin/myscript Copy the file myscript from roddyduk's home bin/ directory on the remote system Opus to "here" Local .

CIS 90 - Lesson 14 scp Remote scp Local roddyduk@opus. cabrillo. edu: bin/myscript .

CIS 90 - Lesson 14 scp Remote scp Local roddyduk@opus. cabrillo. edu: bin/myscript . Path to file. Relative to user's home directory. Either the IP address or hostname of the remote computer. Need to connect to system on the Internet The username on the remote computer. Needed to login and this defines the home directory for the relative path to the file

CIS 90 - Lesson 14 scp Logged in to two different systems Local Linux

CIS 90 - Lesson 14 scp Logged in to two different systems Local Linux System Opus /

CIS 90 - Lesson 14 scp Local Linux System Performing scp copy from Opus

CIS 90 - Lesson 14 scp Local Linux System Performing scp copy from Opus to local Red hat system Opus /

CIS 90 - Lesson 14 scp Catting files on both systems to verify the

CIS 90 - Lesson 14 scp Catting files on both systems to verify the copy Local Linux System Opus /

CIS 90 - Lesson 14 Class Exercise scp • Start up the local VM

CIS 90 - Lesson 14 Class Exercise scp • Start up the local VM on the laptops and login as cisco • Use Putty and login to your account on Opus • Copy the files banner and myscript from your bin directory on Opus scp logname@opus. cabrillo. edu: bin/myscript. scp logname@opus. cabrillo. edu: bin/banner. • Create a bin directory on your local VM (if needed) mkdir bin • Move banner and myscript to your local VM bin directory mv banner myscript bin/ • Check path and permissions to make insure /home/cisco/bin is in your path and that myscript and banner have execute permission set. echo $PATH ls –l /home/cisco/bin/ • Run the script you made on Opus on your local VM myscript

CIS 90 - Lesson 14 To copy multiple files, use the * expansion character

CIS 90 - Lesson 14 To copy multiple files, use the * expansion character Note, this will copy files, but not directories

CIS 90 - Lesson 14 To recursively copy files and directories use the –r

CIS 90 - Lesson 14 To recursively copy files and directories use the –r option Now all files and directories will be copied

CIS 90 - Lesson 14 Class Exercise scp • Copy all the files and

CIS 90 - Lesson 14 Class Exercise scp • Copy all the files and directories in your Opus bin directory to your local bin directory scp –r logname@opus. cabrillo. edu: bin/* /home/cisco/bin/ • Now see if you can copy your entire poems directory on Opus to a new poems directory in your local cisco home directory. When finished write the commands you used on the whiteboard.

CIS 90 - Lesson 14 scripting

CIS 90 - Lesson 14 scripting

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 date ;

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 date ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) 5) 6) Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Wed Dec 3 14: 00: 53 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello $LOGNAME" date ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) 5) 6) Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Hello roddyduk Wed Dec 3 14: 07 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) 1) 2) 3) 4) 5) 6) #

CIS 90 - Lesson 14 myscript 3) 1) 2) 3) 4) 5) 6) # Commands for Task 3 echo "Hello $LOGNAME" echo $(cat /etc/passwd | grep $LOGNAME) date ; ; Duke's CIS 90 Final Project Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Hello roddyduk: x: 1156: 103: Duke Roddy: /home/cis 90/roddyduk: /bin/bash Wed Dec 3 14: 07 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello $LOGNAME" echo $(cat /etc/passwd | grep $LOGNAME | cut -f 5 -d": " ) date ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) Color My Find Command More practice Duke's friend made this one - Thank You 5) Task 5 6) Exit Enter Your Choice: 3 Hello roddyduk Duke Roddy Wed Dec 3 14: 07 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello $LOGNAME" NAME=$(cat /etc/passwd | grep $LOGNAME | cut -f 5 -d": " ) echo "Hello $NAME" date ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) 5) 6) Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Hello roddyduk Hello Duke Roddy Wed Dec 3 14: 07 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 echo "Hello $LOGNAME" NAME=$(cat /etc/passwd | grep $LOGNAME | cut -f 5 -d": " ) echo "Hello $NAME" date ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) 5) 6) Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Hello Duke Roddy Wed Dec 3 14: 07 PST 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 Class Exercise Scripting • Make a short script that

CIS 90 - Lesson 14 Class Exercise Scripting • Make a short script that does the following: • Get and displays the user's name • Runs one command

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 NAME=$(cat /etc/passwd

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 NAME=$(cat /etc/passwd | grep $LOGNAME | cut -f 5 -d": " ) echo "Hello $NAME" date '+%A' date '+%A, %B %d, %Y' ; ; Duke's CIS 90 Final Project 1) 2) 3) 4) 5) 6) Color My Find Command More practice Duke's friend made this one - Thank You Task 5 Exit Enter Your Choice: 3 Hello Duke Roddy Wednesday, December 03, 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 NAME=$(cat /etc/passwd

CIS 90 - Lesson 14 myscript 3) # Commands for Task 3 NAME=$(cat /etc/passwd | grep $LOGNAME | cut -f 5 -d": " ) echo "Hello $NAME" echo "$NAME, Do you like short or long dates? " echo -n "Enter 1 for short or 2 for long: " read ANSWER if [ "$ANSWER" = 1 ]; then date '+%A' else date '+%A, %B %d, %Y' fi ; ; Enter Your Choice: 3 Hello Duke Roddy, Do you like short or long dates? Enter 1 for short or 2 for long: 1 Wednesday Hit the Enter key to return to menu Enter Your Choice: 3 Hello Duke Roddy, Do you like short or long dates? Enter 1 for short or 2 for long: 2 Wednesday, December 03, 2008 Hit the Enter key to return to menu

CIS 90 - Lesson 14 Class Exercise Scripting • Modify your script to do

CIS 90 - Lesson 14 Class Exercise Scripting • Modify your script to do the following: • Ask the user a question • Use a conditional (if statement) that users the users response.

CIS 90 - Lesson 14 tar

CIS 90 - Lesson 14 tar

CIS 90 - Lesson 14 tar command options (no – needed) c tar tvf

CIS 90 - Lesson 14 tar command options (no – needed) c tar tvf x archive files to backup tarfile(s) create table of contents (view) extract v = verbose, double v (vv) provides more information Note: The full path to each file is stored in the archive and these paths are used when restoring files

CIS 90 - Lesson 14 tar command Single file example [root@benji ~]# cd /opt/lampp/htdocs/

CIS 90 - Lesson 14 tar command Single file example [root@benji ~]# cd /opt/lampp/htdocs/ [root@benji htdocs]# ls -l sample. html -rw-r--r-- 1 root 194 Oct 24 10: 13 sample. html [root@benji htdocs]# cat sample. html <html> <head> <title>My first page</title> </head> <body> <h 1>My first web page</h 1> <p>Nothing can stop me now</p> <a href="http: //google. com">My link to Google</a> </body> </html> [root@benji htdocs]# tar cvf /root/sample. tar sample. html [root@benji htdocs]# ls -l /root/sample. tar -rw-r--r-- 1 root 10240 Nov 22 08: 56 /root/sample. tar [root@benji htdocs]# rm sample. html rm: remove regular file `sample. html'? y [root@benji htdocs]# tar tvf /root/sample. tar -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10 sample. html [root@benji htdocs]# tar xvf /root/sample. tar sample. html [root@benji htdocs]# ls -l sample. html -rw-r--r-- 1 root 194 Oct 24 10: 13 sample. html [root@benji htdocs]# cat sample. html <html> <head> <title>My first page</title> </head> <body> <h 1>My first web page</h 1> <p>Nothing can stop me now</p> <a href="http: //google. com">My link to Google</a> </body> </html> [root@benji htdocs]# Backup a web page file Oops! – file gets deleted View backed up file Restore the file

CIS 90 - Lesson 14 tar command Single file example verbose create file to

CIS 90 - Lesson 14 tar command Single file example verbose create file to back up (requires full path) tarfile to use tar cvf /root/sample. tar sample. html verbose tarfile to use view (table of contents) tar tvf /root/sample. tar -rw-r--r-- root/root 10: 13: 10 sample. html verbose extract tarfile to use 194 2008 -10 -24 file in archive to restore (requires full path) tar xvf /root/sample. tar sample. html

CIS 90 - Lesson 14 tar command Pay attention to the path stored in

CIS 90 - Lesson 14 tar command Pay attention to the path stored in the tarfile Creating the tarfile from another directory using absolute path [root@benji ~]# tar cvf sample 2. tar /opt/lampp/htdocs/sample. html tar: Removing leading `/' from member names /opt/lampp/htdocs/sample. html Note, the leading / gets stripped [root@benji ~]# tar tvf sample 2. tar -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10 opt/lampp/htdocs/sample. html [root@benji ~]# This path is used when restoring files Creating the tarfile from another directory using relative path [root@benji ~]# tar cvf sample 2. tar. . /opt/lampp/htdocs/sample. html tar: Removing leading `. . /' from member names Note, the leading. . / gets stripped. . /opt/lampp/htdocs/sample. html [root@benji ~]# tar tvf sample 2. tar -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10 opt/lampp/htdocs/sample. html [root@benji ~]# This path is used when restoring files

CIS 90 - Lesson 14 tar command -C option tar -C dir tarfiles(s) -xvf

CIS 90 - Lesson 14 tar command -C option tar -C dir tarfiles(s) -xvf -x The –C option can be used to set the starting directory for file to be restored to. Add a – to the other options as well

CIS 90 - Lesson 14 tar command -C option Find file to restore in

CIS 90 - Lesson 14 tar command -C option Find file to restore in archive [root@benji ~]# tar tf htdocs. tar | grep jp. php. /xampp/lang/jp. php Change to the directory where the backup was made [root@benji lang]# cd /opt/lampp/htdocs/ [root@benji htdocs]# tar xvf /root/htdocs. tar. /xampp/lang/jp. php [root@benji htdocs]# Or use the –C option to restore from another directory [root@benji ~]# tar -C /opt/lampp/htdocs/ -xvf htdocs. tar. /xampp/lang/jp. php [root@benji ~]#

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/htdocs

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/htdocs directory. 2. Backup sample. html using: tar cvf /root/sample. tar sample. html 3. Verify your tarfile contains sample. html What is the path to sample. html in the tarfile? [Table 1 -4] 4. Delete then practice restoring sample. html: q To its original location Where did you have to be to do this? [Table 9 -12] q To the /tmp directory Where did you have to be to do this? [Table 17 -20] 5. Now use the tar man page to check out the –C directory option. q Delete the sample. html in the /tmp directory q Restore sample. html from /root to the /tmp directory with the –C option. What command did you use [Table 5 -9]?

CIS 90 - Lesson 14 tar command Directory example [root@benji htdocs]# tar cvf /root/htdocs.

CIS 90 - Lesson 14 tar command Directory example [root@benji htdocs]# tar cvf /root/htdocs. tar. . /sample. html. /. /webalizer/ . /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl Backup up files (including hidden and sub-directories) starting from "here" Note how tar saves full path for each file backed up . /xampp/iart. php. /. hidden Delete some files [root@benji htdocs]# rm xampp/iart. php. hidden sample. html rm: remove regular file `xampp/iart. php'? y rm: remove regular empty file `. hidden'? y rm: remove regular file `sample. html'? y [root@benji htdocs]# tar tvf /root/htdocs. tar. /xampp/iart. php. /. hidden. /sample. html -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10. /sample. html Verify they were -rw-r--r-- root/root 3004 2006 -11 -10 08: 57: 01. /xampp/iart. php backed up -rw-r--r-- root/root 0 2008 -11 -22 09: 23: 17. /. hidden [root@benji htdocs]# tar xvf /root/htdocs. tar. /xampp/iart. php. /. hidden. /sample. html. /xampp/iart. php Restore the files that were deleted. /. hidden. /favicon. ico. /index. html

CIS 90 - Lesson 14 create verbose tarfile to use files to back up

CIS 90 - Lesson 14 create verbose tarfile to use files to back up (starting point) tar cvf /root/htdocs. tar. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl . /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php tar command Directory example . /xampp/guestbook-es. pl. /xampp/languages. php. /xampp/guestbook-de. pl. /xampp/lang/jp. php. /xampp/phpinfo. php. /xampp/splash-logo. php. /xampp/splash. php. /xampp/langsettings. php. /xampp/guestbook-pt_br. pl. /xampp/. version. /xampp/guestbook. dat. /xampp/status. php. /xampp/charset. php. /xampp/phonebook. php. /xampp/test. php. /xampp/img/. /xampp/softwarelist. inc. /xampp/img/rb. gif. /xampp/guestbook-it. pl. /xampp/img/status 3. gif. /xampp/cds-fpdf. php. /xampp/img/logo-small. gif. /xampp/ssi. inc. /xampp/img/logo-small. jpg. /xampp/php. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/sqlite/cdcol. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp/img/status 4. gif. /xampp. css. /xampp/img/rt. gif. /xampp/ming. php. /xampp/img/strichel. gif. /xampp/showcode. php. /xampp/img/head-linux. gif. /xampp/guestbook-fr. pl. /xampp/img/head-xampp. gif. /xampp/guestbook-en. pl. /xampp/img/xampp-logo. jpg. /xampp/iart. php. /xampp/img/head-fuer. gif. /. hidden. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /favicon. ico. /index. html. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif

CIS 90 - Lesson 14 tar command Directory example view (table of contents) verbose

CIS 90 - Lesson 14 tar command Directory example view (table of contents) verbose tarfile Files to find in archive [root@benji htdocs]# tar tvf /root/htdocs. tar. /xampp/iart. php. /. hidden. /sample. html -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10. /sample. html -rw-r--r-- root/root 3004 2006 -11 -10 08: 57: 01. /xampp/iart. php -rw-r--r-- root/root 0 2008 -11 -22 09: 23: 17. /. hidden extract verbose tarfile Files to find to extract [root@benji htdocs]# tar xvf /root/htdocs. tar. /xampp/iart. php. /. hidden. /sample. html. /xampp/iart. php. /. hidden

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/ directory. Note the htdocs and backup directories. 2. Backup the htdocs directory (including sub-directories) to htdocs-20081125. tar the backup directory. What command did you use? [Table 21 -24] 3. Verify your tarfile contains xampp/lang/jp. php What command did you use? From where? [Table 1 -4] 4. Delete and then restore xampp/lang/jp. php from the backup directory What command did you use? [Table 9 -12]

CIS 90 - Lesson 14 tar command Size can differ between tarfile and backed

CIS 90 - Lesson 14 tar command Size can differ between tarfile and backed up file Tarfiles § Tarfile can be smaller than backed up file as it only saves the date, not unused portion of data blocks § Tarfile can be larger if backed up file is a sparse file § Additional empty blocks can be added to tar version

CIS 90 - Lesson 14 tar command du size can differ between tarfile and

CIS 90 - Lesson 14 tar command du size can differ between tarfile and backed up file Tarfiles § Additional empty blocks can be added to tar version [root@benji log]# cp messages /root; tar cvf /root/messages. tar messages; tar -c. Svf /root/messages. S. tar messages ls command show same size for original, copy and tar extracts [root@benji ~]# ls -l messages /var/log/messages sparse/messages nosparse/messages -rw------- 1 root 127538 Nov 22 08: 20 messages -rw------- 1 root 127538 Nov 22 08: 13 nosparse/messages -rw------- 1 root 127538 Nov 22 08: 13 /var/log/messages original [root@benji ~]# du messages /var/log/messages sparse/messages nosparse/messages 136 messages 127 /var/log/messages original file 136 sparse/messages 136 nosparse/messages du report shows more disk space used than original for copy and tar extracts Note: the –s option is to handle sparse files (discussed later) file

CIS 90 - Lesson 14 tar command Size can differ between tarfile and backed

CIS 90 - Lesson 14 tar command Size can differ between tarfile and backed up file Tarfiles § Additional empty blocks can be added to tar version [root@benji ~]# stat messages /var/log/messages sparse/messages nosparse/messages File: `messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> File: `/var/log/messages' Size: 127538 Blocks: 254 IO Block: 4096 regular file <snipped> File: `sparse/messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> File: `nosparse/messages' Size: 127538 Blocks: 272 IO Block: 4096 regular file <snipped> [root@benji ~]# stat command shows copy and files extracted from tarfile have additional blocks which explains why file size is the same but disk usage is higher.

CIS 90 - Lesson 14 tar command sparse files Sparse Files § Null blocks

CIS 90 - Lesson 14 tar command sparse files Sparse Files § Null blocks (containing only zeroes) are not stored on the disk § Can be problematic if utilities don't recognize them [root@benji ~]# cd /var/log [root@benji log]# ls -l lastlog -rw-r--r-- 1 root 234476 Nov 22 05: 18 lastlog [root@benji log]# du -h lastlog 16 K lastlog Note the reduced size of the file actually stored on the disk using du –h command

CIS 90 - Lesson 14 tar command sparse files Sparse Files § tar command

CIS 90 - Lesson 14 tar command sparse files Sparse Files § tar command without using the sparse option (-S) for sparse file [root@benji ~]# cd /var/log [root@benji log]# tar cvf /root/lastlog. tar lastlog [root@benji log]# cd /root [root@benji ~]# ls -l lastlog. tar -rw-r--r-- 1 root 245760 Nov 22 05: 19 lastlog. tar [root@benji ~]# du -h lastlog. tar 248 K lastlog. tar The tarfile has expanded all the null blocks increasing [root@benji ~]# tar xvf lastlog. tar disk space usage lastlog [root@benji ~]# ls -l lastlog -rw-r--r-- 1 root 234476 Nov 22 05: 18 lastlog [root@benji ~]# du -h lastlog 240 K lastlog

CIS 90 - Lesson 14 tar command sparse files Sparse Files § tar command

CIS 90 - Lesson 14 tar command sparse files Sparse Files § tar command using the sparse option (-S) with sparse file [root@benji ~]# cd /var/log [root@benji log]# tar c. Svf /root/lastlog 2. tar lastlog [root@benji log]# cd /root Using the -S option, the tar command handles the [root@benji ~]# tar xvf lastlog 2. tar sparse file efficiently lastlog [root@benji ~]# ls -l lastlog -rw-r--r-- 1 root 234476 Nov 22 05: 18 lastlog [root@benji ~]# du -h lastlog 20 K lastlog [root@benji ~]#

CIS 90 - Lesson 14 tar command compression c z tar t vf tarfile

CIS 90 - Lesson 14 tar command compression c z tar t vf tarfile j x file(s) -C dir The z option uses gzip compresssion and the j option uses bzip 2 compression bzip 2 is slower, but compresses more gzip is faster, but compreses less

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs. tar.

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs. tar. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl. /xampp/iart. php. /. hidden. /favicon. ico. /index. html Backing up htdocs with no compression [root@benji htdocs]# [root@benji backup]# ls -l htdocs. tar; du -h htdocs. tar -rw-r--r-- 1 root 706560 Nov 22 13: 13 htdocs. tar 695 K htdocs. tar [root@benji backup]#

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs 2.

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs 2. tar. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl. /xampp/iart. php. /. hidden. /favicon. ico. /index. html [root@benji htdocs]# gzip. . /backup/htdocs 2. tar Post-compression using gzip of archive [root@benji backup]# ls -l htdocs 2. tar. gz; du -h htdocs 2. tar. gz -rw-r--r-- 1 root 343760 Nov 22 13: 15 htdocs 2. tar. gz 340 K htdocs 2. tar. gz [root@benji backup]#

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs 2.

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cvf /opt/lampp/backup/htdocs 2. tar. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl. /xampp/iart. php. /. hidden. /favicon. ico. /index. html [root@benji htdocs]# bzip 2. . /backup/htdocs 2. tar Post-compression using bzip 2 of archive [root@benji backup]# ls -l htdocs 2. tar. bz 2; du -h htdocs 2. tar. bz 2 -rw-r--r-- 1 root 340646 Nov 22 13: 18 htdocs 2. tar. bz 2 337 K htdocs 2. tar. bz 2 [root@benji backup]#

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar czvf /opt/lampp/backup/htdocs. tar.

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar czvf /opt/lampp/backup/htdocs. tar. gz. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl. /xampp/iart. php. /. hidden. /favicon. ico. /index. html Using gzip compression option [root@benji htdocs]# [root@benji backup]# ls -l htdocs. tar. gz; du -h htdocs. tar. gz -rw-r--r-- 1 root 343748 Nov 22 13: 13 htdocs. tar. gz 340 K htdocs. tar. gz [root@benji backup]#

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cjvf /opt/lampp/backup/htdocs. tar.

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# tar cjvf /opt/lampp/backup/htdocs. tar. bz 2. . /. /webalizer/. /sample. html. /xampp/lang. tmp. /xampp. js. /xampp/index. php. /xampp/test/xampp_ming/gif. /xampp/test/xampp_ming/jpg. /xampp/test/xampp_ming/png. /xampp/test/xampp_ming/bitmaps. php. /xampp/test/xampp_win. png. /xampp/test/xampp_ming. zip. /xampp/perl. pl. /xampp/guestbook-no. pl. /xampp/splash-swf. php. /xampp/guestbook-pl. /xampp/ssi. shtml. /xampp/components. php. /xampp/contrib/oracle. php. /xampp/contrib/cds. xml. /xampp/contrib/soap. php. /xampp/contrib/sqlite. php. /xampp/contrib/sax. php. /xampp/contrib/postgresql. pl. /xampp/contrib/interbase. pl. /xampp/contrib/mysql. php. /xampp/contrib/dom. php. /xampp/contrib/mingstats_swf. php. /xampp/contrib/mysql. pl. /xampp/contrib/testperldbi. pl. /xampp/contrib/xmlrss. php. /xampp/contrib/mingstats. html. /xampp/contrib/sql 2 xml. php. /xampp/contrib/sqlite. pl. /xampp/contrib/Babel. Sans-B. fdb. /xampp/contrib/oracle. pl. /xampp/contrib/interbase. php. /xampp/contrib/postgresql. php. /xampp/manuals. php. /xampp/cgi. /xampp/cds. php. /xampp/webalizer. php. /xampp/biorhythm. php. /xampp/Anke. Calligraph. TTF. /xampp/head. php. /xampp/guestbook-zh. pl. /xampp/start. php. /xampp/Anke. Calligraph. fdb. /xampp/mingswf. php. /xampp/mysql. php. /xampp/guestbook-nl. pl. /xampp/navi. php. /xampp/lang. php. /xampp/security. php. /xampp/lang/de. php. /xampp/lang/it. php. /xampp/lang/fr. php. /xampp/lang/es. php. /xampp/lang/pt_br. php. /xampp/lang/nl. php. /xampp/lang/zh. php. /xampp/lang/no. php. /xampp/lang/pl. php. /xampp/lang/en. php. /xampp/languages. php. /xampp/lang/jp. php. /xampp/splash-logo. php. /xampp/langsettings. php. /xampp/. version. /xampp/status. php. /xampp/phonebook. php. /xampp/img/rb. gif. /xampp/img/status 3. gif. /xampp/img/logo-small. jpg. /xampp/img/new. png. /xampp/img/signature-kay. gif. /xampp/img/lt. gif. /xampp/img/benji-500 x 420. jpg. /xampp/img/status 4. gif. /xampp/img/rt. gif. /xampp/img/strichel. gif. /xampp/img/head-linux. gif. /xampp/img/head-xampp. gif. /xampp/img/xampp-logo. jpg. /xampp/img/head-fuer. gif. /xampp/img/head-for. gif. /xampp/img/head-solaris. gif. /xampp/img/status 2. gif. /xampp/img/status 1. gif. /xampp/img/head-windows. gif. /xampp/img/logo-big. gif. /xampp/img/signature-oswald. gif. /xampp/img/status 5. gif. /xampp/img/blank. gif. /xampp/img/lb. gif. /xampp/img/xampp-logo-new. gif. /xampp/img/apachefriends. gif. /xampp/guestbook-es. pl. /xampp/guestbook-de. pl. /xampp/phpinfo. php. /xampp/splash. php. /xampp/guestbook-pt_br. pl. /xampp/guestbook. dat. /xampp/charset. php. /xampp/test. php. /xampp/softwarelist. inc. /xampp/guestbook-it. pl. /xampp/cds-fpdf. php. /xampp/ssi. inc. /xampp/php. /xampp/sqlite/cdcol. /xampp/sqlite/phonebook. sqlite. /xampp/sqlite/. htaccess. /xampp. css. /xampp/ming. php. /xampp/showcode. php. /xampp/guestbook-fr. pl. /xampp/guestbook-en. pl. /xampp/iart. php. /. hidden. /favicon. ico. /index. html Using the bzip 2 compression option [root@benji htdocs]# [root@benji backup]# ls -l htdocs. tar. bz 2; du -h htdocs. tar. bz 2 -rw-r--r-- 1 root 340646 Nov 22 13: 14 htdocs. tar. bz 2 337 K htdocs. tar. bz 2 [root@benji backup]#

CIS 90 - Lesson 14 tar command compression [root@benji backup]# ls -Slr total 2049

CIS 90 - Lesson 14 tar command compression [root@benji backup]# ls -Slr total 2049 -rw-r--r-- 1 root 340646 -rw-r--r-- 1 root 343748 -rw-r--r-- 1 root 343760 -rw-r--r-- 1 root 706560 [root@benji backup]# Nov Nov Nov 22 22 22 13: 14 13: 18 13: 13 13: 15 13: 13 htdocs. tar. bz 2 htdocs 2. tar. bz 2 htdocs. tar. gz htdocs 2. tar. gz htdocs. tar Conclusions: • compression option slightly better than two steps • bzip 2 compresses more that gzip 2 steps

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# rm sample. html rm:

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# rm sample. html rm: remove regular file `sample. html'? y [root@benji htdocs]# tar xvf. . /backup/htdocs. tar. gz. /sample. html [root@benji htdocs]# cat sample. html <html> <head> <title>My first page</title> </head> <body> <h 1>My first web page</h 1> <p>Nothing can stop me now</p> <a href="http: //google. com">My link to Google</a> </body> </html> FYI, not specifying the z option still works when restoring a file

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# rm sample. html rm:

CIS 90 - Lesson 14 tar command compression [root@benji htdocs]# rm sample. html rm: remove regular file `sample. html'? y [root@benji htdocs]# tar xvf. . /backup/htdocs. tar. bz 2. /sample. html [root@benji htdocs]# cat sample. html <html> <head> <title>My first page</title> </head> <body> <h 1>My first web page</h 1> <p>Nothing can stop me now</p> <a href="http: //google. com">My link to Google</a> </body> </html> [root@benji htdocs]# FYI, not specifying the j option still works when restoring a file

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/htdocs

CIS 90 - Lesson 14 Class Exercise tar command 1. Change to the /opt/lampp/htdocs directory. 2. Make four backups of htdocs into the /root directory using both compression options and using post compression with gzip and bzip 2. a) -z option b) -j option c) 2 steps with gzip command d) 2 steps with bzip 2 command 3. Verify your backup by deleting, restoring and viewing sample. html for each backup above What commands did did you you use use for for 2 a and 3? [Table 17 -20] 2 b and 3? [Table 5 -8] 2 c and 3? [Table 13 -16] 2 d and 3? [Table 21 -24]

CIS 90 - Lesson 14 tar command compression c z tarfile tar t vf

CIS 90 - Lesson 14 tar command compression c z tarfile tar t vf j device x file(s) Backups can be made to devices as well

CIS 90 - Lesson 14 tar command using devices [root@benji bin]# fdisk /dev/sda Command

CIS 90 - Lesson 14 tar command using devices [root@benji bin]# fdisk /dev/sda Command (m for help): n First cylinder (582 -652, default 582): Using default value 582 Last cylinder or +size. M or +size. K (582 -652, default 652): +500 M Command (m for help): p Disk /dev/sda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Make a 500 MB partition Device Boot /dev/sda 1 * /dev/sda 2 /dev/sda 3 /dev/sda 4 /dev/sda 5 /dev/sda 6 /dev/sda 7 /dev/sda 8 Id 83 82 83 5 83 83 Start 1 383 448 512 550 557 582 Command (m for help): End 382 447 511 652 549 556 581 643 Blocks 3068383+ 522112+ 514080 1132582+ 305203+ 56196 200781 497983+ System Linux swap / Solaris Linux Extended Linux

CIS 90 - Lesson 14 tar command using devices Command (m for help): x

CIS 90 - Lesson 14 tar command using devices Command (m for help): x Expert command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@benji bin]# partprobe [root@benji bin]# Use partprobe so kernel will use new partition table

CIS 90 - Lesson 14 tar command using devices Change to the directory to

CIS 90 - Lesson 14 tar command using devices Change to the directory to back up. Note /dev/sda 8 is not mounted [root@benji opt]# tar cvzf /dev/sda 8. 2> /root/errors > /root/optfiles [root@benji opt]# wc -l /root/errors /root/optfiles 3 /root/errors 13282 /root/optfiles 13285 total [root@benji opt]# cat /root/errors tar: . /lampp/logs/cgisock. 2381: socket ignored tar: . /lampp/logs/cgisock. 2404: socket ignored tar: . /lampp/var/mysql. sock: socket ignored You don't need to backup socket files. They are created automatically by the kernel when needed

CIS 90 - Lesson 14 tar command using devices [root@benji opt]# cd lampp/htdocs [root@benji

CIS 90 - Lesson 14 tar command using devices [root@benji opt]# cd lampp/htdocs [root@benji htdocs]# rm sample. html rm: remove regular file `sample. html'? Oops! …. file gets deleted [root@benji htdocs]# cd /opt [root@benji opt]# tar tvzf /dev/sda 8 | grep sample. html Finding file in -rw-r--r-- root/root 194 2008 -10 -24 10: 13: 10. /lampp/htdocs/sample. html [root@benji opt]# tar xvzf /dev/sda 8. /lampp/htdocs/sample. html [root@benji opt]# cat lampp/htdocs/sample. html <html> <head> <title>My first page</title> </head> Viewing <body> <h 1>My first web page</h 1> <p>Nothing can stop me now</p> <a href="http: //google. com">My link to Google</a> </body> </html> [root@benji opt]# restored file archive Restoring deleted file from backup archive on a device

CIS 90 - Lesson 14 tar command Examples Perform full backup of entire file

CIS 90 - Lesson 14 tar command Examples Perform full backup of entire file tree # init 1 # cd / # tar cpvf /dev/sdb [!p]*. autofsck Don't backup and restore /proc (this is real time kernel data) !! # tar -cpvf /dev/sdb / --exclude=/proc -p, --same-permissions, --preserve-permissions Keeps permissions of extracted files the same as the originals.

CIS 90 - Lesson 14 tar command Examples Backup files in /opt after May

CIS 90 - Lesson 14 tar command Examples Backup files in /opt after May 5, 1993 # cd /opt # tar -cvzf /root/opt-files. tar. gz –-newer 05/05/1993. This allows differential and incremental backups to be done. Both types are based on a date. Either the last backup (incremental) or the last full backup (differential). To do differential or incremental backups you will need a mechanism to track the dates or use a higher level backup program that makes use of tar.

CIS 90 - Lesson 14 Class Exercise tar command 1. Create a 500 MB

CIS 90 - Lesson 14 Class Exercise tar command 1. Create a 500 MB partition on /dev/sda 2. Backup the entire /opt directory to this partition using tar What commands did you use? [Table 1 -4] 3. Verify your backup by deleting, restoring and viewing sample. html for each backup above What commands did you use? [Table 9 -12] 4. Delete the 500 MB partition

CIS 90 - Lesson 14 Class Exercise tar On Opus, tar up you entire

CIS 90 - Lesson 14 Class Exercise tar On Opus, tar up you entire home directory. Use your own logname to name the tarball: cd tar cvf logname. tar * On your local vm, create a directory with the same name as your Opus logname and change into it. mkdir logname cd logname/ scp logname@opus. cabrillo. edu: *. tar xvf logname. tar

CIS 90 - Lesson 14 Wrap up

CIS 90 - Lesson 14 Wrap up

CIS 90 - Lesson 14 Next Class Project is due next week!

CIS 90 - Lesson 14 Next Class Project is due next week!

CIS 90 - Lesson 14 Backup

CIS 90 - Lesson 14 Backup