How to Use wget command in linux

wget command in linux

 Wget Command in Linux

हैलो दोस्तो कैसे है आप सब आज मैं आपको How to use wget command in linux इसके बारे में बताने वाला हूँ दोस्तों अगर आप Termux या linux का Use करते है तो आप Wget के बारे में थोड़ा जानते होंगे तो मै कुछ Command के बारे में जानकारी देने वाला हूँ इस आर्टिकल को पूरा पढ़े और बताए गए Steps को Follow करे  और ध्यान से पढ़ें मैं आपको Steps by Steps सारी जानकारी बताने वाला हूं.

 

इस पोस्ट बताया पुरे Details में जानकरी दी सारे Option दिया गया है और  wget command का उपयोग कैसे करें।

 

 Installing Wget | Wget को कैसे Install करें ?

अभी की बात करे तो  Wget Package हमें पहले से ही  pre-installed मिलता है Mostly अगर नहीं Install है तो हम Manual Wget Package को install करे सकते है 

 

अगर आपके सिस्टम में पहले से  Wget Packages install है और उसे कैसे check करे सकते है Type करे wget , और Enter press करे यदि आपने wget इंस्टॉल किया हुआ है, तो सिस्टम wget: (missing URL) प्रिंट करेगा। अन्यथा, यह wget ( command not found.) कमांड नहीं मिला प्रिंट करेगा।

 

यदि wget इंस्टॉल नहीं है, तो आप इसे अपने डिस्ट्रो के पैकेज मैनेजर का उपयोग करके आसानी से इंस्टॉल कर सकते हैं।

Installing Wget on Ubuntu and Debian


$ sudo apt install wget


Installing Wget on CentOS and Fedora


$ sudo yem install wget

Wget Command Syntax


Wget कमांड का उपयोग करने से पहले, Basic Syntax के बारे में जानते है।  

wget [options] [url]
 

options - The Wget options
url - URL of the file or directory you want to download or synchronize.

How to Download a File with wget

अपने सरलतम रूप में, जब बिना किसी option  के उपयोग किया जाता है, तो wget [url] में specified resource को current directory.में डाउनलोड करेगा।

 कुछ Example है Linux kernel tar archive डाउनलोड कर सकते है 

$ https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.2.tar.xz






जैसा कि आप ऊपर की image में देख सकते हैं, wget डोमेन के IP address, को resolving करके शुरू होता है, फिर रिमोट सर्वर से जुड़ता है और Transfer शुरू करता है।


दोस्तों डाउनलोड के दौरान, wget फ़ाइल नाम, file size , डाउनलोड गति और डाउनलोड को पूरा करने के अनुमानित समय के साथ प्रगति पट्टी दिखाता है। एक बार डाउनलोड पूरा हो जाने पर, आप डाउनलोड की गई फ़ाइल को अपनी current working directory में पा सकते हैं।

To turn off the output, use the -q option.

यदि फ़ाइल पहले से मौजूद है, तो फ़ाइल नाम के अंत में wget .N (संख्या) जोड़ देगा।

Saving the Downloaded File Under Different Name


डाउनलोड की गई फ़ाइल को किसी different नाम से Save के लिए, चुने हुए नाम के बाद -O विकल्प पास करें:


$ wget -O latest-hugo.zip https://github.com/gohugoio/hugo/archive/master.zip

ऊपर दिया गया आदेश GitHub से नवीनतम hugo zip फ़ाइल को उसके मूल नाम के बजाय नवीनतम-hugo.zip के रूप में Save करे.

Downloading a File to a Specific Directory


Default रूप से, wget डाउनलोड की गई फ़ाइल को Current working directory में Save करता है फ़ाइल को किसी specific स्थान पर Save के लिए, -P Option का उपयोग करें: 

$ wget -P /mnt/iso http://mirrors.mit.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso

ऊपर दिया गया command wget को CentOS 7 iso फाइल को /mnt/iso directory में सेव करने के लिए कहता है।

Limiting the Download Speed


Download गति को सीमित करने के लिए --limit-rate विकल्प का उपयोग करें। By default रूप से, गति को बाइट्स/सेकंड में मापा जाता है। किलोबाइट के लिए k, मेगाबाइट के लिए m और गीगाबाइट के लिए g जोड़ें।

इसमे आदेश Go binary डाउनलोड करेगा और डाउनलोड गति को 1 MB  तक सीमित कर देगा:


$ wget --limit-rate=1m https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz

यह विकल्प तब उपयोगी होता है जब आप सभी उपलब्ध Bandwidth का Consume नहीं करना चाहते।

Resuming a Download


यदि आप -c विकल्प का उपयोग करके डाउनलोड फिर से शुरू कर सकते हैं। यह तब उपयोगी होता है जब किसी बड़ी फ़ाइल के डाउनलोड के दौरान आपका कनेक्शन गिर जाता है, और डाउनलोड को शुरू से शुरू करने के बजाय, आप पिछले वाले को जारी रख सकते हैं।
निम्नलिखित example में, हम Ubuntu 18.04 iso फाइल का डाउनलोड फिर से शुरू कर रहे हैं:


$ wget -c http://releases.ubuntu.com/18.04/ubuntu-18.04-live-server-amd64.iso

यदि Remote सर्वर डाउनलोड को फिर से शुरू करने का Support नहीं करता है, तो wget शुरू से ही डाउनलोड शुरू कर देगा और मौजूदा फाइल को overwrite कर देगा।

Downloading in Background


Background में डाउनलोड करने के लिए -b option का इस्तेमाल करें। निम्नलिखित example में, हम पृष्ठभूमि में OpenSuse iso फ़ाइल डाउनलोड कर रहे हैं:

$ wget -b https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-DVD-x86_64-Current.iso

Default रूप से, आउटपुट को  current directory.  में wget-log फ़ाइल पर redirected किया जाता है। डाउनलोड की स्थिति देखने के लिए, tail command का उपयोग करें:
 
tail -f wget-log

Changing the Wget User-Agent


कभी-कभी फ़ाइल डाउनलोड करते समय, remote सर्वर को Wget User-Agent को ब्लॉक करने के लिए सेट किया जा सकता है। इस तरह की स्थितियों में, किसी different ब्राउज़र का अनुकरण करने के लिए, -U विकल्प पास करता है 


$ wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" http://wget-forbidden.com/

ऊपर दिया गया command Firefox 60 का अनुकरण करेगा जो पेज को wget-forbidden.com से requesting करता है

wget-forbidden.com

Downloading Multiple Files


यदि आप एक साथ कई फाइलें डाउनलोड करना चाहते हैं, तो डाउनलोड किए जाने वाले URL की सूची वाली स्थानीय या बाहरी फ़ाइल के path के बाद -i विकल्प का उपयोग करें। प्रत्येक URL को एक अलग लाइन पर होना चाहिए।
कुछ  उदाहरण दिखाता है कि linux-distros.txt फ़ाइल में निर्दिष्ट URL का उपयोग करके आर्क Linux, Debianऔर Fedora iso फाइलों को कैसे डाउनलोड किया जाए:

wget -i linux-distros.txt



$ wget -i linux-distros.txt

linux-distros.txt

$ http://mirrors.edge.kernel.org/archlinux/iso/2018.06.01/archlinux-2018.06.01-x86_64.iso https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.4.0-amd64-netinst.iso https://download.fedoraproject.org/pub/fedora/linux/releases/28/Server/x86_64/iso/Fedora-Server-dvd-x86_64-28-1.1.iso

यदि आप specify करते हैं - एक फ़ाइल नाम के रूप में, URL को मानक इनपुट से पढ़ा जाएगा।

Downloading via FTP


 Password-protected FTP सर्वर से फ़ाइल डाउनलोड करने के लिए, username और password specify करें जैसा कि नीचे दिखाया गया है:

wget --ftp-user=FTP_USERNAME --ftp-password=FTP_PASSWORD ftp://ftp.example.com/filename.tar.gz

Creating a Mirror of a Website #

wget वाली वेबसाइट का mirror बनाने के लिए -m option का इस्तेमाल करें। यह सभी internal लिंक के साथ-साथ वेबसाइट resources (JavaScript, CSS, Images) का अनुसरण और डाउनलोड करके वेबसाइट की एक पूरी local copy तैयार करेगा।


$ wget -m https://example.com


यदि आप local browsing के लिए डाउनलोड की गई वेबसाइट का उपयोग करना चाहते हैं, तो आपको ऊपर दिए गए command में कुछ अधिक arguments देने होंगे।

$ wget -m -k -p https://example.com


Option -k  डाउनलोड किए गए documents में लिंक को local viewing के लिए उपयुक्त बनाने के लिए wget को convert करने का कारण बनेगा। -p विकल्प wget को HTML पेज प्रदर्शित करने के लिए सभी necessary फाइलों को डाउनलोड करने के लिए कहेगा।

Skipping Certificate Check


यदि आप किसी ऐसे host से HTTPS पर फ़ाइल डाउनलोड करना चाहते हैं जिसके पास एक invalid SSL certificate है, तो --no-check-certificate विकल्प का उपयोग करें:


$ wget --no-check-certificate https://domain-with-invalid-ss.com

Downloading to the Standard Output


निम्नलिखित उदाहरण में, wget silently (flag -q) latest WordPress version को stdout (flag -O -) में डाउनलोड और आउटपुट करेगा और इसे टार utilityमें pipe करेगा, जो आर्काइव को /var/www directory में extract करेगा।

$ wget -q -O - "http://wordpress.org/latest.tar.gz" | tar -xzf - -C /var/www

Post के बारे में :


हम आशा करते है आपको यह आर्टिकल पसंद आया होगा इसमें आपको बताया गया How to use wget command in linux और wget के साथ, आप कई फ़ाइलें डाउनलोड कैसे कर सकते हैं, आंशिक डाउनलोड फिर से शुरू कर सकते हैं, वेबसाइटों को mirror कर सकते हैं और अपनी आवश्यकताओं के अनुसार Wget विकल्पों को जोड़ सकते हैं। अगर फिर भी आपका कोई सवाल हो इस पोस्ट से Related तो हमें Comment कर सकते है OK धन्यबाद !

Post a Comment

Previous Post Next Post