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

How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?

Succinct and gender-neutral Russian word for "writer"

Why does increasing the sampling rate make implementing an anti-aliasing filter easier?

Why do Thanos' punches not kill Captain America or at least cause some mortal injuries?

Ex-manager wants to stay in touch, I don't want to

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

Remove color cast in darktable?

How to efficiently lower your karma

Company stopped paying my salary. What are my options?

If a character drops a magic item that turns on/off, does that item turn off when they drop it?

Early arrival in Australia, early check in not available

Would encrypting a database protect against a compromised admin account?

Why is the Sun made of light elements only?

Improving Sati-Sampajañña (situative wisdom)

Why do the Avengers care about returning these items in Endgame?

Question about tidal forces and the Roche limit

What food production methods would allow a metropolis like New York to become self sufficient

Extending Kan fibrations, without using minimal fibrations

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Detect the first rising edge of 3 input signals

When do you stop "pushing" a book?

Removing all characters except digits from clipboard

Further factorisation of a difference of cubes?

Why are parallelograms defined as quadrilaterals? What term would encompass polygons with greater than two parallel pairs?



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;








4















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
    May 6 at 17:12











  • The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

    – iBug
    May 7 at 5:00

















4















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
    May 6 at 17:12











  • The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

    – iBug
    May 7 at 5:00













4












4








4








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 May 6 at 20:19









jimmij

32.9k877112




32.9k877112










asked May 6 at 17:01









yaelyael

2,84763381




2,84763381












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

    – William Pursell
    May 6 at 17:12











  • The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

    – iBug
    May 7 at 5:00

















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

    – William Pursell
    May 6 at 17:12











  • The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

    – iBug
    May 7 at 5:00
















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

– William Pursell
May 6 at 17:12





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

– William Pursell
May 6 at 17:12













The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

– iBug
May 7 at 5:00





The default PS1 is ugly in Red Hat-like distros (Fedora, CentOS, etc). Debian/Ubuntu does it much better.

– iBug
May 7 at 5:00










1 Answer
1






active

oldest

votes


















10














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
    May 6 at 18:04












  • @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
    May 6 at 18:11












  • @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
    May 6 at 20:17












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

    – yael
    May 6 at 21:14











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

    – jimmij
    May 6 at 21:23











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









10














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
    May 6 at 18:04












  • @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
    May 6 at 18:11












  • @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
    May 6 at 20:17












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

    – yael
    May 6 at 21:14











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

    – jimmij
    May 6 at 21:23















10














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
    May 6 at 18:04












  • @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
    May 6 at 18:11












  • @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
    May 6 at 20:17












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

    – yael
    May 6 at 21:14











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

    – jimmij
    May 6 at 21:23













10












10








10







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 May 6 at 17:20









jimmijjimmij

32.9k877112




32.9k877112












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

    – yael
    May 6 at 18:04












  • @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
    May 6 at 18:11












  • @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
    May 6 at 20:17












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

    – yael
    May 6 at 21:14











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

    – jimmij
    May 6 at 21:23

















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

    – yael
    May 6 at 18:04












  • @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
    May 6 at 18:11












  • @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
    May 6 at 20:17












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

    – yael
    May 6 at 21:14











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

    – jimmij
    May 6 at 21:23
















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

– yael
May 6 at 18:04






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

– yael
May 6 at 18:04














@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
May 6 at 18:11






@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
May 6 at 18:11














@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
May 6 at 20:17






@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
May 6 at 20:17














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

– yael
May 6 at 21:14





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

– yael
May 6 at 21:14













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

– jimmij
May 6 at 21:23





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

– jimmij
May 6 at 21:23

















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

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form