How to check whether url is working or not, through linux shell

bash, linux

Solution

You can do it easily using curl (you may have to install curl if you system doesn't already have it).

for example, performing

curl -is [URL YOU WANT TO CHECK] | head -n 1

will return you a http status code. You can then determine the url exists or not from this status code. For example:

curl -is https://stackoverflow.com/questions/21597851/how-to-check-whether-url-is-working-or-not-through-linux-shell | head -n 1

i.e, your question, will return a 200 status code. `HTTP/2 200`

But another url such as

curl -is https://stackoverflow.com/questions/madeupquestion/example | head -n 1

will return a 404, as it doesn't exist. `HTTP/2 404`

Problem

How to check whether a particular url is woking or not, through linux shell? I tried through elinks, but it shows: ERROR: This application requires javascript enabled in the browser

Original source