ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Setting Pretty Prompts in Linux

    IT Discussion
    linux bash
    4
    7
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      With so many people being new to Linux and discovering the command line and BASH for the first time, something that is likely going to be missed is setting pretty BASH prompts. There is a lot that you could learn about prompts but what I'm going to show is a simple, common and very useful BASH prompt change that will affect all system users.

      The file that we want to change is /etc/profile. This is a universal file that controls all users' environments, so be aware that you will impact other people by doing this (which is exactly what I want in this case.)

      You can use an editor like vi, pico, emacs, joe or nano to make this change (or any GUI tool if you have a GUI installed.) Simple edit the /etc/profile file and add a new line at the end that looks like this:

      export PS1="\u@\h:[\w] $ "
      

      Or if you want to do this with a single command and not have to go into the file to edit it you could do this command (be aware, this simply appends the change so if you do this a lot you will make a large file full of the same command):

      echo 'export PS1="\u@\h:[\w] $ "' >> /etc/profile
      

      After you do this you can log out and log back in to see your changes. Or we can "source" the profile right away to see the changes in our live environment. This is a little known trick and the command is simply the dot "." So we can do this...

      . /etc/profile
      
      1 Reply Last reply Reply Quote 4
      • tonyshowoffT
        tonyshowoff
        last edited by tonyshowoff

        I used to have a really complicated bashrc and bash_profile file, now I jsut don't gaive a damn. sanme reason i didn't spell check this.

        1 Reply Last reply Reply Quote 3
        • thanksajdotcomT
          thanksajdotcom
          last edited by

          What does adding that line do?

          scottalanmillerS 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @thanksajdotcom
            last edited by

            @thanksajdotcom said:

            What does adding that line do?

            Just do it and find out!!! 😉

            1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller
              last edited by

              Makes my prompt look like this:

              scott@cc-lnx-jump:[~/.ssh] $
              
              1 Reply Last reply Reply Quote 0
              • scottalanmillerS
                scottalanmiller
                last edited by

                User at server. Current Working Directory. $

                You can option for less or more info there. This is the most I would recommend. But you could add the time, for example. Or the IP address. Or have nothing at all. I like knowing WHO I am and WHERE I am especially since I might be working as root or something.

                1 Reply Last reply Reply Quote 0
                • DashrenderD
                  Dashrender
                  last edited by

                  I've done this in the past, though without looking it up I couldn't tell you how. 🙂

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post