change bash 40.1 command line arguments parsing Linux

Linux Shell Login Showing bash-4.1 command line, How do i change bash-4.1# to user@hostname ?

https://www.techitadmin.com/2021/09/linux-login-showing-bash-41-command-line.html

How do i change bash-4.1# to user@hostname when login on linux PC Desktop Server

If you are facing above issue during login on Linux PC Desktop Servers so this may help to resolve the issue. What is Bash ? 

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been used as the default login shell for most Linux distributions. A version is also available for Windows 10 via the Windows Subsystem for Linux.

Problem occurs with login shellsIf the problem occurs with login shells as well as non-login shells, the problem is probably the same as above. If it occurs only with login shells, you either don’t have one of the files mentioned for login shells under the INVOCATION quote above, or they don’t source your ~/.bashrc, which is normal on most linux distros. If none of those files exists, create ~/.bash_profile with this in it:
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi
This allows you, for the most part, to keep your configuration in one file (~/.bashrc).
If no matter what you do you cannot get a prompt back, you can create one and put it into ~/.bashrc this way:
if [ “$PS1 ]; then
    PS1= …. # see below
fi
This is because $PS1 is set and has a default value for interactive shells, and you don’t want to set it otherwise since other things may use this value to determine whether this is an interactive environment.
The bash man page contains a section PROMPTING which describes how to set a prompt with dynamic features such as your user name and current working directory, which would be, e.g.,:

To change bash-4.1# to user@hostname

Just go to /etc/skel 
run command $ls -a  it will show 
.bash_logout  .bash_profile  .bashrc  .kshrc 

Now cp bash_profile  .bashrc /home/usernametry to log out and login again you will notice normal bash prompt. 

user@hostname

What is /etc/skel files under Linux systems ?

The /etc/skel directory contains some of the files and directories that are automatically copied over to a new linux user’s when it is created using useradd command. it ensures that all the users gets same intial settings and environment.
Skel is basically derived from the “skeleton” because it contains basic structure of linux user home directory. under the path of /etc/skel directory contains files and directories. 

What is the use of /etc/skel directory in linux ?If your linux system required to distribute default configuration files  you can add that to the directory, when you add any new user and you have chosen to create a home directory while setting up the new user, the files that are contained within /etc/skel directory are copied into the home directory of the new user.


What is a .bashrc file in linux ?
The .bashrc  file normally we can find under users’s home area /home/username .bashrc is a script file that’s executed when any user logs in. The file itself contains a series of configurations for the terminal session. This includes setting up or enabling coloring, completion, shell history, command aliases, and many more. this is a kind of hidden file and imple ls command won’t show the file in your home area if you want to see your .bashrc file use the command ls -a command to view and make necessary changes if required.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *