8

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?

Greenonline
  • 2,081
Jay
  • 195
  • 31
    It is usually a bad idea to execute commands randomly found on the Internet without understanding what they're doing, especially when they start with sudo. Good answers below, but you should have asked before running it. – Calimo Apr 30 '15 at 09:45
  • Note: instead of apt-get you can just use apt. It provides a simpler interface and nicer output. Or just use a visual package manager. – Bakuriu May 01 '15 at 06:16

4 Answers4

29

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.

TheSchwa
  • 3,820
  • 5
    Actually sudo is short for 'substitute user do' - though it's frequently used to do something as root, that's not it's only use, you can also do things as any other user you have a password for. – Rich Bradshaw Apr 30 '15 at 13:19
  • @RichBradshaw The sudo man page mentions "superuser" once, and "substitute," not at all. http://linux.die.net/man/8/sudo – Aaron Hall Apr 30 '15 at 16:41
  • Thats interesting, I'd assumed it came from Su, which definitely is substitute: http://linux.die.net/man/1/su – Rich Bradshaw Apr 30 '15 at 16:47
  • Furthermore, "superuser" doesn't really make sense because "sudo" can run commands as any user, not just root. – Theron Luhn Apr 30 '15 at 16:49
  • Then there's the connection, I concede the point. Though when I was learning this stuff, I mostly wanted a helpful mnemonic for sudo, and superuser do worked quite nicely for that. – Aaron Hall Apr 30 '15 at 17:16
  • 2
    "execute a command as the superuser or another user" I think the main usage is to execute commands as a superuser, and thus it stands for Super user do only. We don't tell sudo to substitute the user for root. But with additional options, we can make it run commands on behalf of another user too. – user3459110 Apr 30 '15 at 21:47
  • Changed it to "substitute user do" since both the project page and wikipedia list it as such. You learn something new every day :) – TheSchwa May 01 '15 at 00:50
  • 1
    Regarding "substitute user do" versus "super user do": http://en.wikipedia.org/wiki/Talk%3ASudo#Is_it_.22substitute_user_do.22_or_.22superuser_do.22.3F – Ergwun May 01 '15 at 04:55
  • @Ergwun that's a cool bit of history (also lol at wikipedia edit wars). I'm going to leave it as "substitute" since new users will never encounter a sudo that is only limited to the root account. – TheSchwa May 01 '15 at 05:41
  • @TheSchwa Thanks for the wonderfully clear answer. So is there a way I could uninstall this curl app? – Jay May 04 '15 at 14:44
  • You can uninstall it with sudo apt-get remove curl. Also, if I answered your question completely, consider accepting my answer using the checkmark. – TheSchwa May 05 '15 at 05:08
9

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.

Maythux
  • 84,289
0

Running a sudo someCommand will not even check if that command exists/is valid/in the PATH. The moment the shell sees sudo, it will prompt for a password.

Maythux
  • 84,289
0

whenever you use a command starting with sudo, it means that you are using the computer as a root privileged. And every command that make change to a computer should start with sudo because Linux needs to make sure the administrator is making those changes. you can also prompt a sudo sucommand before any other commands. so that you do not need to enter your pass-phrase every time you want to change the computer settings.