2. 11-2
Creating Backups
• Backup tools used:
– Gzip
– Bzip2
– Zip
– Tar
• Compressing files
• Decompressing files
• List the contents of an archive/compressed file
3. 11-3
Gzip
• gzip--Gzip compress the size of the given files using Lempel-Ziv coding (LZ77).
Whenever possible, each file is replaced by one with the extension .gz.
syn: gzip {filename}
ex: gzip mydata.doc
• Decompressing a file that is created using gzip command. File is restored to
their original form using this command.
syn: gzip -d {.gz file}
gunzip {.gz file}
ex: gzip -d mydata.doc.gz
gunzip mydata.doc.gz
• List files from a GZIP archive
syn: gzip -l {.gz file}
ex: gzip -l mydata.doc.gz
4. 11-4
Bzip2
• bzip2 :bzip2 compresses files using the Burrows-Wheeler block sorting text
compression algorithm, and Huffman coding. Compression is generally
considerably better than that achieved by gzip command. Whenever possible,
each file is replaced by one with the extension .bz2.
syn: bzip2 {filename}
ex: bzip2 mydata.doc
• Decompressing a file that is created using bzip2 command. File is restored to
their original form using this command.
syn: bzip2 -d {.bz2-file}
bunzip2 {.bz2-file}
ex: bzip2 -d mydata.doc.bz2
gunzip mydata.doc.bz2
• Listing the files from a bzip2 archive is not possible
8. 11-8
Copying Files Remotely
• scp stands for secure cp (copy), which means you can copy files across ssh
connection. That connection will be securely encrypted, it is a very secure way to
copy files between computers.
syn: scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]
from-host
Is the name or IP of the host where the source file is, this can be
omitted if the from-host is the host where you are actually issuing
the command
user
Is the user which have the right to access the file and directory,
that is supposed to be copied in the case of the from-host, and the
user who has the rights to write in the to-host
source-file
Is the file or files that are going to be copied to the destination
host, it can be a directory but in that case you need to specify
the -r option to copy the contents of the directory
destination-
file
Is the name that the copied file is going to take in the to-host, if
none is given all copied files are going to keep its names
9. 11-9
SCP
• SCP Options
-p: Preserves the modification and access times, as well as the permissions
of the source-file in the destination-file
-q: Do not display the progress bar
-r: Recursive, so it copies the contents of the source-file (directory in this
case) recursively
-v: Displays debugging messages
10. 11-10
SCP Examples
• Copy files from a local computer to a remote computer
ex: scp somefile username@server:/home/username/
ser@remote.server.com:/home/user/
• Copy files from a remote server to your local computer
ex: scp username@server:/home/username/file_name /home/local-username/file-name
• Copy files from a remote server to another remote computer
ex: scp user_name1@server1:/home/user_name1/file_name
user_name2@server2:/home/user_name2/
11. 11-11
cURL and Wget
• cURL : is a software package which consists of command line tool and a library
for transferring data using URL syntax.
• Download a Single File
ex: curl http://google.com
• The above command will get the content of the URL and display it in the
STDOUT (i.e. on your terminal).
• To store the output in a file, you an redirect it as shown below. This will also
display some additional download statistics.
12. 11-12
cURL and Wget
• Wget is a free utility for non-interactive download of files from the Web. It
supportsHTTP, HTTPS, and FTP protocols
• In order to download the web page google.com you would type
wget google.com
• The result will be saved as a file in the current directory. You can open and
view the file with a web browser.
• If there are connection problems wget will try up to 20 times to reconnect.
You can use the -t option to change the maximum number of attempts. For
example, with
wget -t 10 google.com
• it will try only up to 10 times.
13. 11-13
Network Troubleshooting
• ping: will ping the host to see if it is alive or not.
syn: ping [options] <host_name>
Ex: ping google.com
ping google.com –c1 <linux>
ping google.com –t <windows>
• ifconfig: This command allows the operating system to setup network interfaces and allow
the user to view information about the configured network interfaces.
ex: ifconfig eth0 #view the network settings on the first Ethernet adapter
ifconfig –a #Display info on all network interfaces on server,active or inactive.
ifconfig eth0 down #If eth0 exists would take it down causing it cannot send or receive any
information
ifconfig eth0 up #If eth0 exists and in the down state would return it back to the up state
14. 11-14
Network Troubleshooting
ifup and ifdown
• ifup - bring a network interface up
• ifdown - take a network interface down
ex: ifup -a #Bring up all the interfaces defined with auto in /etc/network/interfaces
ifup eth0 #Bring up interface eth0
ifdown -a #Bring down all interfaces that are currently up.
• Telnet: to connect to another remote computer.
ex: telnet <ip_address>
telnet <ip_address> <port>
15. 11-15
Network Troubleshooting
• netstat– shows network status.
ex: netstat #Displays generic net statistics of the host you are currently
connnected to.
netstat –an #shows all the connections to the server including the source and
destination ips and ports if you have the proper permissions.
netstat –natp #display active internet connections
netstat –an|grep :80 #displays the active connection on port 80