Although cURL is known as an HTTP client, it actually supports FTP, LDAP, SMTP, etc. supports. It is used as a client for many protocols. For example, curl is used to transfer data between two servers using these protocols.
You can sometimes see CURL in a script or sometimes in an application’s installation guide. The most used feature of cURL is undoubtedly checking if a URL is accessible. So you never had access to curl? So did you get the «bash: curl: command not found» error?
Let us help you with the causes of this error.
Possible reasons of “bash: curl: command not found” error
Let’s talk about possible causes and solutions for this error.
1. cURL package may not be installed
Pull a website with file use of cURL. If cURL is not installed on the system, you will get the following error:
foc@ubuntu22:~$ curl https://www.golinuxcloud.com/wp-content/uploads/screen-1-e1666772015231.jpg
Command 'curl' not found, but can be installed with:
sudo snap install curl # version 7.84.0, or
sudo apt install curl # version 7.81.0-1ubuntu1.4
See 'snap info curl' for additional versions.
We made this example on Ubuntu. Ubuntu informed us that it is not installed on the system and shared the steps to install it. Let’s share the installation steps for Ubuntu and some other distributions.
ALSO READ: Configure vnc server in RHEL 8 Linux [Step-by-Step]
Install the curl package on Debian-based operating systems (Ubuntu, Pardus, Linux Mint, Kali Linux, etc.):
sudo apt install curl -y
or
sudo apt-get install curl -y
On Ubuntu, you can also install the curl package from the snap store:
sudo snap install curl
Install on Redhat based operating systems (Fedora, Centos, AlmaLinux, Rocky Linux, etc):
sudo dnf -y curl install
or
sudo yum -y install curl
Install on Arch Linux:
sudo pacman -S curl
Upload to openSUSE Leap:
sudo install zypper curl
2. PATH environment variable may be incorrect
The PATH variable may have been configured incorrectly or incompletely by the user. In this case, you will encounter this error even if cURL is installed on the system.
The cURL command is called from /bin/curl
on the system. If there is no /bin
in the user PATH variable, many commands, including cURL, will not work.
For example, if your PATH variable is:
foc@ubuntu22:~$ echo $PATH
/usr/games:/usr/local/games:/snap/bin
When you try to run it with cURL you will get this error:
foc@ubuntu22:~$ curl https://www.golinuxcloud.com/wp-content/uploads/screen-1-e1666772015231.jpg
Command 'curl' is available in the following places
* /bin/curl
* /usr/bin/curl
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
curl: command not found
You can see where the cURL package on your system was called with the which command:
foc@ubuntu22:~$ which curl
/usr/bin/curl
Let’s also add the PATH information to call cURL and similar applications:
foc@ubuntu22:~$ export PATH=$PATH:/bin
You won’t be getting this error in your work with cURL anymore.
ALSO READ: Steps to repair filesystem in rescue mode in RHEL/CentOS 7/8 Linux
Although this is a temporary change, you can make it permanent by placing this command in respective user’s home directory inside ~/.bash_profile
.
Summary
We tried to provide information about what to do for «bash: curl: command not found» error for cURL. If the problem is fixed, you can check out 15+ curl command examples in Linux [Cheat Sheet] that will help you with what you can do with cURL.
You can also get more local help about curl with the following commands:
foc@ubuntu22:~$ curl --help
and
foc@ubuntu22:~$ man curl
References
stackoverflow.com — Linux: Curl installed but -bash: :curl: command not found
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
This post will guide you how to install cURL tool on your Ubuntu or CentOS Linux server. How do I use cURL command to download a web page or a file on Ubuntu Linux 16.04/18.04. How to fix the error message “curl: command not found” or “the program curl is currently not installed” on Ubuntu or CentOS Linux.
- What is cURL?
- Installing cURL through Default Repository
- Installing cURL From Source Package
- Checking URL with CURL
- Download a Single File with CURL
- Download Multiple Files with CURL
- Resume an Interrupted Download with CURL
- Limit the Rate of Data Transfer with CURL
- Get HTTP Headers Information of a URL with CURL
- Follow HTTP Location Headers with CURL
- Pass HTTP Authentication with CURL
- Download Files from FTP Server with CURL
- Upload Files to FTP Server with CURL
- Set User Agent in HTTP Request with CURL
- Check If URL Support HTTP/2 Protocol with CURL
- Save Cookies with CURL
- Send Cookies with CURL
- Use Proxy to Download a File with CURL
- Send Mail with CURL
What is cURL?
cURL is a command line tool for getting or sending data using URL syntax. And it supports various common network protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP. cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. You can use curl command to download or upload files using one of the supported protocols including HTTP, HTTPS, and FTP. You can also use CURL command to get HTTP Header information of a URL, or Pass HTTP Authentication, save or send Cookies.
Curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!
Installing cURL through Default Repository
By default, the curl package is installed on the most Linux distributions. You can try to check the curl package if it is installed on your Ubuntu system with the following command:
$ curl –help
Or
$ curl –version
Outputs:
root@devops:~# curl --version Command 'curl' not found, but can be installed with: apt install curl root@devops:~# curl --help Command 'curl' not found, but can be installed with: apt install curl root@devops:~#
If you get the error message “curl: command not found” from the output of those command, it indicates that curl tool is not installed on your system. Then you can try to install curl package via the default official Ubuntu repository, use the following commands to install curl by using the apt install command:
$ sudo apt update $ sudo apt install curl
Outputs:
root@devops:~# sudo apt update Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease Ign:4 http://dl.google.com/linux/chrome/deb stable InRelease Hit:5 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease Hit:6 http://dl.google.com/linux/chrome/deb stable Release Hit:7 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 19 packages can be upgraded. Run 'apt list --upgradable' to see them. root@devops:~# sudo apt install curl Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus ibverbs-providers icoutils ipxe-qemu ipxe-qemu-256k-compat-efi-roms ldmtool libafflib0v5 libaio1 libaugeas0 libbfio1 libcacard0 libconfig9 libdate-manip-perl libdevmapper-event1.02.1 libewf2 libfdt1 libhfsp0 libhivex0 libibverbs1 libintl-perl libintl-xs-perl libiscsi7 libldm-1.0-0 liblvm2app2.2 liblvm2cmd2.02 libnl-route-3-200 librados2 librbd1 librdmacm1 libsdl1.2debian libspice-server1 libstring-shellquote-perl libsys-virt-perl libtsk13 libusbredirparser1 libvirt0 libwin-hivex-perl libxen-4.9 libxenstore3.0 linux-headers-generic-hwe-16.04 linux-image-generic-hwe-16.04 lsscsi lvm2 msr-tools osinfo-db qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils scrub seabios sgabios sleuthkit supermin zerofree Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: curl 0 upgraded, 1 newly installed, 0 to remove and 19 not upgraded. Need to get 159 kB of archives. After this operation, 395 kB of additional disk space will be used. Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 curl amd64 7.58.0-2ubuntu3.6 [159 kB] Fetched 159 kB in 0s (760 kB/s) Selecting previously unselected package curl. (Reading database ... 230124 files and directories currently installed.) Preparing to unpack .../curl_7.58.0-2ubuntu3.6_amd64.deb ... Unpacking curl (7.58.0-2ubuntu3.6) ... Setting up curl (7.58.0-2ubuntu3.6) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... root@devops:~#
If you want to install PHP-curl on your Ubuntu system, use the following apt command:
$ sudo apt install php-curl
Outputs:
root@devops:~# sudo apt install php-curl Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: augeas-lenses cpu-checker cryptsetup cryptsetup-bin db-util db5.3-util dmeventd extlinux hfsplus The following additional packages will be installed: php-common php7.2-common php7.2-curl The following NEW packages will be installed: php-common php-curl php7.2-common php7.2-curl 0 upgraded, 4 newly installed, 0 to remove and 19 not upgraded. Need to get 925 kB of archives. After this operation, 6,827 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php-common all 1:60ubuntu1 [12.1 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2-common amd64 7.2.15-0ubuntu0.18.04.1 [882 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 php7.2-curl amd64 7.2.15-0ubuntu0.18.04.1 [28.8 kB] Get:4 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php-curl all 1:7.2+60ubuntu1 [1,996 B] Fetched 925 kB in 0s (1,978 kB/s) Selecting previously unselected package php-common. (Reading database ... 230131 files and directories currently installed.) Preparing to unpack .../php-common_1%3a60ubuntu1_all.deb ... Unpacking php-common (1:60ubuntu1) ... Selecting previously unselected package php7.2-common. Preparing to unpack .../php7.2-common_7.2.15-0ubuntu0.18.04.1_amd64.deb ... Unpacking php7.2-common (7.2.15-0ubuntu0.18.04.1) ... Selecting previously unselected package php7.2-curl. Preparing to unpack .../php7.2-curl_7.2.15-0ubuntu0.18.04.1_amd64.deb ... Unpacking php7.2-curl (7.2.15-0ubuntu0.18.04.1) ... Selecting previously unselected package php-curl. Preparing to unpack .../php-curl_1%3a7.2+60ubuntu1_all.deb ... Unpacking php-curl (1:7.2+60ubuntu1) ... Setting up php-common (1:60ubuntu1) ... Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer. Setting up php7.2-common (7.2.15-0ubuntu0.18.04.1) ... Creating config file /etc/php/7.2/mods-available/calendar.ini with new version Setting up php7.2-curl (7.2.15-0ubuntu0.18.04.1) ... Creating config file /etc/php/7.2/mods-available/curl.ini with new version Setting up php-curl (1:7.2+60ubuntu1) ...
Once installed Curl package, you can try to verify curl if it is installed successfully. Using the following command to check the version of installed curl:
$ curl –version
Outputs:
root@devops:~# curl --version curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3 Release-Date: 2018-01-24 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL root@devops:~#
From the above outputs, you should notice that the current installed version of curl is 7.58.0.
Installing cURL From Source Package
Since the default repository are not updated frequently, so it may be possible that you will install an older version of package on your system. And If you want to install the latest version of cURL package on your Ubuntu system, you have to install it from source package. Here are the steps:
#1 downloading the installation package of cURL from the official web site of cURL with the following command (the current latest stable version of cURL is 7.64.0):
$ wget https://curl.haxx.se/download/curl-7.64.0.tar.gz .
Outputs:
root@devops:~# wget https://curl.haxx.se/download/curl-7.64.0.tar.gz . --2019-03-07 21:50:52-- https://curl.haxx.se/download/curl-7.64.0.tar.gz Resolving curl.haxx.se (curl.haxx.se)... 151.101.230.49, 2a04:4e42:36::561 Connecting to curl.haxx.se (curl.haxx.se)|151.101.230.49|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 4032645 (3.8M) [application/x-gzip] Saving to: ‘curl-7.64.0.tar.gz’ curl-7.64.0.tar.gz 100%[==================================>] 3.85M 1.97MB/s in 2.0s 2019-03-07 21:50:54 (1.97 MB/s) - ‘curl-7.64.0.tar.gz’ saved [4032645/4032645] --2019-03-07 21:50:54-- http://./ Resolving . (.)... failed: Name or service not known. wget: unable to resolve host address ‘.’ FINISHED --2019-03-07 21:50:54-- Total wall clock time: 2.9s Downloaded: 1 files, 3.8M in 2.0s (1.97 MB/s) root@devops:~#
#2 extract all files from the downloaded archive package of cURL, type the following command:
$ tar –xvf curl-7.64.0.tar.gz
#3 change the current directory to curl-7.64, type:
$ cd curl-7.64.0/
#4 compiling and installing cURL with the following command:
$ ./configure $ make $ make install
Then cURL should be installed on your Ubuntu Linux server.
Checking URL with CURL
If you want to check a given URL is valid or not, you can use CURL command with -L option to print web content. For example, let’s check http://bing.com if it is valid or not. Type:
$ curl –L http://bing.com
Outputs:
root@devops:~# curl -L http://bing.com <!DOCTYPE html><html lang="zh"><script type="text/javascript" >//<![CDATA[ si_ST=new Date //]]></script><head><link id="bgLink" rel="preload" href="/az/hprichbg/rb/BrittlebushBloom_ZH-CN9198170508_1920x1080.jpg" as="image" /><link rel="preload" href="/sa/simg/hpc26.png" as="image" /><meta content="text/html; charset=utf-8" http-equiv="content-type"/><script type="text/javascript">
From the above outputs, it will print the html code of URL. It indicates that this URL is valid.
Let’s check an invalid URL with curl command, type:
$ curl -L http://abc.abcd
Outputs:
root@devops:~# curl -L http://abc.abcd curl: (6) Could not resolve host: abc.abcd
From the above outputs, the domain name could not be resolved. So it is an invalid URL.
Download a Single File with CURL
You can save or download the output of the curl command from a URL by using –o or –O options.
The option –o (lowercase) will save the output to a file with a specified filename. And the option –O (upperase) will save the output to a file with the same file name as it is in the remove web server.
For example, let’s download one html file from the remove web server with the following command:
$ curl –O https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html
Outputs:
root@devops:~# curl -O https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 91604 0 91604 0 0 14058 0 --:--:-- 0:00:06 --:--:-- 23108 root@devops:~# ls how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html
From the above outputs, the html file is downloaded to the current working directory, and you also should see that html file has been downloaded with the same file name as in the remove web server.
If you want to specify a new file name for the downloaded html file, just type the following command with –o option:
$ curl –o newfile.h https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html
Outputs:
root@devops:~# curl -o newfile.h https://www.osetc.com/en/how-to-install-google-chrome-browser-on-ubuntu-16-04-18-04.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 91603 0 91603 0 0 16413 0 --:--:-- 0:00:05 --:--:-- 21048 root@devops:~# ls newfile.h newfile.h
As you can see from the above outputs, the html file is downloaded with the specified file name.
Download Multiple Files with CURL
If you want to download multiple files at once with CURL command on your Ubuntu system, you can use multiple –O options followed by the download links. Let’s see the following syntax:
$ curl –O downloadLink1 –O downloadLink2
For example, you want to download two files at once with the following command:
$ curl -O https://www.osetc.com/en/how-to-install-blender-on-ubuntu-16-04-18-04-linux.html -O https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html
Outputs:
root@devops:~# curl -O https://www.osetc.com/en/how-to-install-blender-on-ubuntu-16-04-18-04-linux.html -O https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 92768 0 92768 0 0 61233 0 --:--:-- 0:00:01 --:--:-- 61233 100 87688 0 87688 0 0 119k 0 --:--:-- --:--:-- --:--:-- 378k root@devops:~# ls how-to-install-blender-on-ubuntu-16-04-18-04-linux.html how-to-install-bower-on-ubuntu-16-04-18-04-linux.html
Resume an Interrupted Download with CURL
If there is one download job interrupted for some reason, for example, network connection lost or pressing Ctrl + C keys, and you can easily to resume this download process on your system with curl -C option. This option is very useful when you download large files, such as: Linux ISO files.
Continue/Resume a previous file transfer at the given offset. 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. If used with uploads, the FTP server command SIZE will not be used by curl.
Use “-C -” to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out.
If this option is used several times, the last one will be used.
For example, let’s download the installation package of chrome from google official set with the following curl command, and interrupt the downloading process with Ctrl +C, then resume this downloading process with curl –C option. Type:
$ curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb $ curl -C - -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Outputs:
root@devops:~# curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
35 54.6M 35 19.5M 0 0 3984k 0 0:00:14 0:00:05 0:00:09 4010k^C
From the above outputs, you should notice that the current downloading process is 35%. Then it was terminated.
root@devops:~# curl -C - -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
** Resuming transfer from byte position 22016000
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 33.6M 100 33.6M 0 0 5655k 0 0:00:06 0:00:06 --:--:-- 6446k
From this output, you would notice that the previous download is resuming.
Limit the Rate of Data Transfer with CURL
If you want to limit the rate of data transfer when using curl command to download files, you can use –limit-rate option to specify the maximum transfer rate you want curl to use for both downloads and uploads files.
This option is also very useful if you have a limited pipe and you want your transfer process not to use your entire bandwidth. And the given speed is measured in bytes/second by default, unless a suffix is append. Appending ‘k’ or ‘K’ will count the number as kilobytes, ‘m’ or ‘M’ makes it megabytes, while ‘g’ or ‘G’ makes it gigabytes. Examples: 200K, 3m and 1G.
For example, if you want to limit the download speed to 1K/s when downloading the installation package of chrome. Using the following command:
$ curl –limit-rate 1K
Outputs:
root@devops:~# curl -O --limit-rate 1k https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 54.6M 0 3595 0 0 1872 0 8:30:06 0:00:01 8:30:05 940
From the above outputs, you should see that the current transfer speed is near to the 1kB/s.
Get HTTP Headers Information of a URL with CURL
If you want to fetch the HTTP headers of a specified URL with CURL command, you can use –I option to get the header information of one URL. When used on an FTP or FILE file, curl displays the file size and last modification time only.
Let’s see the following example to get all the HTTP response headers of https://www.osetc.com, type:
$ curl –I https://www.osetc.com
Outputs:
root@devops:~# curl -I https://www.osetc.com HTTP/1.1 200 OK Date: Sat, 09 Mar 2019 10:33:45 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16 X-Powered-By: PHP/5.4.16 Link: <https://www.osetc.com/wp-json/>; rel="https://api.w.org/" Content-Type: text/html; charset=UTF-8
Follow HTTP Location Headers with CURL
When the requested page has moved to a different location, such as: it indicated with a Location: header and a 3xx response code, and CURL command does not follow the HTTP location header. You can use –L or –location option to make curl redo the HTTP request on the new location.
For example, you try to request a web URL www.osetc.com, and it will be redirected to a new location: https://www.osetc.com. And if you want to redirect to the new location, you need to use –L option. Type the following command:
$ curl www.osetc.com $ curl –L www.osetc.com
Outputs:
root@devops:~# curl www.osetc.com <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="https://www.osetc.com/">here</a>.</p> </body></html>
From the above outputs, you would notice that the request document has moved to https://www.osetc.com.
root@devops:~# curl -L www.osetc.com | head % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 230 100 230 0 0 502 0 --:--:-- --:--:-- --:--:-- 502 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0<!DOCTYPE html> <html lang="en-US" class="no-js no-svg"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="http://gmpg.org/xfn/11"> <script>(function(html){html.className = html.className.replace(/bno-jsb/,'js')})(document.documentElement);</script>
From the above outputs, you can see that the curl command redirected to the new location using –L option, and it downloaded the https://www.osetc.com html source code.
Pass HTTP Authentication with CURL
If you are using curl to request a web content that need to type a username and password to authenticate it. At this moment, you can use –u option to pass the user name and password to use for the remote server authentication. If you only specify the user name in curl command, and curl will prompt for a password. And the user name and password are split up on the first colon character.
The Syntax is as below:
$ curl –u username:password https://www.osetc.com
Download Files from FTP Server with CURL
If you want to download files from a remote FTP server, you can also use curl command with –u and –O options.
For example, you want to download a file called text.tar from a FTP server ftp://myftp.com/pub/. And this file is located under pub directory in FTP server. Type the following command to download file to local disk with curl command:
$ curl –u ftpuser:ftppassword -O ftp://myftp.com/pub/text.tar
This command will try to download the text.tar file from the myftp ftp server and store it in the current directory on your system.
If the specified FTP URL is also refer to a directory, and the above curl command will only list all the files under that directory in the given URL. Like the below command:
$ curl –u ftpuser:ftppassword -O ftp://myftp.com/pub/
Upload Files to FTP Server with CURL
The above section explains that how to download file from ftp server, and you can also upload a file to the remote FTP server with –T option using CURL command.
For example, you would like to upload a file called text.tar to the FTP server ftp://myftp.com/pub/, just type the following command:
$ curl –u ftpuser:ftppassword -T ./text.tar ftp://myftp.com/pub/
Set User Agent in HTTP Request with CURL
If you want to specify the user-agent string in HTTP request to send to the HTTP server, you can use –A option or — user-agent option in curl command.
For example, you want to set one user-agent string as “this is user agent from scott!!!!”, using the following command:
$ curl –I https://www.osetc.com/ --user-agent “this is user agent from scott!!!!”
Outputs:
root@devops:~# curl –I www.osetc.com/ --user-agent "this is user agent from scott"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.osetc.com/">here</a>.</p>
</body></html>
[scott@test logs]# tail -f access.log
111.198.231.159 - - [09/Mar/2019:11:20:29 +0000] "GET / HTTP/1.1" 301 230 "-" "this is user agent from scott"
Check If URL Support HTTP/2 Protocol with CURL
If you want to check if a URL supports HTTP/2 protocol, you can use curl command with –I option and then combine with grep command to check it. For example, you want to check URL https://www.osetc.com if it supports HTTP/s protocol, type the following command:
$ curl –I https://www.osetc.com | grep HTTP
Outputs:
root@devops:~# curl -I https://www.osetc.com | grep HTTP % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 HTTP/1.1 200 OK
From the above outputs, you should see that it only supports HTTP/1.1 protocol.
Save Cookies with CURL
If you want curl to write all cookies to a specified file after a completed operation. You can use –c or –cookie-jar options to write all cookies from its in-memory cookie storage to the give file at the end of operations.
For Example, you want to save cookies to a give file called bingcookies.txt after fetching https://www.bing.com/index.html, using the following commands:
$ curl --cookie-jar bingcookie.txt https://www.bing.com/index.html –O $ cat bingcookie.txt
Outputs:
root@devops:~# curl --cookie-jar bingcookie.txt https://www.bing.com/index.html -O % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 root@devops:~# cat bingcookie.txt # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. #HttpOnly_.bing.com TRUE / FALSE 0 _EDGE_S F=1&SID=17D7595C2B246363189E54462A0A6204 #HttpOnly_.bing.com TRUE / FALSE 1585835514 _EDGE_V 1 .bing.com TRUE / FALSE 1585835514 MUID 11E7B9E8E89860DE07EBB4F2E9B6610E #HttpOnly_www.bing.com FALSE / FALSE 1585835514 MUIDB 11E7B9E8E89860DE07EBB4F2E9B6610E
Send Cookies with CURL
You can pass the data to the HTTP server in the cookie header, when making HTTP requests using CURL. You can use –b or –cookie option to send specific cookies to remote HTTP server. The data should be in the format “NAME1=VALUE1; NAME2=VALUE2”. Or you can also specify a cookie file to send it to HTTP server. For example, you want to send cookie file called bingcookie.txt to make HTTP requests to remote server, type:
$ curl –cookie bingcokie.txt https://www.bing.com
Use Proxy to Download a File with CURL
If you need to use a proxy server on proxyauto.test.com port 8080 to fetch a webpage source code with curl command, you need to use –x option. The proxy string can be specified with a protocol:// prefix. No protocol specified or http:// will be treated as HTTP proxy. Use socks4://, socks4a://, socks5:// or socks5h:// to request a specific SOCKS version to be used.
HTTPS proxy support via https:// protocol prefix was added in 7.52.0 for OpenSSL, GnuTLS and NSS.
Like this:
$ curl –x proxyauto.test.com:8080 https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html
And if the proxy server need to authenticate when curl fetch files, you need to use the –U option to specify username and password by a colon, like this:
$ curl –x proxyauto.test.com:8080 –U username:password https://www.osetc.com/en/how-to-install-bower-on-ubuntu-16-04-18-04-linux.html
Send Mail with CURL
You can also use CURL to send mail using the SMTP server, and you need to specify a single address that the given mail should get send from. And specify a single address, user name or mailing list name. Like this:
$ curl –mail-from sender@osetc.com --mail-rcpt receiver@osetc.com smtp://smtpserver.com
Conclusion
You should know that how to install and use cURL tool on Ubuntu or CentOS Linux from this guide, and you also know how to install cURL tool with the different methods on Ubuntu Linux server. If you want to see more information about cURL, you can go the official web site of cURL directly.
-
Eternyt
- Posts: 46
- Joined: Tue Dec 19, 2017 4:23 pm
PHP module cURL not installed Nextcloud error
I decide to update my setup from stretch to buster, and I now encounter an error when I try to connect to my next cloud server. The error, as the title says, is : PHP module cURL not installed.
I checked if it was installed using apt-get and it says that I have the latest version, but if I try to enable (or disable) it using a2enmod it says that does not exist.
Any help/suggestion?
Thanks!
-
rpdom
- Posts: 21218
- Joined: Sun May 06, 2012 5:17 am
- Location: Chelmsford, Essex, UK
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 11:10 am
What exactly were you trying to install using apt? Was it php-curl?
Seeing as it is not an Apache module, a2enmod has nothing to do with it.
Upgrading from Stretch to Buster will switch you from PHP5 to PHP7, so you’ll need the right module for the version of PHP you are using. You may have both installed.
Unreadable squiggle
-
Eternyt
- Posts: 46
- Joined: Tue Dec 19, 2017 4:23 pm
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 11:42 am
I was thinking that by using apt-get I would be able to install the curl module for apache.
I need the php-curl module because nextcloud require it, but I don’t know how to install it. Or how to tell Apache2 that is already installed.
I know that I updated from php5 to php7, but from what I can tell, I now have only the php7 version. (checking using apt-get)
-
pidd
- Posts: 4439
- Joined: Fri May 29, 2020 8:29 pm
- Location: Wirral, UK
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 12:38 pm
Have a look at /etc/apache2/mods-available, the php conf files will tell you which version of php apache is using, it will be something like php.7.3.conf
Then have a hunt around the relevant php.ini, mods and configs in /etc/php/7.3/apache2 (or whichever php version apache is using) for the curl mod and configuration.
-
Eternyt
- Posts: 46
- Joined: Tue Dec 19, 2017 4:23 pm
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 1:45 pm
In the /etc/apache2/mods-available I have both php7.3.conf and php7.0.conf, is it bad?
Also, I don’t see any curl module in the directory.
In the /etc/php/7.3/apache2 directory I have conf.d and php.ini. In the php.ini I have the curl module mentioned, and in the conf.d I have the 20-curl.ini file. Also, in the /etc/php directory I have both 7.1 7.2 and 7.3 folders. How can I know which one is in use by apache2?
Thanks for the help!
-
pidd
- Posts: 4439
- Joined: Fri May 29, 2020 8:29 pm
- Location: Wirral, UK
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 2:15 pm
Sorry, I mixed up seeing what was installed and what was being used.
Go to /etc/apache2/mods-enabled to see which one is in use, if you have both in there then that is definitely wrong.
-
Eternyt
- Posts: 46
- Joined: Tue Dec 19, 2017 4:23 pm
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 4:06 pm
In /etc/apache2/mods-enabled I have php7.0.conf. How can I switch to php7.3?
And also, I’m not able to see anywhere the curl module, both in mods-enabled and in mods-available. How can I add it?
-
pidd
- Posts: 4439
- Joined: Fri May 29, 2020 8:29 pm
- Location: Wirral, UK
Re: PHP module cURL not installed Nextcloud error
Fri Dec 25, 2020 10:10 pm
/etc/php/7.3/apache2/curl.d should have 20-curl.ini in it which is linked to the cli php area
Code: Select all
:/etc/php/7.3/apache2/conf.d $ ls -al
total 8
drwxr-xr-x 2 root root 4096 Dec 9 00:43 .
drwxr-xr-x 3 root root 4096 Dec 21 10:20 ..
lrwxrwxrwx 1 root root 39 Dec 9 00:41 10-mysqlnd.ini -> /etc/php/7.3/mods-available/mysqlnd.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 10-opcache.ini -> /etc/php/7.3/mods-available/opcache.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:41 10-pdo.ini -> /etc/php/7.3/mods-available/pdo.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:43 15-xml.ini -> /etc/php/7.3/mods-available/xml.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:43 20-bz2.ini -> /etc/php/7.3/mods-available/bz2.ini
lrwxrwxrwx 1 root root 40 Dec 9 00:41 20-calendar.ini -> /etc/php/7.3/mods-available/calendar.ini
lrwxrwxrwx 1 root root 37 Dec 9 00:41 20-ctype.ini -> /etc/php/7.3/mods-available/ctype.ini
lrwxrwxrwx 1 root root 36 Dec 9 00:43 20-curl.ini -> /etc/php/7.3/mods-available/curl.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:43 20-dom.ini -> /etc/php/7.3/mods-available/dom.ini
lrwxrwxrwx 1 root root 36 Dec 9 00:41 20-exif.ini -> /etc/php/7.3/mods-available/exif.ini
lrwxrwxrwx 1 root root 40 Dec 9 00:41 20-fileinfo.ini -> /etc/php/7.3/mods-available/fileinfo.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:41 20-ftp.ini -> /etc/php/7.3/mods-available/ftp.ini
lrwxrwxrwx 1 root root 34 Dec 9 00:41 20-gd.ini -> /etc/php/7.3/mods-available/gd.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 20-gettext.ini -> /etc/php/7.3/mods-available/gettext.ini
lrwxrwxrwx 1 root root 37 Dec 9 00:41 20-iconv.ini -> /etc/php/7.3/mods-available/iconv.ini
lrwxrwxrwx 1 root root 36 Dec 9 00:41 20-json.ini -> /etc/php/7.3/mods-available/json.ini
lrwxrwxrwx 1 root root 40 Dec 9 00:43 20-mbstring.ini -> /etc/php/7.3/mods-available/mbstring.ini
lrwxrwxrwx 1 root root 38 Dec 9 00:41 20-mysqli.ini -> /etc/php/7.3/mods-available/mysqli.ini
lrwxrwxrwx 1 root root 41 Dec 9 00:41 20-pdo_mysql.ini -> /etc/php/7.3/mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root 36 Dec 9 00:41 20-phar.ini -> /etc/php/7.3/mods-available/phar.ini
lrwxrwxrwx 1 root root 37 Dec 9 00:41 20-posix.ini -> /etc/php/7.3/mods-available/posix.ini
lrwxrwxrwx 1 root root 40 Dec 9 00:41 20-readline.ini -> /etc/php/7.3/mods-available/readline.ini
lrwxrwxrwx 1 root root 37 Dec 9 00:41 20-shmop.ini -> /etc/php/7.3/mods-available/shmop.ini
lrwxrwxrwx 1 root root 41 Dec 9 00:43 20-simplexml.ini -> /etc/php/7.3/mods-available/simplexml.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 20-sockets.ini -> /etc/php/7.3/mods-available/sockets.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 20-sysvmsg.ini -> /etc/php/7.3/mods-available/sysvmsg.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 20-sysvsem.ini -> /etc/php/7.3/mods-available/sysvsem.ini
lrwxrwxrwx 1 root root 39 Dec 9 00:41 20-sysvshm.ini -> /etc/php/7.3/mods-available/sysvshm.ini
lrwxrwxrwx 1 root root 41 Dec 9 00:41 20-tokenizer.ini -> /etc/php/7.3/mods-available/tokenizer.ini
lrwxrwxrwx 1 root root 36 Dec 9 00:43 20-wddx.ini -> /etc/php/7.3/mods-available/wddx.ini
lrwxrwxrwx 1 root root 41 Dec 9 00:43 20-xmlreader.ini -> /etc/php/7.3/mods-available/xmlreader.ini
lrwxrwxrwx 1 root root 41 Dec 9 00:43 20-xmlwriter.ini -> /etc/php/7.3/mods-available/xmlwriter.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:43 20-xsl.ini -> /etc/php/7.3/mods-available/xsl.ini
lrwxrwxrwx 1 root root 35 Dec 9 00:43 20-zip.ini -> /etc/php/7.3/mods-available/zip.ini
Iirc if you install php as a standalone package is doesn’t load a lot of modules, however php itself and loads of modules get loaded when you install apache2, mariadb-server and phpmyadmin.
To change which version of php apache uses
Code: Select all
sudo a2dismod php7.0
sudo a2enmod php7.3
sudo systemctl reload apache2
-
Eternyt
- Posts: 46
- Joined: Tue Dec 19, 2017 4:23 pm
Re: PHP module cURL not installed Nextcloud error
Sat Dec 26, 2020 8:45 am
Yes in the /etc/php/7.3/mods-available curl is present. But I’m not able to enable it because in apache2/mods-available is not present
-
rpdom
- Posts: 21218
- Joined: Sun May 06, 2012 5:17 am
- Location: Chelmsford, Essex, UK
Re: PHP module cURL not installed Nextcloud error
Sat Dec 26, 2020 9:03 am
Which version of PHP is enabled for Apache?
Code: Select all
rpdom@raspi12:~ $ ls /etc/apache2/mods-enabled | grep php
php7.3.conf
php7.3.load
If it is not 7.3, then it won’t pick up your curl 7.3 module.
You can’t use a2enmod for curl as it is a PHP module, not an Apache module.
You can use a2enmod to enable the right version of PHP in Apache.
You will never see curl in /etc/apache2/mods-available.
Unreadable squiggle
-
pidd
- Posts: 4439
- Joined: Fri May 29, 2020 8:29 pm
- Location: Wirral, UK
Re: PHP module cURL not installed Nextcloud error
Sat Dec 26, 2020 5:57 pm
Eternyt wrote: ↑
Sat Dec 26, 2020 8:45 am
Yes in the /etc/php/7.3/mods-available curl is present. But I’m not able to enable it because in apache2/mods-available is not present
Curl is a php mod not an apache mod.
Return to “Troubleshooting”
Пользователь 423277 Заглянувший Сообщений: 9 |
ДОбрый день друзья. Это мой первый пост — не судите строго. Дайте направление что делать. Заранее благодарю! |
Пользователь 19968 Эксперт Сообщений: 259 |
1. копируем 20-curl.ini.disabled в 20-curl.ini проверяем. |
Пользователь 423277 Заглянувший Сообщений: 9 |
Сделал. Может быть я конечно что не понимаю, просто, когда установил сторонний модуль, там было написано, что необхдима CURL. А при попытке настроить его, выходит ошибка — Call to undefined function curl_init() Файл переименовал — та же самая ошибка. |
Пользователь 265201 Эксперт Сообщений: 1340 |
#4 1 19.01.2016 07:19:28
|
||
Пользователь 423277 Заглянувший Сообщений: 9 |
установил. переименовал. перезапустил сервер — так же ошибка |
Пользователь 423277 Заглянувший Сообщений: 9 |
эти файлы (20-curl.ini и 20-curl.ini.disabled) вообще пустые, весят 0 Кб. Может я все-таки чего то не понимаю. Как узнать включен Curl вообще или нет? Сейчас установил еще один модуль аналогичной функциональности — пишет, что не установлен CURL |
Пользователь 265201 Эксперт Сообщений: 1340 |
если файл пустой, в в файл 20-curl.ini надо внести extension=curl.so |
Пользователь 423277 Заглянувший Сообщений: 9 |
#8 0 19.01.2016 09:32:04
Заработало! Спасибо большое Виталий. Пару вопросов: |
||
Пользователь 265201 Эксперт Сообщений: 1340 |
1. не могу сказать, обычно при установки bitrixVM файл *.disabled содержит в себе строку подключения |
Пользователь 325885 Постоянный посетитель Сообщений: 218 |
#10 1 24.02.2016 13:52:04
2. Цифры указывают на приоритет загрузки, чем ниже — тем раньше загрузится данный модуль. |
||||
Пользователь 305804 Заглянувший Сообщений: 20 |
#11 0 24.03.2017 17:24:44
Спасибо, Помогло. |
||
Пользователь 186210 Посетитель Сообщений: 30 |
#12 0 12.07.2018 01:11:13 Если при установке возникла ошибка как ниже то вводим очистить все И снова устанавливаем Затем копируем содержимое как в во втором сообщении и делаем рестарт epel/x86_64/primary FAILED http://www.nic.funet.fi/pub/mirrors/fedora.redhat.com/pub/epel/7/x86_64/repodata /27fea268205fe1c8821b4fc84996fa6c9bf32f86bb229655ea1f755bb90f3de8-primary.xml.gz : [Errno 14] HTTP Error 404 — Not Found |
Пользователь 3479803 Заглянувший Сообщений: 2 |
#13 4 26.01.2020 12:25:47 Столкнулся с такой же проблемой на ver. 7.4.3 установленной на выделенный сервер (продукт Интернет-магазин + CRM) при установке модуля оплаты с сайта. И вот какое решение нашел. Может кому-то пригодится. Качаем PuTTY . Запускаем putty.exe. Вводим IP-адрес, порт, входим под root, далее пароль. Попадаем в главное меню, выбираем «8» «manage pool web servers». В следующем меню нажимаем «2» «Manage PHP extensions». В следующем меню выбираем также пункт «2» «Enable curl extension» (у меня на скриншоте он называется «Disable curl extension» так он у меня уже включен в данный момент). Далее возвращаемся во второе меню («Configure localhost setting») и выбираем пункт «4» «Reboot server». Далее выходим и наслаждаемся результатами. |
Пользователь 1666821 Заглянувший Сообщений: 6 |
#14 0 26.02.2021 11:14:14
Добавлю к этой инструкции, что подключившись к вирутальной машине, надо вызвать главное меню битрикса, это делается командой:
|
||||
Пользователь 2337525 Постоянный посетитель Сообщений: 180 |
#15 0 26.02.2021 12:53:39 Могу добавить что Reboot server вовсе не обязательно. Достаточно перезапустить только апач командой service httpd restart |
Пользователь 4620418 Заглянувший Сообщений: 2 |
#16 0 23.04.2021 13:13:06
У меня на сервере в 20-curl.ini была строка extension=curl заменил на extension=curl.so сделал рестарт Apache service httpd restart |
||
Пользователь 1474153 Посетитель Сообщений: 29 |
#17 0 09.05.2022 00:49:33 в моем случае сразу две ошибки были решены, в одной из них обновление модуля WACS: АнтиБот давало ошибку. таблетка — в ВМ включила curl |