Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

What does ~$ stand for? For example:

user@ubuntu:~$

So far I know that the $ sign is a symbol for a regular user. If I'm not mistaken root have # at the end. I also think that $ has something to do with the home folder. In my search I found $HOME command showing home directory:

bash: /home/user: Is a directory

I also found a lot of commands in the forums that begin with $:

$ sudo apt-get update 

So for what does $ actually stand for?

EDIT (28.01.2014) :

Today I came across this video that totally answers my question from 8 months ago and decided to share it here :)

BASH Basics - https://www.youtube.com/watch?v=x73WTEltyHU

share|improve this question

4 Answers 4

up vote 32 down vote accepted

The ~ and $ are elements of the command line prompt. This indicates that your computer (or more exactly, I guess, the shell you are running) is waiting for user input. It is prompting you to input a command.

The $ is merely a separator or divider. It separates the command prompt from the command which follows it. When people write such things as $ sudo apt-get update (your example), they are simply telling you that the command, in this case sudo apt-get update, needs to be entered at a command prompt. Strictly speaking, perhaps, the $ is redundant in this context.

Other separators may be used in other situations. For example, # is used for a root shell.

The ~ (called 'tilde') is shorthand for your home directory. When it appears in a command prompt, e.g., user@hostame:~$, it indicates that the current working directory is your home directory. Thus if you run the list command, ls, without specifying any particular directory, it will list the contents of your home directory.

(By the way, $HOME, is not a command, as you suggest, but rather an environment variable. It determines the location of your home directory. You can see its value by running $ echo $HOME.)

share|improve this answer
    
Thank you :) Your answer covers everything. –  FEarBG Jun 4 '13 at 18:51
9  
@FEarBG I think this answer fails in one small aspect: the prompt is completely customizable and is just a decoration; you could decide to have an empty prompt, or use whatever symbols you like in it(e.g. on my computer I have replaced $ with ` ̃∴` as prompt symbol). You can change your prompt setting the PS1 environment variable to your liking. –  Bakuriu Jun 4 '13 at 20:03
    
@Bakuriu Assuming bash, of course. Other shells MAY be different. –  Michael Kjörling Jun 5 '13 at 8:44
    
"Strictly speaking, perhaps, the $ is redundant in this context." - Yes, that is why we generally prefer to avoid the $ if there's no need for it (which there is for log copies or example outputs, for instance). –  user98085 Jun 5 '13 at 16:46

Traditionally, a shell prompt either ends with $, % or #. If it ends with $, this indicates a shell that's compatible with the Bourne shell (such as a POSIX shell, or a Korn shell, or Bash). If it ends with %, this indicates a C shell (csh or tcsh). If it ends with #, this indicates that the shell is running as the system's superuser account (root).

Source: here

share|improve this answer
    
on some (old, usually) systems, you have "#" even as a regular user (maybe to keep you on your toe ^^)... ie, some older shells don't change the symbol if you're root -vs- regular user. –  Olivier Dulac Jun 5 '13 at 14:48
    
Other possible source –  lgarzo Jun 5 '13 at 16:55
  • ~ stands for your home directory.
  • $ it's a separator for your system, it comes from the command \$ from the man page.

So if you find a command beginning with $ it just says that nothing should be added before that.

user@ubuntu:~$

user is the username your are logged in with.
@ is just to say here is a link.
ubuntu is the name of the system you are logged in as.
:~ says that you are in the user home directory now.
$ comes from the \$ escape sequence in the $PS1. man page.

But this can all be changed by reading in the man page. Thank you @demure for the help.

share|improve this answer
2  
To be specific, it is the \$ portion of the $PS1, which is designed to show $ if not root (otherwise it will be #) man page exert –  demure Jun 4 '13 at 16:17
    
@denure updated my answer, if you feel you can improve it please do so. –  Alvar Jun 4 '13 at 20:26

The $ sign it the end of the prompt in terminal when you add a command like the one you showed, do not type in the $ else it will not work.

So $ sudo apt-get update

would be typed in as:

sudo apt-get update 

Hope that helps.

Edit

The ~ stands for your Home folder so name@pc_name:~/Desktop$ would show that you are in the Home>Desktop folder.

share|improve this answer
1  
I understand that, but why they put $ in the first place if not used ? –  FEarBG Jun 4 '13 at 16:13
3  
Perhaps to show that you should enter the command at the prompt. –  SimplySimon Jun 4 '13 at 16:19
4  
And also to distinguish between a command run by a normal user (at the $ prompt) vs. root (the # prompt). –  coneslayer Jun 4 '13 at 17:33
    
@FEarBG: It's an arbitrary convention, unrelated (as far as I know) to the use of $ to denote a variable name. There are only so many printable characters available on a keyboard. DOS and Windows use > in prompts, Unix usually uses $ or %. It tells you "this is a prompt" without wasting space on your screen (or, in the old days, ink and paper). –  Keith Thompson Jun 4 '13 at 20:43
    
And of course, in DOS and Windows environment variables use %. As you say, it's largely arbitrary; there pretty much needs to be something, but it doesn't need to be the same everywhere (although it would be kind of nice if it was). –  Michael Kjörling Jun 5 '13 at 8:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.