• Can I fix this?

    Author
    Topic
    #2644773

    Since I installed Linux Mint 20 I’ve had this minor problem with the command line in Terminal.  Namely it reads “merlin@merlin-system-product-name:-$” (without the quotations).  I don’t know why this is like this but it didn’t happen with any of the previous Linux installs I’ve done.

    Anyway, is there a way fix this so it just shows the hostname I want – Merlin?  I want to at least get that system-product-name out of there.  It’s a minor thing and it doesn’t cause any problem, but I’m using Terminal more and I don’t like it.  Help on this will be greatly appreciated as usual.

    Being 20 something in the 70's was more fun than being 70 something in the 20's
    Viewing 8 reply threads
    Author
    Replies
    • #2644780

      This doesn’t answer your question, but ALL of my Mint installations from 19.3 to 20.3 to 21.1 – 3 to 4 installations of each – have or have had a command line in Terminal like the one you are showing in quotes. Perhaps it’s your other installations that are anomalous?

      • #2644783

        I still have LMC 19.1 on an old Sony laptop and it doesn’t have that long command line.  There are a few ways to supposedly correct this that I found in my searches, but I mainly only really trust what info. I get here.  I get nervous trying something when I don’t know anything about it.

        Thanks anyway for that info.

        Being 20 something in the 70's was more fun than being 70 something in the 20's
    • #2644779

      Edit your ~/.bashrc file.

      • #2645106

        Where is the /.bashrc file?  I read about /etc/Hostname which is a text file that contains the long Command line I wrote above.  These files are owned by Root and Text Editor won’t work on files in Root (I don’t think).

        Being 20 something in the 70's was more fun than being 70 something in the 20's
        • #2645169

          In Mint, you should be able to use “open as root” or whatever the similar command is from the file manager. You can use that to open a root file manager, and from there the text editor will be able to modify the file. Use caution when using root privileges, of course!

          Dell XPS 13/9310, i5-1135G7/16GB, Kubuntu 22.04
          XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 22.04
          Acer Swift Go 14, i5-1335U/16GB, Kubuntu 22.04 (and Win 11)

          1 user thanked author for this post.
        • #2645392

          The tilde symbol, ~, is an abbreviation for the current user’s home directory. If the current user is ‘charlie,’ ~/.bashrc would expand to /home/charlie/.bashrc

          Without the tilde, /.bashrc would mean that the file is located in the root directory (which, of course, it is not). If you want to refer just to the file and not reference the path, just use .bashrc without the slash.

          A file whose name begins with a dot (period) is hidden. You can see it if you enable the file manager’s option for “show hidden files.”

           

           

          Dell XPS 13/9310, i5-1135G7/16GB, Kubuntu 22.04
          XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 22.04
          Acer Swift Go 14, i5-1335U/16GB, Kubuntu 22.04 (and Win 11)

          1 user thanked author for this post.
    • #2645266

      Where is the /.bashrc file?

      It’s a hidden file in your home directory.

       

       

      1 user thanked author for this post.
    • #2645464

      Okay now, the bottom line is, if I edit the file .bashrc to take the System-Product-Name out of the command line will it cause any problems?  That’s the main thing I want to avoid.  Also, should I edit the Hostname file in /etc. which contains the long command line too? It appears to be just a text file.

      I love to tweak things to suit myself, but only when I’m sure of what I’m doing.

      Being 20 something in the 70's was more fun than being 70 something in the 20's
      • #2645465

        I’ve never tried what you want to do so I can’t answer your questions. But it is a computer with an operating system so I would take the same precautions as I would if I was attempting a similar operation on a Windows or Mac computer. In other words I’d assume something will go wrong and have a recovery plan. That’s just the way it is (unfortunately).

        1 user thanked author for this post.
        • #2645471

          Very good advice DrBonzo.  Thanks.

          Being 20 something in the 70's was more fun than being 70 something in the 20's
          1 user thanked author for this post.
    • #2645664

      Hi Charlie, I tested changing the terminal prompt in the .bashrc file for Linux mint 21 and had mixed results. First I made a full backup since sometimes doing small changes.. well you know the rest. My terminal prompt was also a relatively long prompt having username@hostname. The hostname was a combination of my username-VirtualBox in my case. Before editing I made a copy of the .bashrc file in my user directory and it was called .bashrc(copy). Next I edited (using nano) the .bashrc file to delete the reference to the @hostname which is represented by an @\h in the first PS1 = line in the .bashrc file.
      So in the 1st PS1 line I deleted the following 3 characters  @\h

      (followed by exiting the terminal and restarting Linux mint)

      if [ “$color_prompt” = yes ]; then
      PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘

      Tried a few other variations and wound up having to back out my changes twice because the up arrow for history in the terminal broke.

      Now my terminal prompt is just my username:workingdirectory$ (username presented by u and working directory represented by w in the PS1 line)

      Actually after the trouble I had yesterday, surprised I gave it another try.  3rd time was the charm.  Do I recommend , It depends on ones comfort level in making the change and ones ability to back it out if needed.

      1 user thanked author for this post.
      • #2645906

        Thanks very much Sueska, from what you describe it sounds too risky for me at this time.  I was rather hoping to just be able to edit the file “Hostname” in the /etc directory.  It’s a text file that just has the words “merlin-system-product-name” in it.  If I have to do more than this right now I’ll just put it off until I get more experienced.

        Being 20 something in the 70's was more fun than being 70 something in the 20's
    • #2645923

      What is listed after the @ in the terminal is the computer name which is stored in the file “hostname” located in the /etc directory.

      In Linux Mint, it can be changed in one of two ways:

      1. Via the Files app, right click the etc directory and choose “Open as root”. Then open the hostname file via the text editor and change the computer name as desired, save the file and close the text editor.
      2. Via the terminal using the hostnamectl command as follows: hostnamectl hostname MyPC (where “MyPC” is what you want the name to be). This updates the hostname file in the etc directory without needing root access. Close terminal then re-launch it to see the updated name after the @ symbol.

      There really is no danger using either method, it should not cause any problems. If you want can always just copy the hostname file to another location in your home directory before you make the change. Then you have the option to put the original back if you want (will require opening etc as root again to paste it).

      Note: in the terminal entering just: hostnamectl will return the computer name and other system info. For more info on the hostnamectl command see: https://www.linux.org/docs/man1/hostnamectl.html

      1 user thanked author for this post.
    • #2645991

      I tried #2 suggestion using Terminal and no luck. This is what I got.

      Screenshot-from-Terminal

      I tried it using sudo and it didn’t work either.

      Edit:  For some reason I don’t have “Open as root” on my right click context menu; even though I’ve got the Open as root box checked in Context Menu preferences.  Tried unclicking, reclicking, and rebooting but it won’t show up.

      Being 20 something in the 70's was more fun than being 70 something in the 20's
      • This reply was modified 1 month ago by Charlie.
      • This reply was modified 1 month ago by Charlie.
      • #2646013

        It may be a difference in Linux Mint versions, I’m using 21.2. Try using set-hostname instead.

        hostnamectl set-hostname Merlin

        Also to see all options for the version installed on your system: hostnamectl –help (that is two dashes followed by the word help. The forum software appears to change it to one long dash).

        And yes, may need to use sudo at the beginning of the command.

        I didn’t realize until now that my user account already has write access to that hostname file under /etc and that’s why it worked for me without sudo.

        3 users thanked author for this post.
        • #2646019

          That worked!  Thank you!  I forgot to use sudo and it still worked.

          Screenshot-of-terminal2

          Being 20 something in the 70's was more fun than being 70 something in the 20's
          3 users thanked author for this post.
    • #2646307

      Hi Charlie, I am glad Mothy helped you find you a solution. The long terminal name was bothering me as well. I am happy now too and I learned a lot about ~.bashrc. Too bad the knowledge I gained was not before making the first two mistakes. Chris Hoffman from the Howtogeek has a comprehensive guide on modifying your bash prompt and explains the purpose of the code in the ~.bashrc script. I believe my mistakes included removing one too many backward slashes (also called escape characters).
      https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/
      I decided to make similar changes on my 21.2 version of mint. Not sure if best practice, but I was surprised to find that I was able to edit the file with just the text editor. I know you are all set now Charlie, but just wanted to share my additional results and to thank you for your question and those who answered you because it helped me learn more.

      2 users thanked author for this post.
      • #2646332

        I appreciate your taking the time to look for a solution Sueska.  I’m to a point where I’m trying to use Terminal more and learn more commands.  I have two books on Linux and one deals primarily with Terminal. This book has loads of commands but didn’t have that “hostnamectl” command which really did the trick!  I’m glad you used it and are happy with it too.

        Being 20 something in the 70's was more fun than being 70 something in the 20's
        2 users thanked author for this post.
    • #2651978

      One happy LMC user.

      Being 20 something in the 70's was more fun than being 70 something in the 20's
      • #2652562

        One happy LMC user.

        When you write “LMC” it seems maybe you’re generally referring to the Cinnamon Edition(s) of Linux Mint. Is that right?

        Thanks.

        • #2652619

          Yes, I really like Cinnamon and even my wife is using it daily with my help now and then.

          Being 20 something in the 70's was more fun than being 70 something in the 20's
    Viewing 8 reply threads
    Reply To: Can I fix this?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: