In the next article we are going to take a look at how to modify the bashrc. With this we will achieve hide or modify the username and host name of the prompt by Bash. Some people are obsessed with privacy and your security. They never reveal anything about your identity online. If you are one of them, you will like this little tip to protect your privacy a bit.
If you are a blogger or tech writer, you will almost certainly need to upload screenshots of your Gnu / Linux terminal to your websites and blogs sometimes. And as all Gnu / Linux users know, the terminal will reveal our username and host.
If you are one of those who do tutorials and share screenshots of your terminal and you are also concerned about privacy and security, the most practical is to simply create another user account as admin @ demo or user @ example. We can use these accounts to make guides or videos and upload them to our blog or social networks without worrying about the data shown by the terminal. But there are also other options as we are going to see below.
Your username / host may be too cool so you may not want others to copy it and use it as their own. On the other hand, your username / host name may be too weird, bad, or may contain offensive characters, so you may not find it interesting for others to see them. In such cases, this little tip might help you hide or change your username @ localhost in terminal.
In the previous screenshot you can see that in my terminal the username is "sapoclay" and "entreunosyceros ”is my host name.
Hide "username @ localhost:" using the bashrc file
To begin with, we are going to edit our file "~ / .bashrc". I'm going to use the Vim editor for this, but that each one uses the one they like the most. In my case, after opening the terminal (Ctrl + Alt + T) I am going to write the following command:
vi ~/.bashrc
Once open, we will press the 'Esc' and 'i' key. Once in insert mode we will add the following to the end of the file:
PS1="\W> "
To exit the file, as always in vim, we have to press the 'keyI' and then write: wq to save and close the file.
After returning to the console, we will have to run the following command to make the changes effective:
source ~/.bashrc
We will see the changes immediately. Now we will no longer see the user @ localhost part. Only the ~> symbol will be seen.
Modify "username @ localhost:" using the bashrc file
If what you are looking for is not to hide the part of user @ localhost, but if you are looking change your bash prompt to something more interesting and meaningful we will have to go back to edit ~ / .bashrc file. From the terminal (Ctrl + Alt + T), as in the previous example, we will write:
vi ~/.bashrc
Open the file and activated the insert mode, we will add the following line at the end of the same:
PS1="entreunosyceros> "
Replaces «interunosyceros»With any combination of letters of your choice. When you have it, press the 'keyI' and writes : Wq to save and exit the file.
For see the changes madeAs in the previous example, you will have to execute the following command to update the changes:
source ~/.bashrc
These changes will be displayed immediately. We can see the letters entreunosyceros at your shell prompt.
Get settings for bashrc via web
If you want to be able to configure your computer's prompt in your own way, you can go to the website bashrcgenerator. In it you can select through 'drag and drop'what options do you want to be displayed in your terminal. The web will provide you with the necessary code that you will have to add to your ~. / Bashrc file as we have just seen in this same article.
Warning- This is bad practice in some cases. For example, if other shells like zsh inherit your current shell, it will cause some problems. Use it only to hide or modify your username @ localhost if you use a single shell. In addition to hiding the user @ localhost part in the terminal, this tip does not have a functional app and it could be problematic in some specific cases, even though it is very cool well configured.