Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the modification methods that the terminal command prompt is too long in ubuntu?

2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "ubuntu terminal command prompt is too long to modify what are", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "ubuntu terminal command prompt is too long to modify the method of which" this article.

The terminal command prompt for ubuntu is too long, the main reasons are:

1: the computer name is too long

2: multi-layer is directly displayed.

For long computer name processing:

For example, the following computer name prompt is too long:

Ningcaichen-virtual-machine is the computer name:

Ningcaichen@ningcaichen-virtual-machine:/mytmp$ sudo vim / etc/hostname

Modified to:

Ningcaichen@ningcaichen-virtual-machine:/mytmp$ sudo vim / etc/hosts

Modified to:

Restart

The result will be better:

Processing for displaying multi-tier directories:

It looks like:

You can change it without modifying it at a glance, or you can change it to show only the last directory (at this point you have to look at all the paths, you have to pwd):

For example, CentOS shows only the last directory:

Modify this file:

(make a copy before you modify it)

Vim .bashrc

(enter: set number in command line mode) enter to display the line number:

Change the previous\ w to\ W

Re-execute the newly modified initialization command document (which contains commands), and there is no need to restart.

Source / .bashrc

Results:

As you can see, only one directory is shown at the end.

So: pwd if you want to see all of them at this time.

The above is all the contents of this article entitled "what are the ways to modify the terminal command prompt in ubuntu that is too long?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report