Previous Page | Next Page

  1. Agustin's Linux Manual
  2. System Administration
  3. About the Author
  4. Contents
  5. Administration
  6. Terminals
  7. Command Basics
  8. Root Directory
  9. Executing Commands
  10. File specs
  11. File Permission
  12. How permissions are assigned
  13. Change ownership chown
  14. Running multiple commands
  15. Killing Processes
  16. Bash configuration files
  17. VI Editor
  18. Creating path environment
  19. Midnight Commander
  20. Linuxconf Utility
  21. Networking
  22. Domain Name Service DNS
  23. Router and Gateway
  24. Adding Users
  25. User Accounts
  26. Managing Groups
  27. Mounting File System
  28. NFS Mounts
  29. Disk Quotas
  30. Run levels
  31. Linuxconf Control
  32. Mandrake Control Center
  33. Creating a Boot Disk
  34. Switching Boot Mode
  35. Hardware Configurations
  36. Printer Configuration
  37. Installing Printers
  38. Samba Printer
  39. Managing services
  40. Managing Users
  41. Program Scheduler
  42. Software Management
  43. Installing CUPS

Bash configuration files

The bash controls some special files, which are part of every user's profile. These files are sitting right in your home directory.

[agustin@server2 agustin]$ ls .bash*

File nameDescription
.bash_historyKeeps a list of the commands you have been typing
.bash_logoutA list of auto run commands to be executed when you leave the shell,
.bash_profileA list of commands to be executed when you log in.
.bashrccontains a list of commands that is executed every time you open a new shell
Table 3.4

Changing the prompt

This is not so important it is just a matter of personal taste. Here I will demonstrate how to modify the prompt. This modification is for general users, and the file to be modified is /etc/bashrc

[root@server2 agustin]# vi /etc/bashrc
1 # /etc/bashrc
2 
3 # System wide functions and aliases
4 # Environment stuff goes in /etc/profile
5
6 # by default, we want this to get set.
7 # Even for non-interactive, non-login shells.
8 if [ `id -gn` = `id -un` -a `id -u` -gt 99 ]; then
9	umask 002
10 else
11	umask 022
12 fi
13
14 # are we an interactive shell?
15 if [ "$PS1" ]; then
16    case $TERM in
17	xterm*)
18	    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
19	    ;;
20	*)
21	    ;;
22    esac
23 #   [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
24    
25    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\[\e[1;32m\] \w\\$\[\e[1;37m\]"
26  
27    if [ -z "$loginsh" ]; then # We're not a login shell
28        for i in /etc/profile.d/*.sh; do
29	    if [ -x $i ]; then
30	        . $i
31	    fi
32	done
33    fi
34 fi
35
36 unset loginsh

Comment line 23 and add line 25.
  • Press ESC
  • Type the colon ":"
  • Type wq

The next time you login your prompt will look like this:

For root: ~#
For users: ~$