18

What is the difference between $ and # signs in Linux environment? As I started working on Linux and I found that both are different. I mean they do have different set of privileges...?

[root@localhost ~]# and [tom@localhost ~]$.

37

In short, if the screen shows a dollar sign ($) or hash (#) on the left of the blinking cursor, you are in a command-line environment.

$, #, % symbols indicate the user account type you are logged in to.

  • Dollar sign ($) means you are a normal user.
  • hash (#) means you are the system administrator (root).
  • In the C shell, the prompt ends with a percentage sign (%).

There are differences on prompts in different Unix or GNU/Linux distributions because of their default settings. For example, the prompt of Debian/Ubuntu is guest@linux:~$, the one of Fedora/CentOS/RedHat is [guest@linux ~]$ and the one of SuSE Linux/OpenSUSE is guest@linux:~>. In general, the prompt usually show the login user name, machine hostname, and current working directory and ended with a dollar ($), percentage (%), or hash (#) sign.

guest@linux:~$ 
  • guest - username: the user account you are logged in to.
  • linux - machine hostname: the machine you are operating.
  • ~ - current working directory: the directory you are in. Tilde (~) means home directory, i.e. the default directory when first logging in.

Reference: wiki.debian.org.hk/w/Basic_Command_Line

| improve this answer | |
  • @reverseiblean thanks for quik reply.Now i can see $ and # in centos promt. – Nagendra Dec 5 '15 at 10:39
  • for root user # and for tom or other users it is $ – Nagendra Dec 5 '15 at 10:40
  • @GayanWeerakutti What does dollar sign do in this command chattr +i "$(realpath /etc/resolv.conf)" I found it on another question and I need clarification. Thanks. – Shayan Aug 23 '19 at 18:07
  • 1
    @GayanWeerakutti It makes sense because /etc/resolv.conf was a symlink in pre-systemd days to /run/resolvconf/resolv.conf file. Not entirely sure how it's used now, though. And chattr apparently doesn't work on symlinks – Sergiy Kolodyazhnyy Aug 24 '19 at 8:05
  • 1
    In fact, there's actually a whole question about it – Sergiy Kolodyazhnyy Aug 24 '19 at 8:07
-1

If we talk about CLI, there is no difference between $ and # sign. It is only represent the user account type.

$ sign prompt indicate you are logged in with normal account.

# sign prompt indicate you are logged in with root account.

satish@ubuntu:~$
root@ubuntu:~#
| improve this answer | |
  • 3
    This is a duplicate of the accepted answer. – karel Aug 24 '19 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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