OpenWRT Command Line Prompt via SSH

Wiki.TerraBase.info
Revision as of 14:47, 27 September 2021 by Root (talk | contribs) (Created page with "...at least it isn't as bad as the default Command Line Prompt from Redhat / CentOS. It has the most important thing, even Microsoft has included with DOS: The current FULL p...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

...at least it isn't as bad as the default Command Line Prompt from Redhat / CentOS. It has the most important thing, even Microsoft has included with DOS: The current FULL path (not just a directory) where one is in the file system. For example: root@WRT3200ACM:/etc/config

How does one modify it? Change the PS1 variable (the line that starts off: export PS1='WhatEverStuff ' ), it's in /etc/bashrc. But for OpenWRT it's in /etc/profile.

The default value for PS1 = PS1='\u@\h:\w\$ ' (\u = User Name, \h = Host Name, \w = Full Path, \$ = # if one is logged on as the root user, $ for any other user)

This results in (for example): root@WRT3200ACM:/etc/config

What if you want just the path? Use this: PS1='[\w]\\$ '

For an 'old fashion' DOS prompt: export PS1='\h:\w > '

If you're logged on via IP / SSH, disconnect and reconnect to a new session for settings to take place.

If you're connected via Serial / TTL, type exit, then press enter a couple of times to start a new session.

If one is working on several OpenWRT routers, it will probably be useful to leave in the \u (Host Name)

CentOS uses Double Quotes ( " ) around what the PS1 variable is set to. OpenWRT uses Single Quotes ( ' ). Since both are really BASH based, probably both would work for OpenWRT. But if one wants to stick with the convention, use Single Quotes.

For additional information on the BASH PS1 variable: https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html