Debian Clusters for Education and Research: The Missing Manual

Bash Profile Modifications

From Debian Clusters

Jump to: navigation, search

Group Modifications

By default, when Debian creates a new user, it creates a new group for that user (the group is named the same as the group name). Rather than having each user in their own group, it's smart to add them to a common users or similar group. To change this default, edit /etc/adduser.conf and change

USERGROUPS=yes

to

USERGROUPS=no

Home Directory Modifications

If users' home directories will be on the NFS mount, then current users' home directories need to be moved here, and new users directories also needed to be created here.

New Users

To ensure that new users have home directories created in the appropriate place on the NFS mount, edit /etc/adduser.conf. In this file, the DHOME variable needs to be set to the new location. For instance, if your mount is called /shared like mine is, you would change it to

DHOME=/shared/home

Current Users

The move over for current users can be accomplished by moving their old directory over to the mount (mv /home/user /shared/ in my case) and then editing /etc/passwd. The second to last entry on each line for a user is their home directory. This needs to be changed to the home directory's new location. For instance, (in my case again, since my mount is called /shared),

kwanous:x:1000:1000:KWanous,,,:/home/kwanous:/bin/bash

becomes

kwanous:x:1000:1000:KWanous,,,:/shared/kwanous:/bin/bash

PATH Additions

If you're using part of the NFS mount to share software as well as home directories, then the PATH variable for everyone needs to be modified so that it looks in /yourmountname/bin for executable code. (I'm calling my mount shared, so mine is /shared/bin.) To do this, edit /etc/profile. This will take affect for all users, current and new.

Initially, the path you're concerned with looks like this:

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

Append :/<yourmountname>/bin for both root accounts (the first part of the if statement) and all other accounts (the else part). Also append :/<yourmountname>/sbin just to the root account part. My modified portion of the file is the below.

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/shared/bin:/shared/sbin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/games:/shared/bin"
fi

History

Normally the bash shell history, executed by history and stored in ~/.bash_history, only stores a limited number of commands entered (500 by default on Debian). The number of commands stored can be increased, as well as the format of the history file.

There are a couple of different places to store these changes. You could put them individually in each user's ~/.bash_profile and then also edit the one in /etc/skel/.bash_rc so that changes appear in each new user's .bash_profile. This way, users will be able to edit this part out of their bash profile if they don't like the changes. (You'll also have to add it to /root/.bashrc for the root user.) On the other hand, if you always want these changes to be on for all users and to not let them be able to turn them off, edit /etc/bash.bashrc.

More Commands

To change the number of commands that history keeps track off, add the following lines:

HISTSIZE=10000
HISTFILESIZE=''

HISTSIZE specifies the number of commands to store. HISTFILESIZE being set to nothing means that the history file can grow indefinitely. Since you're going to be adding far more commands now, it's also a good idea to add

HISTCONTROL=ignoreboth

This line prevents duplicate commands from being entered in history next to each other. For instance, if you typed ls three times in a row with no other commands in between, it would only store ls once. On the other hand, if you executed ls, cd mystuff, ls, cd, ls, then this whole set of instructions would be stored in history. None of the commands next to each other in that sequence are the same.

Timestamped History

Adding this line

HISTTIMEFORMAT='%a, %d %b %Y %l:%M:%S%p %z '

will make history displayed like this:

kwanous@gyrfalcon:~$ history | tail -n 5
  245  Fri, 20 Jul 2007 12:39:26PM -0500 history
  246  Fri, 20 Jul 2007 12:39:52PM -0500 history | tail
  247  Fri, 20 Jul 2007 12:40:03PM -0500 nano .bash_profile 
  248  Fri, 20 Jul 2007 12:41:56PM -0500 exit
  249  Fri, 20 Jul 2007 12:42:06PM -0500 history | tail -n 5
  • %a is the day of the week
  • %d is the date
  • %b is the month
  • %Y is the year
  • %l is the hour
  • %M is the minutes
  • %S is the seconds
  • %p is AM/PM
  • %z is the adjustment from Greenwich Mean Time

For entries in .bash_history prior to making this change, the current date/time will be added to them.

Personal tools