{"id":1353,"date":"2022-11-02T16:23:05","date_gmt":"2022-11-02T09:23:05","guid":{"rendered":"https:\/\/longvan.net\/cong-dong\/?p=1353"},"modified":"2022-11-02T16:48:01","modified_gmt":"2022-11-02T09:48:01","slug":"huong-dan-su-dung-lenh-curl-de-download-file","status":"publish","type":"post","link":"https:\/\/longvan.net\/cong-dong\/huong-dan-su-dung-lenh-curl-de-download-file\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng l\u1ec7nh curl \u0111\u1ec3 download file"},"content":{"rendered":"<h4>I. C\u00e0i \u0111\u1eb7t CURL tr\u00ean Linux<\/h4>\n<ul>\n<li>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean Debian \/ Ubuntu v\u00e0 c\u00e1c d\u1eabn xu\u1ea5t, h\u00e3y nh\u1eadp nh\u01b0 sau<br \/>\n<code># sudo apt install curl<\/code><\/li>\n<li>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean RHEL, CentOS, Fedora v\u00e0 c\u00e1c d\u1eabn xu\u1ea5t, h\u00e3y nh\u1eadp nh\u01b0 sau:<br \/>\n<code># sudo yum install curl<\/code><\/li>\n<li>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean OpenSUSE v\u00e0 c\u00e1c d\u1eabn xu\u1ea5t, h\u00e3y nh\u1eadp nh\u01b0 sau:<br \/>\n<code># sudo zipper install curl<\/code><\/li>\n<\/ul>\n<h4>II. C\u00e1ch s\u1eed d\u1ee5ng<\/h4>\n<ul>\n<li>C\u00fa ph\u00e1p chung c\u1ee7a l\u1ec7nh Curl trong Linux nh\u01b0 sau:<br \/>\n<code># curl [options] [URL...]<\/code><\/li>\n<li>Trong \u0111\u00f3:\n<ul>\n<li>Tham s\u1ed1 URL l\u00e0 b\u1eaft bu\u1ed9c.<\/li>\n<li>Tham s\u1ed1 OPTIONS th\u00ec c\u00f3 th\u1ec3 c\u00f3 ho\u1eb7c kh\u00f4ng.<br \/>\nURL l\u00e0 \u0111\u01b0\u1eddng d\u1eabn tr\u1ecf \u0111\u1ebfn th\u01b0 vi\u1ec7n \/ m\u00e3 ngu\u1ed3n tr\u00ean internet, th\u01b0\u1eddng l\u00e0 \u0111\u01b0\u1eddng d\u1eabn c\u00e1c website.<\/li>\n<\/ul>\n<\/li>\n<li><strong>V\u00ed d\u1ee5<\/strong>: L\u1ea5y th\u00f4ng tin m\u00e3 ngu\u1ed3n c\u1ee7a website longvan.net<br \/>\n<code># curl longvan.net<\/code><br \/>\nL\u1ec7nh s\u1ebd tr\u1ea3 k\u1ebft qu\u1ea3 v\u1ec1 l\u00e0 n\u1ed9i dung m\u00e3 HTML c\u1ee7a website. N\u1ebfu b\u1ea1n kh\u00f4ng ch\u1ec9 r\u00f5 s\u1eed d\u1ee5ng ph\u01b0\u01a1ng th\u1ee9c HTTP hay HTTPS th\u00ec n\u00f3 s\u1ebd l\u1ea5y gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh l\u00e0 HTTP.<\/li>\n<\/ul>\n<h4>III. Download file v\u1edbi l\u1ec7nh CURL<\/h4>\n<p>\u0110\u1ec3 t\u1ea3i xu\u1ed1ng m\u1ed9t t\u1ec7p v\u1edbi curl, s\u1eed d\u1ee5ng t\u00f9y ch\u1ecdn\u00a0<code>-o<\/code>\u00a0ho\u1eb7c\u00a0<code>-O<\/code>, theo sau l\u00e0 URL v\u00e0o t\u1ec7p.<\/p>\n<ul>\n<li>T\u00f9y ch\u1ecdn ch\u1eef th\u01b0\u1eddng -o cho ph\u00e9p b\u1ea1n ch\u1ec9 \u0111\u1ecbnh t\u00ean c\u1ee7a t\u1ec7p \u0111\u00e3 l\u01b0u. V\u00ed d\u1ee5 sau, file l\u01b0u l\u1ea1i s\u1ebd c\u00f3 t\u00ean l\u00e0 linux.tar.xz<br \/>\n<code># curl -o linux.tar.xz https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v5.x\/linux-5.5.3.tar.xz<\/code><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1354\" src=\"https:\/\/longvan.net\/cong-dong\/wp-content\/uploads\/2022\/10\/picture5-e1667380467449.png\" alt=\"\" width=\"650\" height=\"89\" \/><\/li>\n<li>V\u1edbi tu\u1ef3 ch\u1ecdn ch\u1eef Hoa l\u00e0 -O l\u01b0u t\u1ec7p v\u1edbi t\u00ean t\u1ec7p g\u1ed1c c\u1ee7a n\u00f3. V\u00ed d\u1ee5 sau s\u1ebd l\u01b0u file v\u1edbi t\u00ean l\u00e0 linux-5.5.3.tar.xz<br \/>\n<code># curl -O https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v5.x\/linux-5.5.3.tar.xz<\/code><\/li>\n<\/ul>\n<p>Ngo\u00e0i ra:<\/p>\n<ul>\n<li>V\u1edbi curl, b\u1ea1n c\u0169ng c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng c\u00e1c t\u1ec7p t\u1eeb m\u00e1y ch\u1ee7 FTP \u0111\u01b0\u1ee3c b\u1ea3o v\u1ec7 b\u1eb1ng m\u1eadt kh\u1ea9u, V\u00ed d\u1ee5:<br \/>\n<code>#curl -u FTP_USERNAME:FTP_PASSWORD ftp:\/\/ftp.example.com\/file.tar.gz<\/code><\/li>\n<li>Khi \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng v\u1edbi t\u00f9y ch\u1ecdn\u00a0<code>-I<\/code>\u00a0curl s\u1ebd hi\u1ec3n th\u1ecb c\u00e1c ti\u00eau \u0111\u1ec1\u00a0<code>HTTP<\/code>\u00a0c\u1ee7a m\u1ed9t URL \u0111\u00e3 cho<\/li>\n<\/ul>\n<p>Nh\u01b0 v\u1eady, Long V\u00e2n \u0111\u00e3 h\u01b0\u1edbng d\u1eabn Qu\u00fd kh\u00e1ch c\u00e1ch s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 CURL \u0111\u1ec3 download file. Ch\u00fac qu\u00fd kh\u00e1ch th\u00e0nh c\u00f4ng !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I. C\u00e0i \u0111\u1eb7t CURL tr\u00ean Linux \u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean Debian \/ Ubuntu v\u00e0 c\u00e1c d\u1eabn xu\u1ea5t, h\u00e3y nh\u1eadp nh\u01b0 sau # sudo apt install curl \u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean RHEL, CentOS, Fedora v\u00e0 c\u00e1c d\u1eabn xu\u1ea5t, h\u00e3y nh\u1eadp nh\u01b0 sau: # sudo yum install curl \u0110\u1ec3 c\u00e0i \u0111\u1eb7t curl tr\u00ean OpenSUSE v\u00e0 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_oasis_is_in_workflow":0,"_oasis_original":0,"footnotes":""},"categories":[4],"tags":[145,146,5],"class_list":["post-1353","post","type-post","status-publish","format-standard","hentry","category-linux","tag-curl","tag-download-file","tag-linux"],"_links":{"self":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/1353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/comments?post=1353"}],"version-history":[{"count":4,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"predecessor-version":[{"id":1445,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/posts\/1353\/revisions\/1445"}],"wp:attachment":[{"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/longvan.net\/cong-dong\/wp-json\/wp\/v2\/tags?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}