Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the '$' mean in command line commands?

Tags:

command

line

I often find command line commands starting with dollar signs in instructions to install many things. For example to install Ruby in Ubuntu, the website says to use the following command:

$ sudo apt-get install ruby-full

What does the $ represent?

like image 290
Depressed Duda Avatar asked Jan 30 '16 16:01

Depressed Duda


People also ask

What does '$' mean in Linux?

"$" - is just a sign of the shell prompt, means that shell is ready to accept commands, you can understand it as a separator after which, you can interact with a shell.

What does dollar sign mean in CMD?

The system shell prompt That dollar sign means: we're in the system shell, i.e the program that you're put into as soon as you open the Terminal app. The dollar sign is often the symbol used to signify where you can begin typing in commands (you should see a blinking cursor there).

What does * mean in command?

To be in command means to have control of something and to be in charge. The person who is in command is confident, knows what's going on, doesn't put up with any troublemaking from anyone else.


2 Answers

$ is not part of the command, it is just shown to illustrate terminal input. A full log of the guys entry would read something like

Dominic@stackoverflow$ sudo ap...

See the answer below https://stackoverflow.com/a/48215530/1117934, for a more complete explanation on the difference between $ and #.

like image 163
DominicEU Avatar answered Oct 12 '22 21:10

DominicEU


The $ is not part of the command. It's there to tell you that this command needs to be executed as a regular user.

When you prompt as a regular user (in bash shell at least), the line starts with the user name you're currently prompt as, followed by @, followed by the machine hostname, followed by :, followed by the current location, followed by $.

It looks like this :

bob@work-station:~$ 

But, if you prompt as root, the last $ will be replaced by a # :

root@work-station:~#

And that's the point of those tutorials :

  • If the command starts with $, you know that the command should be executed as regular user.
  • If it starts with #, it should be executed as root.

Hope it helps.

like image 27
JazZ Avatar answered Oct 12 '22 21:10

JazZ