Hoffman2:Profile: Difference between revisions

From Center for Cognitive Neuroscience
Jump to navigation Jump to search
No edit summary
No edit summary
(2 intermediate revisions by the same user not shown)
Line 41: Line 41:




====Curious?====
===Curious?===
For those that care, what you are doing is asking the computer to execute the file
For those that care, what you are doing is asking the computer to execute the file
  /u/home/FMRI/apps/etc/profile
  /u/home/FMRI/apps/etc/profile
Line 48: Line 48:
The last line
The last line
  umask 007
  umask 007
makes it so that any files you create will have a default permission of about 770 so that other people in your group have write permissions.
makes it so that any files you create will not allow "anyone" outside your group to read, write, or execute files and directories you make.  This does not automatically grant read, write, and execute privileges to you and your group though.






==Extras==
==Extras==
===Collaboration===
By default, any files and directories you create will not necessarily have permissions that allow your group to write on them.  This can be a problem if other people are supposed to build on data you processed.  We have a script ([[Hoffman2:Scripts:fix_perms |fix_perms.sh]]) that will kindly find any files you own in a specified directory that don't have read/write/execute permissions for the group and make it so they do.
You can build this script into your bash profile so that every time you log into Hoffman2, it will run in the background.  It is also recommended that you run this script at the end of jobs to make results immediately available to collaborators.
Adding the line
fix_perms.sh -q ~/../data &
to the end of your bash profile will run the permission fixer on your group's common data directory in the background quietly each time you log in.
===Colors===
You can change the content and color of your command prompt by editing your bash_profile.  There is a great explanation of how to do this [http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html here].
You can change the content and color of your command prompt by editing your bash_profile.  There is a great explanation of how to do this [http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html here].


Line 65: Line 76:
: The name of the computer you are logged into.  This also helps you know where you are at all times.
: The name of the computer you are logged into.  This also helps you know where you are at all times.


===Example===
Line to add to your bash profile
Line to add to your bash profile
  export PS1="\[\e[0;31m\]\h\[\e[1;37m\]:\[\e[1;34m\]\w\n\[\e[1;37m\]\D{%Y-%m-%d-%H-%M-%S} \[\e[22;32m\]\u \$ "
  export PS1="\[\e[0;31m\]\h\[\e[1;37m\]:\[\e[1;34m\]\w\n\[\e[1;37m\]\D{%Y-%m-%d-%H-%M-%S} \[\e[22;32m\]\u \$ "
Line 71: Line 81:
<code style="background:#000000; padding:5pt"><span style="color:#FF0000">HOST</span><span style="color:#000000">:</span><span style="color:#0000FF">CURRENT WORKING DIRECTORY</span><br/>
<code style="background:#000000; padding:5pt"><span style="color:#FF0000">HOST</span><span style="color:#000000">:</span><span style="color:#0000FF">CURRENT WORKING DIRECTORY</span><br/>
<span style="color:#FFFFFF"> DATETIME IN ISO8601 FORMAT</span> <span style="color:#00FF00">USERNAME $</span></code>
<span style="color:#FFFFFF"> DATETIME IN ISO8601 FORMAT</span> <span style="color:#00FF00">USERNAME $</span></code>
==Example Bash Profile==
<nowiki>#.bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# Source to use FMRI Apps
source /u/home/FMRI/apps/etc/profile
# Umask (Revoke Permissions)
umask 007
# Collaborative permissions
fix_perms.sh -q ~/../data/collabDirectory
# Happy Colors
export PS1="\[\e[0;31m\]\h\[\e[1;37m\]:\[\e[1;34m\]\w\n\[\e[1;37m\]\D{%Y-%m-%d-%H-%M-%S} \[\e[22;32m\]\u \$
</nowiki>





Revision as of 01:03, 19 September 2012

Back to all things Hoffman2

In UNIX systems, there are certain configuration files that get executed every time you login. If you are using the Bash shell (default), you have a file called .bash_profile which is processed when you log in. In order to make the FMRI toolset available to you on Hoffman2 and so you can work well with others, we recommend that you follow the instructions in the Basics section. Read Extras for some bells and whistles.


Basics

You account has one last thing that needs to be edited before being usable.

  1. SSH into Hoffman2
  2. Use your favorite text editor to edit the file ~/.bash_profile
    VIM
    • $ vim ~/.bash_profile
    Emacs
    • $ emacs ~/.bash_profile
    NEdit
    • $ nedit ~/.bash_profile
  3. Insert these lines at the bottom of the file
    • source /u/home/FMRI/apps/etc/profile
      umask 007
    VIM
    • Type G - capital G - to go to the end of the file
    • Type A - capital A - to go to the end of the line and enter insert mode
    • Type ENTER - to insert a newline
    • Type or paste in the specified lines.
    Emacs
    • Use the arrow keys to scroll the cursor down to the bottom of the document and add a newline.
    • Type or paste in the specified lines.
    NEdit
    • Use the arrow keys to scroll the cursor down to the bottom of the document and add a newline.
    • Type or paste in the specified lines.
  4. Save the file
    VIM
    • ESC + ":wq" + ENTER
    Emacs command line
    • CTRL+x, CTRL+c
    Emacs GUI
    • CTRL+x, CTRL+c, y
    • or use the menu system
    NEdit
    • Use the menu.
  5. Log out of Hoffman2 and the next time you log in, everything will be set for you to start working.


Curious?

For those that care, what you are doing is asking the computer to execute the file

/u/home/FMRI/apps/etc/profile

every time you login. This file modifies your PATH variable so you have access to the FMRI toolset.

The last line

umask 007

makes it so that any files you create will not allow "anyone" outside your group to read, write, or execute files and directories you make. This does not automatically grant read, write, and execute privileges to you and your group though.


Extras

Collaboration

By default, any files and directories you create will not necessarily have permissions that allow your group to write on them. This can be a problem if other people are supposed to build on data you processed. We have a script (fix_perms.sh) that will kindly find any files you own in a specified directory that don't have read/write/execute permissions for the group and make it so they do.

You can build this script into your bash profile so that every time you log into Hoffman2, it will run in the background. It is also recommended that you run this script at the end of jobs to make results immediately available to collaborators.

Adding the line

fix_perms.sh -q ~/../data &

to the end of your bash profile will run the permission fixer on your group's common data directory in the background quietly each time you log in.


Colors

You can change the content and color of your command prompt by editing your bash_profile. There is a great explanation of how to do this here.

Some of the content you can include in the command prompt:

Current time
You can format this however you want. This helps when looking back through your Terminal to find when you made certain changes to files.
Current working directory
So you always know where you are in a filesystem and don't need to constantly retype pwd.
Username
Who you are. Helpful if you are logged into multiple servers under multiple accounts and need help keeping track.
Host
The name of the computer you are logged into. This also helps you know where you are at all times.

Line to add to your bash profile

export PS1="\[\e[0;31m\]\h\[\e[1;37m\]:\[\e[1;34m\]\w\n\[\e[1;37m\]\D{%Y-%m-%d-%H-%M-%S} \[\e[22;32m\]\u \$ "

Resulting prompt (on a black background)
HOST:CURRENT WORKING DIRECTORY
DATETIME IN ISO8601 FORMAT USERNAME $


Example Bash Profile

#.bash_profile

 # Get the aliases and functions
 if [ -f ~/.bashrc ]; then
         . ~/.bashrc
 fi

 # Source to use FMRI Apps
 source /u/home/FMRI/apps/etc/profile

 # Umask (Revoke Permissions)
 umask 007

 # Collaborative permissions
 fix_perms.sh -q ~/../data/collabDirectory

 # Happy Colors
 export PS1="\[\e[0;31m\]\h\[\e[1;37m\]:\[\e[1;34m\]\w\n\[\e[1;37m\]\D{%Y-%m-%d-%H-%M-%S} \[\e[22;32m\]\u \$ 


External Links