Learn about Centmin Mod LEMP Stack today
Become a Member

Server Name

Discussion in 'Feature Requests & Suggestions' started by Jimmy, Feb 1, 2017.

  1. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Would it be possible to have the server name listed under the Centmin Mod Menu heading?

    --------------------------------------------------------
    Centmin Mod Menu 123.09beta01 centminmod.com
    Server: sever1.domainname.com
    --------------------------------------------------------


    I might have 2 or 3 terminal windows open at the same time. If I am looking at the menu, it would be nice to make sure I'm on the right server. I know it's other places, but a few times, when I was tired, I almost did something to the wrong server. Having it in the menu title would be another safeguard against doing something on the wrong server... for me at least.

    Just a suggestion. :)
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    not in the menu maybe someone outside of it ?

    fyi, if you have unique hostnames, the command prompt will be able to differentiate the servers too ;) i.e. instead of server1.hostname.com, use webhostname-location-1.hostname.com

    so instead of

    [root@server1]#

    would be

    [root@webhostname-location-1]#
     
    Last edited: Feb 1, 2017
  3. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Where ever you feel it is best. Just something so that when I have 2 menus side by side, I know which one is which. :)

    Thought having it in the menu would good. Not sure where else it could go.
     
  4. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Yea, I often look at that because my naming convention is server1, server2, etc. It's also at the top of the terminal window.

    Mainly when I get tired and have two menus open at the same time, I've a few times, almost did the wrong thing because I was focused on the CMM menu vs. double checking which server / window.
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Guess it's just habit.. I routinely have up to 10-30 server SSH windows open at a time, never had any probs :)
     
  6. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Just wanted to make the suggestion. It's up to you if you want to add it or not. :)
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Hmmm worse case GitLab employee ran rm -rf on production LOL

    Gitlab employee accidentally deletes live data
     
  8. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    --------------------------------------------------------
    Centmin Mod Menu 123.09beta01 centminmod.com
    Server: sever1.domainname.com
    --------------------------------------------------------

    ;)
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    changing command prompt BASH Shell: Change The Color of My Shell Prompt Under Linux or UNIX

    i.e. full hostname and cyan blue
    Code (Text):
    PS1="\e[0;36m[\u@\H \w]\\$ \e[m "


    full hostname and lighter cyan blue
    Code (Text):
    PS1="\e[1;36m[\u@\H \w]\\$ \e[m "


    hour:min, full hostname + lighter cyan blue
    Code (Text):
    PS1="\e[1;36m[\$(date +%H:%M)][\u@\H \w]\\$ \e[m "

    or
    Code (Text):
    PS1="\e[1;36m[\A][\u@\H \w]\\$ \e[m " 


    hour:min, full hostname + lighter cyan blue + black background (How to Customize your Bash Prompt on a Linux VPS | DigitalOcean)
    Code (Text):
    PS1="\e[40;1;36m[\A][\u@\H \w]\\$ \e[m " 


    example

    upload_2017-2-2_3-29-36.png
     
    Last edited: Feb 2, 2017
  10. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Interesting! I'll have to check that out. @eva2000 you're loaded with interesting tidbits! :)
     
  11. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yes thinking of making the last one the default in Centmin Mod 123.09beta01

    Code (Text):
    PS1="\e[40;1;36m[\A][\u@\H \w]\\$ \e[m " 


    black terminals

    upload_2017-2-2_3-30-11.png

    white terminals

    upload_2017-2-2_3-37-22.png

    or with white text on black background
    Code (Text):
    PS1="\e[40;1;37m[\A][\u@\H \w]\\$ \e[m "
    


    upload_2017-2-2_3-45-22.png

    clear enough for folks working with multiple SSH windows simultaneously :)

    or leave colours out of it and use

    Code (Text):
    PS1="[\u@\H \w]\\$ "
    
     
    Last edited: Feb 2, 2017
  12. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  13. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Looks good! Should make things easier. Though, I'm thinking about using the colors too, because there is no mistaking colors.... unless you're color blind, which I'm not. ;)
     
  14. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah i left out colours as folks maybe have custom SSH client/terminal colour schemes which may get kind of funky :)
     
  15. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Ended up going with this:

    Code:
    PS1="\e[32m[\u@\h \W]\\$ \e[m"
    If someone wants to add the time:

    Code:
    PS1="\e[32m[\A][\u@\h \W]\\$ \e[m"
    I'll change the color (32m) to what I want for each server based on this chart:

    • 30: Black
    • 31: Red
    • 32: Green
    • 33: Yellow
    • 34: Blue
    • 35: Purple
    • 36: Cyan
    • 37: White
     
    Last edited: Feb 2, 2017
  16. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    but that uses short \h hostname ?
     
  17. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    Don't need the full hostname since I'm using the colors. All my servers are the same domain.
     
  18. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I see
     
  19. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    10:05 PM
    There is no mistaking the colors! I'm loving this!

    Thanks!
     
  20. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:05 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    also to prevent mishaps, can setup custom alias command for pwd command = list present working directory to also display hostname

    i.e. alias pwdh command
    Code (Text):
    alias pwdh='echo -n "$(hostname) "; pwd'
    

    so when you type pwdh
    Code (Text):
    pwdh
    host1.domain.com /root
    

    Code (Text):
    cd /home/nginx
    pwdh
    host1.domain.com /home/nginx
    


    edit: hmmm pwd won't work in .bashrc heh which needs a bit more tweaking to inset into /root/.bashrc with echo
    Code (Text):
    echo "alias pwdh='echo -n \"\$HOSTNAME\"; echo \" \$PWD\"'" >> /root/.bashrc
    

    after echo append to /root/.bashrc, the entry would appear as
    Code (Text):
    alias pwdh='echo -n "$HOSTNAME"; echo " $PWD"'
    
     
    Last edited: Feb 2, 2017