What does sudo apt-get install curl command do? Why does it require the password? [duplicate]

I tried installing PlayOnLinux by using the steps according to a YouTube video, Install MS Office 2010 on Ubuntu 12.04-14.04, and used the command

sudo apt-get install curl

Then it requested my password which I entered.

Can anyone please explain what this command line does?


Solution 1:

First let's look at each part of the command individually:

  1. sudo is short for "substitute user do" and executes commands as another user. Most commonly, it is used to temporarily become "root" (Linux equivalent of admin). Software installation would not work without sudo in the front. This is the part of the command that needs your password. For security reasons, you should always try to use sudo rather than straight-up logging in as root.

  2. apt-get is one program in the apt suite, which deals with software installation and management. Linux distributions typically feature a package manager that is used to install, configure, and remove software; Ubuntu uses apt as described here.

  3. install tells apt-get to install a package on your computer. The command will search through your repositories (typically just the official Ubuntu repositories via the internet) for a package, download it, copy it to your computer, and configure it. For more specifics see this question.

  4. curl tells apt-get what package to install. Specifically, curl is a data transfer program, and is commonly used to download websites or files via the command line. More details available on its manpage.

So, putting everything together, you are going to download the package curl from the internet and install it by giving the apt-get program root privileges.

As Calimo noted in his comment, you should be careful executing random terminal commands you find on the internet. And you should be VERY careful executing any command that starts with sudo, since it has the potential to damage the really important parts of your system.

Solution 2:

man curl

curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user inter‐ action.

This is curl.

The command sudo apt-get install curl means you are going to download and install curl into your system.

So when you use sudo and every time you use sudo you will be asked for your password to ensure that you have permissions to do things for your system

Read this and this for more information about sudo.