Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

bash

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

like image 815
user3209101 Avatar asked Oct 13 '25 06:10

user3209101


1 Answers

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

like image 137
MLeFevre Avatar answered Oct 14 '25 21:10

MLeFevre