Tips & Tricks

OpenSource For You - - Contents -

An al­ter­na­tive for the dd com­mand

We are com­fort­able us­ing the dd com­mand in our day to day ad­min­is­tra­tion of com­put­ers and servers. An al­ter­na­tive to it is the dcfldd com­mand, which also shows a progress re­port of the process. dcfldd is an en­hanced ver­sion of dd, de­vel­oped by the US De­part­ment of De­fence Com­puter Foren­sics Lab.

To use dcfldd, we first need to in­stall it, for which you can use the fol­low­ing com­mand:

$sudo apt-get in­stall dcfldd

$dcfldd if=<source> of=<des­ti­na­tion>

For ex­am­ple:

$dcfldd if=/dev/zero of=/dev/null

The out­put is:

425216 blocks (13288Mb) writ­ten.

—Rupin Puthukudi, rupinmp@gmail.com

A be­gin­ner’s guide to Curl

The Curl com­mand is used to trans­fer data from or to a server. It is used with the fol­low­ing pro­to­cols: HTTP, HTTPS, FTP, SFTP, TFTP, DICT, TELNET, LDAP, IMAP, SCP, SMTP and SMTPS.

Curl can be used in­side the scripts. When you down­load us­ing the Curl com­mand, you can eas­ily pause or re­sume the down­load. There are 120 com­mand line op­tions with the Curl com­mand. It sup­ports cook­ies, forms and SSL, mul­ti­ple up­loads with a sin­gle com­mand and IPv6.

For ex­am­ple:

$curl http://www.my.org

The above com­mand shows the con­tents of this web­site in your ter­mi­nal. If you want to save the out­put of the Curl com­mand, you can use the re­di­rect sym­bol > or the -o op­tion.

For ex­am­ple:

$ curl http://www.cen­tos.org > file.txt

…or:

$ curl http://www.cen­tos.org -o file.txt

Now let’s look at how to down­load mul­ti­ple files us­ing the Curl com­mand:

$curl -O http://ftp.open.com/pub/axt.html -O http://ftp.gnu.

com/pub/bxy.html -O

http://ftp.lkj.com/pub/c.html

An im­por­tant fact to note here is that Curl will use the same TCP con­nec­tion to down­load mul­ti­ple files. This is done to im­prove the down­load speed. When we use Curl ­O (up­per­case O), it will save the con­tents in the file with the orig­i­nal file name in the lo­cal ma­chine. If we use -o (low­er­case o), then we need to give the file name in the com­mand.

Curl is au­to­mat­i­cally redi­rected to a new URL if we use the -L op­tion.

For ex­am­ple:

$curl -L google.com

Af­ter run­ning the above com­mand, you can can­cel the down­load­ing process us­ing Ctrl+c, and then if we want to re­sume down­load­ing from the last point, use the ­C op­tion.

$curl -C - -O http://ftp.lo­cal.com/pub/test.gz

** Re­sum­ing trans­fer from byte po­si­tion 28609

% To­tal % Re­ceived % Xferd Av­er­age Speed Time Time Time Cur­rent

To limit the data rate in the Curl com­mand, use the --limit-rate op­tion, as fol­lows:

$ curl --limit-rate 1000B -O http://ftp.lo­cal.com/pub/test.gz

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.