Originally Posted by paul_e_t
My prompt given in dot profile (?) is way to long. Not only that but it does not have a dot in front to make the file hidden??. All I want is my login name "pault" as a prompt however I can't properly read or understand the complex script. I also cannot find any references. running Mint17 I sure could use help. please
Things are easier to read when you put programs/scripts in code blocks to preserve indentation. I'll put some indentation while explaining..
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
This tests for the existence of the PS1 environment variable. If it is missing then the convention is that the shell is being used to run a script, so you don't need the prompt string anyway. This just saves time...
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
This checks for the type of shell. /bin/sh is a shell, but doesn't necessarily have all the features of bash. The first part is just testing to see if the environment variable BASH has a non empty value, then it checks to see if the value is "/bin/sh". If it is not, then the true part of the test is processed (it assumes you are using bash, which is reasonable in this context. If you were running the C shell- csh - it would be processing a different file than this one anyway).
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
All this is doing is checking for the existence of the file /etc/bash.bashrc. If the file exists, then the script includes the command from that file.
If the line "#PS1='\h:\w\$ '" weren't commented out, it would set the users command prompt to the host name, and the current working directory. It just provides a simple way to remind the user of what host (the \h), and directory (the \w) the command the user is about to type in will affect. If there is only one machine, then the "\h: can be left out. If none of this is desired, then I would suggest using "PS1='$ '" instead.
The ". /etc/bash.basrc" just adds the contents of the file to the command stream already being executed. This allows environment variables that may be defined in that file to be added to the current process environment. It works exactly as if the contents of the file were in this file (the /etc/profile I'm annotating)
if [ "`id -u`" -eq 0 ]; then
This is the part executed if the shell is identified as /bin/sh as determined by the testing of the BASH environment variable. The syntax used is the more restricted syntax of the bourne shell, and is simplified. The "`id -u`" identifies the user id (see the manpage for the id command), and checks to see if the value is 0. If it is 0, then the login is for the root user, and sets the command prompt to '# '. This allows a relatively easy visual identification/reminder that the root account (with the power to destroy things accidentally) is being used. If the user id is not 0, then the prompt is set to '$ ', indicating the the login is a bit safer to use (damage is limited to only the files/processes that the login can access).
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
This last part is a bit more complex. This part looks for the existance of a directory (named /etc/profile.d). If the directory exists, then the "for i" loop will loop for each file in /etc/profile.d that has the extension ".sh", and include the commands in the identified file as part of the profile. This is used to define some specialty environment variables that may be needed by users. The files may define an application environment with a different command search list, additional default libraries, or other setup needed for the given login. These files are sometimes added to the /etc/profile.d directory by things like database systems, work processing systems,... anything that needs a special setup to work. They COULD have been done as part of the application startup (see google earth for a rather lengthy setup), but are done here to save time later. If the environment can be setup once for the user, why do it each time the application is used?
Hope this helps.