Change User Agent on cURL

Windows Articles

How to update apps on Android

Hi folks! In this post, we will show you how to update your Android apps. Updating the apps on your device is...

How to install Apache Ant on Ubuntu 20.04?

Hello, friends. Apache Ant is a very important tool for the development of applications in Java. So in this post, we will...

How to use the ss command

For Linux users, there will come a time when you need to know about the network. Several tools help in this process,...

How to create user template in Windows Server 2019/2016

Hello! Windows Server has many features that support system administration. For example, through the users it is possible to manage many administrative...

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...
Mel Khamlichi
Mel Khamlichihttp://www.osradar.com
Founder of Osradar, from Amsterdam Netherlands

cURL is a really useful tool for Linux users. This tool can easily download all the files from the internet over lots of supported protocols – FTP, HTTPS, IMAP, POP3, RTSP, SMB, SMTP, SCP, DICT etc. and lot more. That’s why it’s my favorite tool to download files from the internet instead of “wget”. When you use cURL, the server sees you as a browser requesting file access. Now, let’s take a look how to change the user agent of cURL.

When connecting to the server, the program sends a data like this – “Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0”. The server identifies that you’re using Firefox (although you’re not). You can set out the option of your favorite browser as user-agent of the cURL tool.

Changing the user-agent

In cURL, the syntax for changing the user-agent follows this structure –

curl -A "user-agent-name-here" url
curl --user-agent "user-agent-name-here" url
curl -H "User-Agent: user-Agent-Name-Here"

The user agent also follows this structure –

Mozilla/[version] ([system and browser information]) [platform] ([platform details]) [extensions]

In this command line example, I’ll be using Firefox as the user-agent of cURL for connecting with OSRadar.

$ curl -A "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0" https://www.osradar.com/
$ curl -I -A "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0" https://www.osradar.com/

If you want to use your user-agent as Safari, use this command line –

curl -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (K HTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" https://www.osradar.com/

Enjoy cURL!

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to update apps on Android

Hi folks! In this post, we will show you how to update your Android apps. Updating the apps on your device is...

How to install Apache Ant on Ubuntu 20.04?

Hello, friends. Apache Ant is a very important tool for the development of applications in Java. So in this post, we will...

How to use the ss command

For Linux users, there will come a time when you need to know about the network. Several tools help in this process,...

How to create user template in Windows Server 2019/2016

Hello! Windows Server has many features that support system administration. For example, through the users it is possible to manage many administrative...

Debian 10.6 available

Several volunteers have developed the free software distributed under the name of Debian. Debian does not sell its software directly, the developers...