<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>data transfer Archives - ITEC4B</title>
	<atom:link href="https://itec4b.com/tag/data-transfer/feed/" rel="self" type="application/rss+xml" />
	<link>https://itec4b.com/tag/data-transfer/</link>
	<description>Information Technology Expert Consulting</description>
	<lastBuildDate>Thu, 02 Mar 2023 18:56:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>
	<item>
		<title>rsync: Remote Synchronization</title>
		<link>https://itec4b.com/rsync-remote-synchronization/</link>
		
		<dc:creator><![CDATA[author]]></dc:creator>
		<pubDate>Thu, 02 Mar 2023 12:44:17 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[Data Transfer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[data transfer]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://itec4b.com/?p=989</guid>

					<description><![CDATA[rsync is a complete and powerful open source utility that provides fast incremental files transfer.It efficiently transfers and synchronizes files/directories between storage drive(s) and across networked hosts. It was created in 1996 by Andrew Tridgell and Paul Mackerras.It is currently maintained by Wayne Davison. rsync is freely available under the GNU General Public License.rsync source &#8230; <p class="link-more"><a href="https://itec4b.com/rsync-remote-synchronization/" class="more-link">Read more<span class="screen-reader-text"> "rsync: Remote Synchronization"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p><span style="text-decoration: underline;"><strong><a href="https://rsync.samba.org">rsync</a> is a complete and powerful open source utility that provides fast incremental files transfer</strong></span>.<br>It efficiently transfers and synchronizes files/directories between storage drive(s) and across networked hosts.</p>



<p>It was created in 1996 by Andrew Tridgell and Paul Mackerras.<br>It is currently maintained by Wayne Davison.<br><br>rsync is freely available under the GNU General Public License.<br><a href="https://git.samba.org/?p=rsync.git;a=tree">rsync source code is here</a> <br><br>The rsync algorithm is a type of delta encoding, and is used for minimizing network usage.<br><span style="text-decoration: underline;"><strong>It efficiently computes/identify which parts (splitted blocks by <strong>fragmentation</strong>) of a source file match some part of an existing destination file (those parts don&#8217;t need to be sent across the communication link), thus minimizing the amount of data to transfer by only moving the portions of files that have changed</strong></span>.<br><br>For further speed improvements, the data sent to the receiver can be compressed using any of the supported algorithms.<br><br><strong>ssh is the default remote shell for rsync since <a href="https://download.samba.org/pub/rsync/NEWS#2.6.0">version 2.6.0 (January 1st 2004)</a></strong></p>



<pre class="wp-block-code"><code>Install rsync (Debian)
# apt install rsync

rsync version
$ rsync -V</code></pre>



<h2>Usage</h2>



<p><strong><span style="text-decoration: underline;">Local SRC &gt; Local DST</span></strong><br><code>rsync [OPTIONS] SRC [DST]</code></p>



<p><strong><span style="text-decoration: underline;">Push (Local SRC > Remote DST)</span></strong> <code>rsync [OPTIONS] SRC [USER@]HOST:DST</code><br><strong><span style="text-decoration: underline;">Pull (Local DST &lt; Remote SRC)</span></strong> <code>rsync [OPTIONS] [USER@]HOST:SRC [DST]</code><br><br>Usages with just one SRC arg and no DST arg will list the source files instead of copying:<br><code><strong>&lt;type>&lt;perms_rwx> &lt;size_bytes> &lt;mtime YYYY/MM/DD> &lt;mtime hh:mm:ss> &lt;relative_path></strong></code><br><br><strong><span style="text-decoration: underline;">IMPORTANT: rsync must be installed on both the source and destination machines</span></strong><br><br>If you still has this error:<br><code>rsync: command not found<br>rsync: connection unexpectedly closed (0 bytes received so far) [sender]<br>rsync error: error in rsync protocol data stream ...</code><br><br>It means Local rsync cannot find the remote rsync executable.<br>In this case you need to know the path of the remote host&#8217;s rsync binary and make it part of the command with <code><strong>--rsync-path=/path/to/remote/rsync</strong></code></p>



<pre class="wp-block-code"><code>$ which rsync
/usr/bin/rsync  (Debian)</code></pre>



<h2>Options</h2>



<p><span style="text-decoration: underline;"><strong>If <code>--delete </code>option is specified, rsync will identify the files NOT present on the sender and delete them on the receiver</strong></span>. This option can be dangerous if used incorrectly! It is recommended to do a simulation run before, using the <code><strong>--dry-run</strong></code> option (<code><strong>-n</strong></code>) to find out which files are going to be deleted.<br><br>Each file from the list generated by rsync will be checked to see if it can be skipped.<br><span style="text-decoration: underline;"><strong>In the most common mode of operation, files are not skipped if the modification time or size differs</strong></span>.</p>



<p>rsync performs a slower but comprehensive check if invoked with <code><strong>--checksum</strong></code> option.<br>This forces a full checksum comparison on every file present on both systems.<br><br><code><span style="text-decoration: underline;"><strong>--checksum, -c</strong></span></code><br><strong><span style="text-decoration: underline;">Skip files based on checksum, not mtime AND size</span></strong>.<br>This changes the way rsync checks if the files have been changed and are in need of a transfer.<br>Without this option, rsync uses a &#8220;quick check&#8221; that (by default) checks if each file&#8217; size and time of last modification match between the sender and receiver.<br>This option changes this to compare a 128-bit checksum for each file that has a matching size.<br>Generating the checksums means that both sides will expend a lot of disk I/O reading all the data in the files in the transfer, so this can slow things down significantly (and this is prior to any reading that will be done to transfer changed files)</p>



<p><code><strong><span style="text-decoration: underline;">--human-readable, -h</span></strong></code><br>Output numbers in a more human-readable format.<br>Unit letters: K (Kilo), M (Mega), G (Giga), T (Tera), or P (Peta).</p>



<p><strong><span style="text-decoration: underline;"><code>--dry-run, -n</code></span></strong><br>Simulation run (no changes made)</p>



<p><code><strong><span style="text-decoration: underline;">--verbose, -v</span></strong></code><br>Increases the amount of information you are given during the transfer.<br>By default, rsync works silently.<br>A single -v will give you information about what files are being transferred and a brief summary at the end.<br>Two -v options will give you information on what files are being skipped and slightly more information at the end.<br>More than two -v options should only be used if you are debugging rsync.</p>



<p><code><strong><span style="text-decoration: underline;">--quiet, -q</span></strong></code><br>Decreases the amount of information you are given during the transfer, notably suppressing information messages from the remote server. This option is useful when invoking rsync from cron.</p>



<p><strong><span style="text-decoration: underline;"><code>--info=FLAGS</code></span></strong><br>Choose the information output<br>An individual flag name may be followed by a level number, with 0 meaning to silence that output, 1 being the default output level, and higher numbers increasing the output of that flag (for those that support higher levels).<br><code>$ rsync --info=help</code><br><code>$ <strong>rsync -av --info=progress2 SRC/ DST/</strong></code></p>



<p><span style="text-decoration: underline;"><code><strong>--progress</strong></code></span><br>Print information showing the progress of the transfer.<br>This is the same as specifying <code>'<strong>--info=flist2,name,progress</strong>'</code> but any user-supplied settings for those info flags takes precedence (e.g. <code>--info=flist0 --progress</code>).</p>



<p>While rsync is transferring a regular file, it updates a progress line that looks like this:<br><code><strong>&lt;reconstructed_bytes&gt; &lt;%_current_file&gt; &lt;throughput/sec&gt; &lt;remaining_time&gt;</strong></code></p>



<p>When the file transfer is done, rsync replaces the progress line with a summary line that looks like this:<br><code><strong>&lt;filesize_bytes&gt; 100% &lt;throughput/sec&gt; &lt;elapsed_time&gt; (xfr#?, to-chk=???/N)</strong></code><br>where ? is the nth transfer, ??? is the remaining files for the receiver to check (to see if they are uptodate or not)<br><br>In an incremental recursion scan (<code><strong>--recursive</strong></code>), rsync doesn&#8217;t know the total number of files in the files list until it reaches the end of the scan. Since it starts transfering files during the scan, it displays a line with the text &#8220;ir-chk&#8221; (for incremental recursion check) instead of &#8220;to-chk&#8221; until it knows the full size of the list, at which point it switches to &#8220;to-chk&#8221;. &#8220;ir-chk&#8221; lets you know that the number of files in the files list is still going to increase.</p>



<p><strong><span style="text-decoration: underline;"><code>--archive, -a</code></span></strong><br><strong>It is equivalent to <code>-rlptgoD</code></strong><br>This is a quick way of saying you want recursion and want to preserve almost everything.<br><span style="text-decoration: underline;"><strong>Be aware that it does not include preserving ACLs (<code>-A</code>), xattrs (<code>-X</code>), atimes (<code>-U</code>), crtimes (<code>-N</code>), nor the finding and preserving of hardlinks (<code>-H</code>)</strong></span>.<br>The only exception to the above equivalence is when <code>--files-from</code> is specified, in which case <code>-r</code> is not implied.</p>



<p><strong><span style="text-decoration: underline;"><code>--recursive, -r</code></span></strong><br>This tells rsync to copy directories recursively. See also <code>--dirs</code> (<code>-d</code>).<br>Beginning with rsync 3.0.0, the recursive algorithm used is now an incremental scan that uses much less memory than before and <span style="text-decoration: underline;"><strong>begins the transfer after the scanning of the first few directories have been completed</strong></span>.<br>It is only possible when both ends of the transfer are at least version 3.0.0.<br><br><span style="text-decoration: underline;">Some options require rsync to know the full files list, these options disable the incremental recursion mode.<br>These include: <code>--delete-before</code>, <code>--delete-after</code>, <code>--prune-empty-dirs</code>, and <code>--delay-updates</code></span>.</p>



<p>Because of this, <strong><span style="text-decoration: underline;">the default delete mode when you specify <code>--delete</code> is now <code>--delete-during</code> when both ends of the connection are at least 3.0.0</span></strong> (use <code>--del</code> or <code>--delete-during</code> to request this improved deletion mode explicitly).<br>See also the &#8211;delete-delay option that is a better choice than using &#8211;delete-after.</p>



<p>Incremental recursion can be disabled using the <code>--no-inc-recursive</code> option or its shorter <code>--no-i-r </code>alias.</p>



<p><strong><code><span style="text-decoration: underline;">--delete-during, --del</span></code></strong><br>Request that the file deletions on the receiving side be done incrementally as the transfer happens.<br>The per-directory delete scan is done right before each directory is checked for updates, so it behaves like a more efficient <code>--delete-before</code>. This option was first added in rsync version 2.6.4. See <code>--delete</code> (which is implied) for more details on file deletion.</p>



<p><strong><code><span style="text-decoration: underline;">--delete-before</span></code></strong><br>Request that the file deletions on the receiving side be done before the transfer starts.<br>It does imply a delay before the start of the transfer, and this delay might cause the transfer to timeout (if <code>--timeout</code> was specified). It also forces rsync to use the old, non-incremental recursion algorithm that requires rsync to scan all the files in the transfer into memory at once (see <code>--recursive</code>).</p>



<p><strong><span style="text-decoration: underline;"><code>--delete-after</code></span></strong><br>Request that the file deletions on the receiving side be done after the transfer has completed.<br><span style="text-decoration: underline;">Important: this option forces rsync to use the old, non-incremental recursion algorithm that requires rsync to scan all the files in the transfer into memory at once (see <code>--recursive</code>)</span>. Use <code>--delete-delay</code> instead.</p>



<p><code><strong><span style="text-decoration: underline;">--delete-delay</span></strong></code><br>Request that the file deletions on the receiving side be computed during the transfer (like &#8211;delete-during), but removed after the transfer completes. <span style="text-decoration: underline;">This is more efficient than using <code>--delete-after</code></span>.<br>If the number of removed files overflows an internal buffer, a temporary file will be created on the receiving side to hold the names. If the creation of the temporary file fails, rsync will try to fall back to using <code>--delete-after</code> (which it cannot do if <code>--recursive</code> is doing an incremental scan).</p>



<p><strong><span style="text-decoration: underline;"><code>--links, -l</code></span></strong><br>By default, symbolic links are not transferred at all.<br>A message <code>"skipping non-regular"</code> file is emitted for any symlinks that exist.<br>If <code>--links</code> is specified, then symlinks are recreated with the same target on the destination.<br>Note that <code>--archive</code> implies <code>--links</code>.</p>



<p><strong><span style="text-decoration: underline;"><code>--perms, -p</code></span></strong><br>Preserve permissions<br>This option causes the receiving rsync to <strong><span style="text-decoration: underline;">set the destination permissions to be the same as the source permissions</span></strong>.<br>(See also the <code>--chmod</code> option for a way to modify what rsync considers to be the source permissions)<br><br><span style="text-decoration: underline;">When this option is off, permissions are set as follows</span>:<br><br>&#8211; Existing files (including updated files) retain their existing permissions, though the <code>--executability</code> option might change just the execute permission for the file.<br><br>&#8211; New files get their <code>"</code>normal<code>"</code> permission bits set to the source file&#8217;s permissions masked with the receiving directory&#8217;s default permissions (either the receiving umask, or the permissions specified via the destination directory&#8217;s default ACL), AND their special permission bits disabled except in the case where a new directory inherits a setgid bit from its parent directory.</p>



<p>Thus, when<code> --perms</code> and <code>--executability</code> are both disabled, rsync&#8217;s behavior is the same as that of other file copy utilities, such as cp(1) and tar(1).</p>



<p>In summary:<br><span style="text-decoration: underline;"><strong>To give destination files (both existing and new) the source permissions, use <code>--perms</code></strong></span>.<br>To give new files the destination default permissions (while leaving existing files unchanged), make sure that the <code>--perms</code> option is off and use <code>--chmod=ugo=rwX</code> (which ensures that all non-masked bits get enabled).</p>



<p>The preservation of the destination&#8217;s setgid bit on newly-created directories when &#8211;perms is off was added in rsync 2.6.7.</p>



<p><strong><span style="text-decoration: underline;"><code>--times, -t</code></span></strong><br><strong><span style="text-decoration: underline;">Preserve modification times</span></strong><br>This tells rsync to transfer modification times along with the files and update them on the remote system.<br>Note that if this option is not used, the optimization that excludes files that have not been modified cannot be effective.<br>In other words, a missing <code>-t</code> or <code>-a</code> will cause the transfer to behave as if it used <code>--ignore-times</code>, causing all files to be updated (though rsync&#8217;s delta-transfer algorithm will make the update fairly efficient if the files haven&#8217;t actually changed, you&#8217;re much better off using <code>-t</code>).</p>



<p><strong><span style="text-decoration: underline;"><code>--ignore-times, -I</code></span></strong><br>Normally rsync will skip any files that are already the same size and have the same modification timestamp.<br>This option turns off this <code>"</code>quick check<code>"</code> behavior, causing all files to be updated.</p>



<p><strong><span style="text-decoration: underline;"><code>--atimes, -U</code></span></strong><br><strong><span style="text-decoration: underline;">Preserve access times</span></strong><br>This tells rsync to <strong><span style="text-decoration: underline;">set the access (use) times of the destination files to the same value as the source files</span></strong>.<br><strong><span style="text-decoration: underline;">nanoseconds are not preserved (set to .000000000</span>)<span style="text-decoration: underline;">, command <code>cp -a</code> does</span></strong>.</p>



<p><strong><span style="text-decoration: underline;">IMPORTANT</span>:<br>There is no option to preserve ctime <code>"</code>status time<code>"</code></strong><br><strong>(the timestamp used to record when the inode changed, it is specific to a filesystem)</strong><br>An inode changes if any of its attributes are updated:<br>&#8211; at creation time (new file)<br>&#8211; file name<br>&#8211; mode/permissions<br>&#8211; owner/group<br>&#8211; hard link count<br>etc.<br><br>The creation of a file is one of the conditions listed above (creation of inode/file).<br>ctime cannot be preserved when files are brought into a new filesystem.</p>



<p><strong><span style="text-decoration: underline;"><code>--open-noatime</code></span></strong><br><strong><span style="text-decoration: underline;">Avoid changing the atime on opened file</span></strong><br>This tells rsync to open files with the <code>O_NOATIME</code> flag (on systems that support it) to avoid changing the access time of the files that are being transferred. If your OS does not support the <code>O_NOATIME</code> flag then rsync will silently ignore this option. Note also that some filesystems are mounted to avoid updating the atime on read access even without the <code>O_NOATIME</code> flag being set.</p>



<p><strong><span style="text-decoration: underline;"><code>--crtimes, -N</code></span></strong><br><strong>MAY NOT BE SUPPORTED, DEPENDS ON THE FILESYSTEM</strong>.<br>This tells rsync to set the create times (newness) of the destination files to the same value as the source files.</p>



<p><strong><span style="text-decoration: underline;"><code>--group, -g</code></span></strong><br><strong>Preserve group</strong><br>This option causes rsync to <strong><span style="text-decoration: underline;">set the group of the destination file to be the same as the source file</span></strong>.<br><span style="text-decoration: underline;">If the receiving program is not running as the super-user (or if <code>--no-super</code> was specified), only groups that the invoking user on the receiving side is a member of will be preserved</span>. Without this option, the group is set to the default group of the invoking user on the receiving side.</p>



<p><strong><span style="text-decoration: underline;"><code>--owner, -o</code></span></strong><br>This option causes rsync to <strong><span style="text-decoration: underline;">set the owner of the destination file to be the same as the source file, but only if the receiving rsync is being run as the super-user</span></strong> (see also the <code>--super</code> and <code>--fake-super</code> options).<br>Without this option, the owner of new and/or transferred files are set to the invoking user on the receiving side.</p>



<p><strong><span style="text-decoration: underline;"><code>--acls, -A</code></span></strong><br>This option causes rsync to <strong><span style="text-decoration: underline;">update the destination ACLs to be the same as the source ACLs</span></strong>.<br>The option also implies <code>--perms</code>.<br>The source and destination systems must have compatible ACL entries for this option to work properly.<br>See the <code>--fake-super</code> option for a way to backup and restore ACLs that are not compatible.</p>



<p><strong><span style="text-decoration: underline;"><code>--xattrs, -X</code></span></strong><br>This option causes rsync to update the destination extended attributes to be the same as the source ones.</p>



<p><strong><span style="text-decoration: underline;"><code>--hard-links, -H</code></span></strong><br>This tells rsync to look for hard-linked files in the source and link together the corresponding files on the destination. Without this option, hard-linked files in the source are treated as though they were separate files.<br><br>This option does NOT necessarily ensure that the pattern of hard links on the destination exactly matches that on the source.</p>



<h2>Usual Usage</h2>



<p><strong><span style="text-decoration: underline;">Local SRC_DIR > Local DST_DIR</span></strong><br>NOTE: By default, if Local DST_DIR does not exist it is created</p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">Copy SRC_DIR inside /path/to/local/DST_DIR/ : /path/to/local/DST_DIR/SRC_DIR</span>
$ rsync -av --info=progress2 /path/to/local/SRC_DIR /path/to/local/DST_DIR

<span style="text-decoration: underline;">Copy &lt;src_path>'s content inside &lt;dst_path>/</span>
$ rsync -av --info=progress2 &lt;src_path><strong>/</strong> &lt;dst_path>/
$ rsync -av --info=progress2 &lt;src_path><strong>/*</strong> &lt;dst_path>/</code></pre>



<p><strong><span style="text-decoration: underline;">Local SRC_FILE > Local DST</span></strong></p>



<pre class="wp-block-code"><code>$ rsync -av --info=progress2 /path/to/local/SRC_FILE /path/to/local/DST</code></pre>



<p><span style="text-decoration: underline;">IF DST is a directory</span>, it copies SRC_FILE inside DST (DIR)<br><br><span style="text-decoration: underline;">IF DST is a file</span>, its content is replaced with the content of SRC_FILE<br>(with -a option ONLY mtime is the same, atime, ctime are different, you may use -U + -N options)<br><br><span style="text-decoration: underline;">If DST does not exist</span> :<br>&#8211; if there is a trailing slash &#8216;/&#8217; it creates the directory DST (only for a direct subdirectory of an existing path &#8220;mkdir -p does not work&#8221; ) AND copies SRC_FILE inside DST<br><br>&#8211; otherwise it creates file DST (copy of SRC_FILE)</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>curl: Transfer Data From/To a Server</title>
		<link>https://itec4b.com/curl-transfer-data-from-to-a-server/</link>
		
		<dc:creator><![CDATA[author]]></dc:creator>
		<pubDate>Tue, 24 Jan 2023 17:44:16 +0000</pubDate>
				<category><![CDATA[Application]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[Data Transfer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[data transfer]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">https://itec4b.com/?p=336</guid>

					<description><![CDATA[curl is entirely free and open source software, it is a complete and powerful tool to transfer data from/to a server.Daniel Stenberg is the founder and lead developer of cURL and libcurl since 1996. curl is used daily by virtually every Internet-using human on the globe, it is used everywhere ! cURL is an Open &#8230; <p class="link-more"><a href="https://itec4b.com/curl-transfer-data-from-to-a-server/" class="more-link">Read more<span class="screen-reader-text"> "curl: Transfer Data From/To a Server"</span></a></p>]]></description>
										<content:encoded><![CDATA[
<p><a href="https://curl.se">curl</a> is entirely free and open source software, it is a <strong>complete and powerful tool to transfer data from/to a server</strong>.<br>Daniel Stenberg is the founder and lead developer of <strong>cURL</strong> and <strong>libcurl</strong> <a href="https://curl.haxx.se/docs/history.html">since 1996</a>.<br><br><span style="text-decoration: underline;"><strong>curl is used daily by virtually every Internet-using human on the globe, it is used everywhere !</strong></span></p>



<p>cURL is an Open Source project consisting of voluntary members from all over the world.<br>The cURL project is completely independent and free.<br><br>It is a <span style="text-decoration: underline;">client-side program</span> (the &#8216;c&#8217;), a URL (Uniform Resource Locator) client, and shows the data (by default).<br>So &#8216;c&#8217; for Client and URL: cURL</p>



<p><a href="https://everything.curl.dev">Everything curl</a> is a detailed and free book that explains basically everything there is to know about curl, libcurl and the associated project.</p>



<p>cURL is a project and its primary purpose and focus is to make two products:<br>&#8211; curl, the command-line tool<br>&#8211; libcurl the transfer library with a C API<br><br>Both the tool and the library do Internet transfers for resources specified as URLs using Internet protocols.<br><span style="text-decoration: underline;"><strong>Everything and anything that is related to Internet protocol transfers can be considered curl&#8217;s business</strong></span>.</p>



<p>The protocol describes exactly how to ask the server for data, or to tell the server that there is data coming.<br>Protocols are typically defined by the IETF (<a href="https://www.ietf.org">Internet Engineering Task Force</a> ),<br>which hosts RFC documents that describe exactly how each protocol works: how clients and servers are supposed to act and what to send and so on.</p>



<p>curl and libcurl are distributed under an Open Source license known as a MIT license derivative.<br>A key thing to remember is, that libcurl is the library and that this library is the biggest component of the curl command-line tool.</p>



<p><strong>Where&#8217;s the code ?</strong><br>The curl git tree can be browsed with a web browser at <a href="https://github.com/curl/curl">https://github.com/curl/curl</a><br>To check out the curl source code from git, you can clone it like this:</p>



<pre class="wp-block-code"><code>$ git clone https://github.com/curl/curl.git</code></pre>



<p>curl started out as a command-line tool and it has been invoked from shell prompts and from within scripts by an uncountable number of users over the years.<br><span style="text-decoration: underline;">curl has established itself as one of those trusty tools that is there for you to help you get your work done</span>.</p>



<p><a href="https://curl.se/docs/comparison-table.html">Here</a> you can find <strong>why curl is your first choice</strong>.</p>



<h2><a href="https://curl.se">curl</a> vs. <a href="https://www.gnu.org/software/wget">wget</a></h2>



<p><a href="https://daniel.haxx.se/docs/curl-vs-wget.html">https://daniel.haxx.se/docs/curl-vs-wget.html</a><br><br><span style="text-decoration: underline;">wget has (recursive) downloading powers that curl does not feature and it also handle download retries over unreliable connections possibly slightly more effective</span>.<br><strong>For just about everything else, curl is probably the more suitable tool</strong>.</p>



<p>curl operates on URLs. URI (Uniform Resource Identifier) is actually the correct name for them.<br>The syntax is defined in RFC 3986 (2005): <a href="https://datatracker.ietf.org/doc/html/rfc3986">https://datatracker.ietf.org/doc/html/rfc3986</a></p>



<h2>Install curl (Debian)</h2>



<pre class="wp-block-code"><code># apt install curl</code></pre>



<h2>curl options basics</h2>



<p><strong><span style="text-decoration: underline;"><code>-V, --version</code></span></strong><br>Displays information about curl and the libcurl version it uses.<br>The output from that command line is typically four lines, out of which some will be rather long and might wrap in your terminal window<br><br><span style="text-decoration: underline;">Line 1: curl</span><br>The first line includes the full version of curl, libcurl and other 3rd party libraries linked with the executable.<br>The first line starts with &#8216;curl&#8217; and first shows the main version number of the tool.<br>Then follows the &#8220;platform&#8221; the tool was built for within parentheses and the libcurl version.<br>Those three fields are common for all curl builds.<br><br>If the curl version number has -DEV appended to it, it means the version is built straight from a in-development source code and it is not an officially released and &#8220;blessed&#8221; version.<br>The rest of this line contains names of third party components this build of curl uses, often with their individual version number next to it with a slash separator.<br><br><span style="text-decoration: underline;">Line 2: Release-Date</span><br>This line shows the date this curl version was released by the curl project,<br>and it can also show a secondary &#8220;Patch date&#8221; if it has been updated somehow after it was originally released.</p>



<p><span style="text-decoration: underline;">Line 3: Protocols</span><br>The third line (starts with &#8220;Protocols:&#8221;) is a list of all transfer protocols (URL schemes really) in alphabetical order that this curl build supports.<br>All names are shown in lowercase letters.<br><br><span style="text-decoration: underline;">Line 4: Features</span><br>The fourth line (starts with &#8220;Features:&#8221;) is the list of features this build of curl supports.<br>If the name is present in the list, that feature is enabled. If the name is not present, that feature is not enabled.</p>



<p><span style="text-decoration: underline;"><strong><code>-v, --verbose</code></strong></span><br>Makes curl verbose during the operation.<br>Useful for debugging and seeing what&#8217;s going on &#8220;under the hood&#8221;.<br>When verbose mode is enabled, curl gets more talkative and will explain and show a lot more of its doings.<br>It will add informational tests and prefix them with &#8216;*&#8217;.</p>



<p>A line starting with &#8216;&gt;&#8217; means &#8220;header data&#8221; sent by curl,<br>A line starting with &#8216;&lt;&#8216; means &#8220;header data&#8221; received by curl that is hidden in normal cases,<br>A line starting with &#8216;*&#8217; means additional info provided by curl.</p>



<p>If you only want HTTP headers in the output, <code>-i, --include</code> might be the option you&#8217;re looking for.<br>If you think this option still doesn&#8217;t give you enough details, consider using <code>--trace</code> or <code>--trace-ascii</code> instead.</p>



<p>See also <code>-i, --include</code>. This option overrides <code>--trace</code> and <code>--trace-ascii</code>.</p>



<p><span style="text-decoration: underline;"><strong><code>-s, --silent</code></strong></span><br>Silent or quiet mode.<br>Don&#8217;t show progress meter or error messages when errors occur. Makes Curl mute.<br>It will still output the downloaded data you ask for, potentially even to the terminal/stdout unless you redirect it.<br>Use <code>-S, --show-error</code> in addition to this option to only disable progress meter but still show error messages.</p>



<p><span style="text-decoration: underline;"><strong><code>-S, --show-error</code></strong></span><br>When used with <code>-s, --silent</code>, it makes curl show an error message if it fails.</p>



<p><code><span style="text-decoration: underline;"><strong>-I, --head</strong></span></code><br>(HTTP, FTP, FILE) Fetch the headers only.<br>HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document.<br>When used on an FTP or FILE file, curl displays the file size and last modification time only.</p>



<p><span style="text-decoration: underline;"><strong><code>--ssl</code></strong></span><br>Try to use SSL/TLS for the connection.<br>Reverts to a non-secure connection if the server doesn&#8217;t support SSL/TLS.<br><br><code><strong><span style="text-decoration: underline;">--ssl-reqd</span></strong></code><br>Require SSL/TLS for the connection. Terminates the connection if the server doesn&#8217;t support SSL/TLS.<br><br><code><span style="text-decoration: underline;"><strong>-L, --location</strong></span></code> (<strong>HTTP 3NN Redirection</strong>)<br>(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3NN response code), <strong><span style="text-decoration: underline;">this option will make curl redo the request automatically on the new place</span></strong>.</p>



<p>If used together with -i, &#8211;include or -I, &#8211;head, headers from all requested pages will be shown.<br><br><span style="text-decoration: underline;"><strong><code>--stderr</code></strong></span><br>Redirect all writes to stderr to the specified file instead.<br>If the file name is a plain &#8216;-&#8216;, it is instead written to stdout.<br>If this option is used several times, the last one will be used.</p>



<p><strong><span style="text-decoration: underline;">OUPUT</span></strong><br><span style="text-decoration: underline;">If not told otherwise, curl writes the received data to stdout</span>.<br>It can be instructed to instead save that data into a local file, using the <code>-o, --output </code>OR<code> -O, --remote-name</code> options.<br>If curl is given multiple URLs to transfer on the command line, it similarly needs multiple options for where to save them.<br>curl does not parse or otherwise &#8220;understand&#8221; the content it gets or writes as output.<br>It does no encoding or decoding, unless explicitly asked so with dedicated command line options.<br><br><code><strong><span style="text-decoration: underline;">-o, --output &lt;path></span></strong></code><br>Write output to &lt;path> instead of stdout.<br><br><code><strong><span style="text-decoration: underline;">-O, --remote-name</span></strong></code><br>Write output to a local file named like the remote file you get.<br>(Only the file part of the remote file is used, the path is cut off)<br><br><span style="text-decoration: underline;">The file will be saved in the current working directory</span>.<br>If you want the file saved in a different directory, make sure you change the current working directory before invoking curl with this option.</p>



<p>The remote file name to use for saving is extracted from the given URL, nothing else, and if it already exists it will be overwritten.<br>There is no URL decoding done on the file name. If it has %20 or other URL encoded parts of the name, they will end up as-is as file name.</p>



<p>You may use this option as many times as the number of URLs you have.<br><br><code><strong><span style="text-decoration: underline;">-C, --continue-at</span></strong></code><br>Continue/Resume a previous file transfer at the given offset.<br>The given offset is the exact number of bytes that will be skipped, counting from the beginning of the source file before it is transferred to the destination.<br><br><strong><span style="text-decoration: underline;">Use <code>'-C -'</code> to tell curl to automatically find out where/how to resume the transfer</span></strong>.<br>It then uses the given output/input files to figure that out.<br>If this option is used several times, the last one will be used.</p>



<pre class="wp-block-code"><code><strong><span style="text-decoration: underline;">Download a file</span></strong>
$ curl URL -o /path/to/dst_filename

<strong><span style="text-decoration: underline;">Download a file to the current directory</span></strong>
$ curl -O URL

<strong><span style="text-decoration: underline;">Resume an interrupted download</span></strong>
$ curl -O -C - URL</code></pre>



<p><strong><span style="text-decoration: underline;">PROGRESS METER</span></strong><br>curl normally displays a progress meter during operations, indicating the amount of transferred data, transfer speeds and estimated time left, etc.<br>The progress meter displays number of bytes and the speeds are in bytes per second.<br>The suffixes (K, M, G, T, P) are 1024 based. For example 1K is 1024 bytes. 1M is 1048576 bytes (1024^2).</p>



<p>curl displays this data to the terminal by default, so if you invoke curl to do an operation and it is about to write data to the terminal, it disables the progress meter as otherwise it would mess up the output mixing progress meter and response data.</p>



<p>If you want a progress meter for HTTP POST or PUT requests, you need to redirect the response output to a file, using shell redirect (&gt;), <code>-o, --output</code> or similar.</p>



<p>It is not the same case for FTP upload as that operation does not spit out any response data to the terminal.</p>



<p>If you prefer a progress &#8220;bar&#8221; instead of the regular meter, <code>-#, --progress-bar</code> is your friend.<br>You can also disable the progress meter completely with the <code>-s, --silent</code> option.</p>



<p><span style="text-decoration: underline;"><strong><code>-#, --progress-bar</code></strong></span><br>Make curl display transfer progress as a simple progress bar instead of the standard, more informational, meter.<br>This progress bar draws a single line of &#8216;#&#8217; characters across the screen and shows a percentage if the transfer size is known.<br>For transfers without a known size, there will be space ship (-=o=-) that moves back and forth but only while data is being transferred, with a set of flying hash sign symbols on top.</p>



<p><span style="text-decoration: underline;"><strong><code>--no-progress-meter</code></strong></span><br>Option to switch off the progress meter output without muting or otherwise affecting warning and informational messages like <code>-s, --silent</code> does.<br>Note that this is the negated option name documented.<br>You can thus use <code>--progress-meter</code> to enable the progress meter again.<br>Added in version 7.67.0.</p>



<h2>Connection Test: Get Server Information</h2>



<pre class="wp-block-code"><code>$ curl -I -v --silent --ssl  &#91;protocol://]ip_or_hostname | grep '^&#91;&gt;&lt;*]'</code></pre>



<p>If you specify URL without protocol:// prefix, curl will attempt to guess what protocol you might want.<br>It will then default to HTTP but try other protocols based on often-used host name prefixes.<br>For example, for host names starting with &#8220;ftp.&#8221; curl will assume you want to speak FTP.</p>



<p>curl will do its best to use what you pass to it as a URL.<br><br><a href="https://everything.curl.dev/usingcurl/tls/enable">https://everything.curl.dev/usingcurl/tls/enable</a><br><br>Using <code>--ssl</code> means that curl will attempt to upgrade the connection to TLS but if that fails, it will still continue with the transfer using the plain-text version of the protocol.<br>To make the <code>--ssl</code> option require TLS to continue, there is instead the <code>--ssl-reqd</code> option which will make the transfer fail if curl cannot successfully negotiate TLS.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
