How to change the terminal to a beautiful command line prompt in Ubuntu 18

How to change the terminal to a beautiful command line prompt in Ubuntu 18

I reinstalled VMware and Ubuntu, but the command line prompt is too monotonous and not beautiful. How can I change it? So I searched the Internet.

1. Change the PS1 environment variable. Both of these are OK. I choose the first one:

 export PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h\[\033[00m\][\[\033[01;33m\]\t\[\033[00m\]]:\[\033[01;34m\]\w\[\033[00m\]$ "
 export PS1="\[\e[32;1m\][\[\e[33;1m\]\u\[\e[31;1m\]@\[\e[33;1m\]\h \[\e[36;1m\]\w\[\e[32;1m\]]\[\e[34;1m\]\$ \[\e[0m\]"

2. Run ls-all as a normal user, select .bashrc and insert the export PS1= code above at the end of the file, then enter the following command to take effect.

source ./.bashrc

3. Then modify PS1 under root. Use the method on the Internet to insert export PS1 at the end of the /etc/profile file and then source it to take effect. However, it is troublesome to source it again every time you use the root connection in xshell.

At this time, you can find the .bashrc file in the root directory under root, add PS1 to it, and then source ./.bashrc, and it will take effect every time you connect.

In order to distinguish root from ordinary users, you need to change $ to #:

export PS1="\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;32m\]\h\[\033[00m\][\[\033[01;33m\]\t\[\033[00m\]]:\[\033[01;34m\]\w\[\033[00m\]# "

Summarize

The above is the method that I introduced to you to change the terminal to a beautiful command line prompt in Ubuntu 18. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Summary of how to modify the terminal command prompt in Ubuntu when it is too long

<<:  Detailed explanation of jQuery's animate animation method and animation queuing problem solution

>>:  How to configure MySQL master-slave synchronization in Ubuntu 16.04

Recommend

Master the CSS property display:flow-root declaration in one article

byzhangxinxu from https://www.zhangxinxu.com/word...

Detailed example of locating and optimizing slow query sql in MySQL

Table of contents 1. How to locate and optimize s...

Use Docker to create a distributed lnmp image

Table of contents 1. Docker distributed lnmp imag...

Solution to the IP address not being displayed under Linux

Table of contents Preface Solution: Step 1 Step 2...

CSS3 countdown effect

Achieve results Implementation Code html <div ...

Eight common SQL usage examples in MySQL

Preface MySQL continued to maintain its strong gr...

Detailed explanation of nodejs built-in modules

Table of contents Overview 1. Path module 2. Unti...

How to modify the default storage location of Docker images (solution)

Due to the initial partitioning of the system, th...

MySQL password is correct but cannot log in locally -1045

MySQL password is correct but cannot log in local...

js to achieve 3D carousel effect

This article shares the specific code for impleme...

Responsive layout summary (recommended)

Basic knowledge of responsive layout development ...

JavaScript recursion detailed

Table of contents 1. What is recursion? 2. Solve ...

Vue's global watermark implementation example

Table of contents 1. Create a watermark Js file 2...