Last time, I have written a short article on Linux environment variables. In that article, we have also seen a types of environment variable, the purpose of PATH variable and so on. But, in Linux there is also one very important variable that we are going to discuss in this article. It's a PS1 variable.
What is PS1 variable?
You can look at PS1 variable as a bash prompt configuration variable. It's a basically variable that defines the way your bash prompt is going to look like. So, every time you launch your terminal, you will see something like this.
What you see on this picture above, is the way my terminal looks like when I launch it. Now, as you can see, there is:
# amar@ubuntustation:~$
Here's a short brake up of the text above. In the first you can see my name.
- amar - my username
@ - separator between username and hostname
ubuntustation - hostaname (machine name)
~ - user home directory
$ - designates regular user
# - designates super user
You can change your hostname via the hostname command in terminal.
# man hostname
The look of the prompt is stored within the PS1 variable. The system settings of the prompt (for all users on the system) are stored in /etc/bashrc file.
Once you run echo PS1, you will get different information. By default, PS1 will list the following information. To see it, run the following command.
# sudo vim /home/amar/.bashrc
By default, PS1 lists the following information when you open up your terminal.
# PS1="[\u@\h\W]\$"
(u) - username
(h) - hostname
(\W) - the base of the name of current working directory
(\$) - regular user
(\#) - super user
Note that the prompt can be changed as well and you need to modify it's file in order to add time, current date, uptime or any other desired information you want to be shown in your prompt. But I suggest you to not change these information unless you need so, it's a better to leave it the way it is. But if you wish to change the prompt, feel free to visit the article bellow that will guide you into that process. Till next time.
How to change your prompt?
[1] https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
Nema komentara:
Objavi komentar