Bash prompt takes only the first word of a hostname before the dotIs it possible to know when you're at the first bash prompt of a terminal?I changed my hostname, why is my bash PS1 prompt unchangedHow do I customize the bash prompt on centos?How to set the command(s) that get run before every single prompt?bash prompt with abbreviated current director including dot files?Obtain the “pretty” hostname in bashChanging hostname doesn't change the terminal nameHow to change bash prompt string in current bash session?How to change the format of the bash prompt?/etc/bashrc overrides my settings in home .bashrc

In the figure, a quarter circle, a semicircle and a circle are mutually tangent inside a square of side length 2. Find the radius of the circle.

What did Varys actually mean?

Can you just subtract the challenge rating of friendly NPCs?

How can I test a shell script in a "safe environment" to avoid harm to my computer?

GitLab account hacked and repo wiped

Displaying an Estimated Execution Plan generates CXPACKET, PAGELATCH_SH, and LATCH_EX [ACCESS_METHODS_DATASET_PARENT] waits

LiOH hydrolysis of methyl 2,2-dimethoxyacetate not giving product?

shebang or not shebang

All of my Firefox add-ons have been disabled suddenly, how can I re-enable them?

How do I give a darkroom course without negs from the attendees?

Make me a minimum magic sum

Concatenate all values of the same XML element using XPath/XQuery

Assuming a normal distribution: what is the sd for a given mean?

My large rocket is still flipping over

Explaining intravenous drug abuse to a small child

What detail can Hubble see on Mars?

Game artist computer workstation set-up – is this overkill?

Is it safe to keep the GPU on 100% utilization for a very long time?

How does "politician" work as a job/career?

What's the role of the Receiver/Transmitter in Avengers Endgame?

cd ` command meaning and how to exit it?

How to increase row height of a table and vertically "align middle"?

Good introductory book to type theory?

Why is the blank symbol not considered part of the input alphabet of a Turing machine?



Bash prompt takes only the first word of a hostname before the dot


Is it possible to know when you're at the first bash prompt of a terminal?I changed my hostname, why is my bash PS1 prompt unchangedHow do I customize the bash prompt on centos?How to set the command(s) that get run before every single prompt?bash prompt with abbreviated current director including dot files?Obtain the “pretty” hostname in bashChanging hostname doesn't change the terminal nameHow to change bash prompt string in current bash session?How to change the format of the bash prompt?/etc/bashrc overrides my settings in home .bashrc






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I configured my machine as the following hostname ( in reshat 7.2 )



digi.master01.usa.com


but my prompt is like this



[root@digi ]#


while we want



[root@digi.master01 ]#


any idea how to change it in linux configuration?










share|improve this question
























  • What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

    – William Pursell
    6 hours ago

















3















I configured my machine as the following hostname ( in reshat 7.2 )



digi.master01.usa.com


but my prompt is like this



[root@digi ]#


while we want



[root@digi.master01 ]#


any idea how to change it in linux configuration?










share|improve this question
























  • What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

    – William Pursell
    6 hours ago













3












3








3








I configured my machine as the following hostname ( in reshat 7.2 )



digi.master01.usa.com


but my prompt is like this



[root@digi ]#


while we want



[root@digi.master01 ]#


any idea how to change it in linux configuration?










share|improve this question
















I configured my machine as the following hostname ( in reshat 7.2 )



digi.master01.usa.com


but my prompt is like this



[root@digi ]#


while we want



[root@digi.master01 ]#


any idea how to change it in linux configuration?







linux bash prompt hostname






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









jimmij

32.9k876111




32.9k876111










asked 6 hours ago









yaelyael

2,84263281




2,84263281












  • What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

    – William Pursell
    6 hours ago

















  • What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

    – William Pursell
    6 hours ago
















What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

– William Pursell
6 hours ago





What do you currently have in PS1? You could use $(hostname | cut -d . -f 1-2)

– William Pursell
6 hours ago










1 Answer
1






active

oldest

votes


















8














In bash you can use two special characters regarding hostname:




  • h to get host name up to the first dot


  • H to get full host name

If you want anything else you need to make your own version for example with HOSTNAME variable:



[root@digi ]# HOSTNAME=digi.master01.usa.com # this should be set automatically by bash

[root@digi ]# PS1="[u@$HOSTNAME%.*.* ]#"
[root@digi.master01 ]#





share|improve this answer























  • (+1) , on which file I need to edit the - PS1?

    – yael
    5 hours ago












  • @yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

    – datUser
    5 hours ago












  • @yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

    – jimmij
    3 hours ago












  • last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

    – yael
    2 hours ago











  • @yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

    – jimmij
    2 hours ago











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f517429%2fbash-prompt-takes-only-the-first-word-of-a-hostname-before-the-dot%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














In bash you can use two special characters regarding hostname:




  • h to get host name up to the first dot


  • H to get full host name

If you want anything else you need to make your own version for example with HOSTNAME variable:



[root@digi ]# HOSTNAME=digi.master01.usa.com # this should be set automatically by bash

[root@digi ]# PS1="[u@$HOSTNAME%.*.* ]#"
[root@digi.master01 ]#





share|improve this answer























  • (+1) , on which file I need to edit the - PS1?

    – yael
    5 hours ago












  • @yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

    – datUser
    5 hours ago












  • @yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

    – jimmij
    3 hours ago












  • last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

    – yael
    2 hours ago











  • @yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

    – jimmij
    2 hours ago















8














In bash you can use two special characters regarding hostname:




  • h to get host name up to the first dot


  • H to get full host name

If you want anything else you need to make your own version for example with HOSTNAME variable:



[root@digi ]# HOSTNAME=digi.master01.usa.com # this should be set automatically by bash

[root@digi ]# PS1="[u@$HOSTNAME%.*.* ]#"
[root@digi.master01 ]#





share|improve this answer























  • (+1) , on which file I need to edit the - PS1?

    – yael
    5 hours ago












  • @yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

    – datUser
    5 hours ago












  • @yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

    – jimmij
    3 hours ago












  • last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

    – yael
    2 hours ago











  • @yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

    – jimmij
    2 hours ago













8












8








8







In bash you can use two special characters regarding hostname:




  • h to get host name up to the first dot


  • H to get full host name

If you want anything else you need to make your own version for example with HOSTNAME variable:



[root@digi ]# HOSTNAME=digi.master01.usa.com # this should be set automatically by bash

[root@digi ]# PS1="[u@$HOSTNAME%.*.* ]#"
[root@digi.master01 ]#





share|improve this answer













In bash you can use two special characters regarding hostname:




  • h to get host name up to the first dot


  • H to get full host name

If you want anything else you need to make your own version for example with HOSTNAME variable:



[root@digi ]# HOSTNAME=digi.master01.usa.com # this should be set automatically by bash

[root@digi ]# PS1="[u@$HOSTNAME%.*.* ]#"
[root@digi.master01 ]#






share|improve this answer












share|improve this answer



share|improve this answer










answered 6 hours ago









jimmijjimmij

32.9k876111




32.9k876111












  • (+1) , on which file I need to edit the - PS1?

    – yael
    5 hours ago












  • @yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

    – datUser
    5 hours ago












  • @yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

    – jimmij
    3 hours ago












  • last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

    – yael
    2 hours ago











  • @yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

    – jimmij
    2 hours ago

















  • (+1) , on which file I need to edit the - PS1?

    – yael
    5 hours ago












  • @yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

    – datUser
    5 hours ago












  • @yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

    – jimmij
    3 hours ago












  • last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

    – yael
    2 hours ago











  • @yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

    – jimmij
    2 hours ago
















(+1) , on which file I need to edit the - PS1?

– yael
5 hours ago






(+1) , on which file I need to edit the - PS1?

– yael
5 hours ago














@yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

– datUser
5 hours ago






@yael you would need to add this to your ~/.bashrc file. E.g: add the line export PS1="[u@H ]#". Then logout or source the file, . ~/.bashrc to make this active.

– datUser
5 hours ago














@yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

– jimmij
3 hours ago






@yael Like @datUser said, put this into ~/.bashrc, eventually ~/.bash_profile or even /etc/profile (system-wide), but for interactive stuff like prompt ~/.bashrc is the right place.

– jimmij
3 hours ago














last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

– yael
2 hours ago





last question , I try to create now digi-master01 insted of digi.master but without success can you please help me with this ?

– yael
2 hours ago













@yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

– jimmij
2 hours ago





@yael newhostname=$HOSTNAME/./- should do the job or $HOSTNAME//./- to change all dots.

– jimmij
2 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f517429%2fbash-prompt-takes-only-the-first-word-of-a-hostname-before-the-dot%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Log på Navigationsmenu

Creating second map without labels using QGIS?How to lock map labels for inset map in Print Composer?How to Force the Showing of Labels of a Vector File in QGISQGIS Valmiera, Labels only show for part of polygonsRemoving duplicate point labels in QGISLabeling every feature using QGIS?Show labels for point features outside map canvasAbbreviate Road Labels in QGIS only when requiredExporting map from composer in QGIS - text labels have moved in output?How to make sure labels in qgis turn up in layout map?Writing label expression with ArcMap and If then Statement?

Nuuk Indholdsfortegnelse Etyomologi | Historie | Geografi | Transport og infrastruktur | Politik og administration | Uddannelsesinstitutioner | Kultur | Venskabsbyer | Noter | Eksterne henvisninger | Se også | Navigationsmenuwww.sermersooq.gl64°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.75064°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.750DMI - KlimanormalerSalmonsen, s. 850Grønlands Naturinstitut undersøger rensdyr i Akia og Maniitsoq foråret 2008Grønlands NaturinstitutNy vej til Qinngorput indviet i dagAntallet af biler i Nuuk må begrænsesNy taxacentral mødt med demonstrationKøreplan. Rute 1, 2 og 3SnescootersporNuukNord er for storSkoler i Kommuneqarfik SermersooqAtuarfik Samuel KleinschmidtKangillinguit AtuarfiatNuussuup AtuarfiaNuuk Internationale FriskoleIlinniarfissuaq, Grønlands SeminariumLedelseÅrsberetning for 2008Kunst og arkitekturÅrsberetning for 2008Julie om naturenNuuk KunstmuseumSilamiutGrønlands Nationalmuseum og ArkivStatistisk ÅrbogGrønlands LandsbibliotekStore koncerter på stribeVandhund nummer 1.000.000Kommuneqarfik Sermersooq – MalikForsidenVenskabsbyerLyngby-Taarbæk i GrønlandArctic Business NetworkWinter Cities 2008 i NuukDagligt opdaterede satellitbilleder fra NuukområdetKommuneqarfik Sermersooqs hjemmesideTurist i NuukGrønlands Statistiks databankGrønlands Hjemmestyres valgresultaterrrWorldCat124325457671310-5