Score:-1

What is the `GET` command in Ubuntu?

in flag

What is the GET command in Ubuntu? When I was trying out telnet, I accidentally typed in GET / too slowly, and it timed out, and I accidentally pressed Enter, and it ran the command GET.

The output was:

HTML>
<HEAD>
<TITLE>Directory /</TITLE>
<BASE HREF="file:/">
</HEAD>
<BODY>
<H1>Directory listing of /</H1>
<UL>
<LI><A HREF="./">./</A>
<LI><A HREF="../">../</A>
<LI><A HREF="bin/">bin/</A>
<LI><A HREF="boot/">boot/</A>
<LI><A HREF="cdrom/">cdrom/</A>
<LI><A HREF="dev/">dev/</A>
<LI><A HREF="etc/">etc/</A>
<LI><A HREF="home/">home/</A>
<LI><A HREF="lib/">lib/</A>
<LI><A HREF="lib32/">lib32/</A>
<LI><A HREF="lib64/">lib64/</A>
<LI><A HREF="libx32/">libx32/</A>
<LI><A HREF="lost%2Bfound/">lost+found/</A>
<LI><A HREF="media/">media/</A>
<LI><A HREF="mnt/">mnt/</A>
<LI><A HREF="opt/">opt/</A>
<LI><A HREF="proc/">proc/</A>
<LI><A HREF="root/">root/</A>
<LI><A HREF="run/">run/</A>
<LI><A HREF="sbin/">sbin/</A>
<LI><A HREF="snap/">snap/</A>
<LI><A HREF="srv/">srv/</A>
<LI><A HREF="swapfile">swapfile</A>
<LI><A HREF="sys/">sys/</A>
<LI><A HREF="tmp/">tmp/</A>
<LI><A HREF="usr/">usr/</A>
<LI><A HREF="var/">var/</A>
</UL>
</BODY>
</HTML>

What is this command?

When I run GET / HTTP/1.1, it displays http://www.i5.com/calacom at the end of the page... What is that website?

Edit:

man GET says:

LWP-REQUEST(1p)                                     User Contributed Perl Documentation                                    LWP-REQUEST(1p)

NAME
       lwp-request - Simple command line user agent

Seriously! I did not run the command inside telnet!

whereis GET shows GET: /usr/bin/GET /usr/share/man/man1/GET.1p.gz.

All GET commands were run on the terminal itself! Do not post answers talking about HTTP in telnet. I am not new to HTTP.

FedKad avatar
cn flag
This command is part of `libwww-perl` package: https://packages.ubuntu.com/hirsute/all/libwww-perl/filelist
Score:1
mz flag

It's indeed HTTP's GET method but not specific/related to telnet. GET simply sends a GET request and displays the output in STDOUT. When you do GET /, you're actually sending a GET request to your root folder. To test things, open any browser and simple type / in URL bar. Now inspect the elements and you'll notice the HTML of the page is same as what you got in terminal.

I developed a simple REST API to test things. This is how results look like:

$ GET localhost:8090
{
    "bookID": 2091,
    "title": "Dear Genius",
    "authors": "Ursula Nordstrom-Leonard S. Marcus-Maurice Sendak",
    "average_rating": 4.39,
    "isbn": 64462358,
    "language_code": "eng",
    "ratings_count": 518,
    "price": 2107
}

You can find the manual on lwp-request(1): Simple user agent - Linux man page. Quoting from there:

This program can be used to send requests to WWW servers and your local file system. The request content for POST and PUT methods is read from stdin. The content of the response is printed on stdout. Error messages are printed on stderr. The program returns a status value indicating the number of URLs that failed.

Simpleperson avatar
in flag
Actually the page in chrome and firefox are different.
Simpleperson avatar
in flag
Yes, I do know it is HTTP, but I was not sure if this is a safe command.
Kulfy avatar
mz flag
That's probably how Firefox and Chrome "pretiffy" folders. But the basic HTML structure would look similar. Regarding if it's safe, it depends on where you're sending the request. :)
Score:0
cn flag

This was also new to me. However, doing some investigation I concluded to the following:

$ whereis GET
GET: /usr/bin/GET /usr/share/man/man1/GET.1p.gz

So, this is a "command" under /usr/bin.

$ file /usr/bin/GET ; ll /usr/bin/GET
/usr/bin/GET: symbolic link to lwp-request
lrwxrwxrwx 1 root root 11 Jan 11 21:01 /usr/bin/GET -> lwp-request*

It is a symbolic link for lwp-request under the same directory.

$ ll /usr/bin/ | grep lwp-request
lrwxrwxrwx  1 root root          11 Jan 11 21:01 GET -> lwp-request*
lrwxrwxrwx  1 root root          11 Jan 11 21:01 HEAD -> lwp-request*
lrwxrwxrwx  1 root root          11 Jan 11 21:01 POST -> lwp-request*
-rwxr-xr-x  1 root root       16200 Jan 11 21:01 lwp-request*

There are other "symbolic links" to the same executable.

$ file /usr/bin/lwp-request ; dpkg -S /usr/bin/lwp-request
/usr/bin/lwp-request: Perl script text executable
libwww-perl: /usr/bin/lwp-request

This is a Perl script coming with the libwww-perl package.

$ man GET

More information about the command will reveal that there is a -u option:

-u Print request method and absolute URL as requests are made.

So, if we try the command in the Question using the -u option:

$ GET -u / HTTP/1.1

it displays:

GET file:/
<HTML>
<HEAD>
<TITLE>Directory /</TITLE>
<BASE HREF="file:/">
</HEAD>
<BODY>
<H1>Directory listing of /</H1>
...
</BODY>
</HTML>
GET http://www.HTTP.com/1.1
<html><head><title>www.http.com</title></head><frameset BORDER='0' frameborder='0' framespacing='0' rows='100%,*'>
<frame name='target' src='http://www.i5.com/calacom'>
<noframes>  <body BGCOLOR='#FFFFFF'>
This page requires that your browser supports frames.
<BR>You can access the page without frames with this <a href='http://www.i5.com/calacom'>link</A>.
</body></noframes></frameset></html>

We see that when the GET command is given two arguments, it tries to access two URLs:

  1. file:/
  2. http://www.HTTP.com/1.1

The first one is a listing of the local / directory. The second one is the (probably non-existent) "page" 1.1 of the web site http.com which contains a "frame" to display the page http://www.i5.com/calacom.

Simpleperson avatar
in flag
That clears all my doubts, thanks a lot.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.