Linux系统中PS1是什么?

什么是PS1变量
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.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT鹅

您的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值