Command prompt changing

Have a tip or trick to do with Linux?
Want to write a How-to or an in depth tutorial?
This is the place.
Post Reply
User avatar
Posts: 7
Joined: Fri Dec 15, 2017 8:23 pm

Command prompt changing

Post: # 6Post FrankG
Sat Dec 16, 2017 10:11 am

It seems in Linux you are drawn to the command prompt quite frequently, I am discovering that many task can be accomplished quicker and easier by launching a terminal and typing a quick command. On my computer the default command prompt looks like this:
My default prompt
defaultprompt.png (15.77 KiB) Viewed 243 times

While that is okay and totally functional it displays a lot of info that I already know and don't need to see every time I pop into a terminal. So I changed it to show the time and the working directory only.
It now looks like this:
My new prompt
promptnew.png (13.66 KiB) Viewed 243 times
If you would like to simplify your prompt it is an easy fix:
When following this tutorial enter the code (the highlighted blue text) exactly as shown.
Do not enter the + signs IE press ctrl alt t not ctrl + alt + t
  1. Open a terminal ctrl+alt+t
  2. Type in the following; ~:$vim .bashrc replace vim with the text editor of your choice.
  3. Once the file is open find the first line that starts with PS1 (in vim you would do this by entering the following: /PS1 then press enter)
  4. Press the n key to cycle through all instances of PS1 you want to be at the first (top) listing.
  5. Now change what is there to the following: PS1="\t_\w:$" (In vim you can position your cursor at the start of the line type c$ and type PS1="\t_\w:$" then hit the escape key)
  6. Type shift+: your cursor will move to the bottom left of the terminal and you will see the :
  7. Type wq and press enter.
  8. Type exit
  9. That's it relaunch the terminal ctrl+alt+t to view your new command prompt.
I hope this was helpful, this is the first tutorial I have written so please comment if it was helpful and suggestions are welcome..

  • HP Pavilion g7
  • Ubuntu 17.10
  • Gnome Desktop

Post Reply