Difference between revisions of "Lab Manual:Unix/Linux Primer"

From SpanLabWiki
Jump to: navigation, search
(X11 Scroll Bar)
Line 1: Line 1:
 
Most of the lab's computers use Unix (our Macs running OS X) or Linux (amygdala, dmthal, nacc, etc.). Linux and Unix are nice because they are stable, secure (if you know what you are doing), efficient, and play well with most of our lab software.
 
Most of the lab's computers use Unix (our Macs running OS X) or Linux (amygdala, dmthal, nacc, etc.). Linux and Unix are nice because they are stable, secure (if you know what you are doing), efficient, and play well with most of our lab software.
 +
 +
==Some Useful UNIX Commands==
 +
 +
To look at disk usage:
 +
$ df -h *
 +
 +
To find a file:
 +
$ locate searchstring dopa2PA
 +
 +
To get full time information on files:
 +
$ ls --full-time
 +
 +
Setting the path, the place the afni command will look for afni. Note that you need to be in the tcsh shell to do this.
 +
$ setenv PATH {$PATH}:/abin    (or appropriate path name in place of /abin)
 +
 +
Setting Permissions
 +
In the folder whose permissions you're setting, type
 +
$ chmod 775 *
 +
 +
If not in the folder, type
 +
$ chmod 775 foldername
 +
 +
For an individual executable (eg a script), you can set permissions with the chmod command.  Each number in the three digit code sets permissions for different levels of user. "775," for example, sets R/W/Ex abilities to the user and group, but only 5 to all others.
 +
 +
$ chmod 775 filename
 +
 +
 +
 +
To check on # of trial types, go to each subject's folder and type the grep command, subbing in for D1 as need (this is the trial type argument)
 +
 +
$ grep -c D1 bb.vec
 +
 +
 +
To determine which version you're running:
 +
$ cat /proc/version
 +
 +
So, for example:
 +
 +
[span@mpfc /]$ cat /proc/version
 +
 +
will return
 +
 +
Linux version 2.4.20-19.9smp (bhcompile@stripples.devel.redhat.com)(gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5))
 +
#1 SMP Tue Jul 15 17:04:18 EDT 2003
 +
 +
 +
$ is the BASH shell - to return to BASH, type 'bash'
 +
% is the TCSH shell - to return to TCSH, type 'tcsh'
  
 
==UNIX Commands Reference==
 
==UNIX Commands Reference==

Revision as of 13:40, 17 July 2008

Most of the lab's computers use Unix (our Macs running OS X) or Linux (amygdala, dmthal, nacc, etc.). Linux and Unix are nice because they are stable, secure (if you know what you are doing), efficient, and play well with most of our lab software.

Some Useful UNIX Commands

To look at disk usage:

$ df -h *

To find a file:

$ locate searchstring dopa2PA

To get full time information on files:

$ ls --full-time

Setting the path, the place the afni command will look for afni. Note that you need to be in the tcsh shell to do this.

$ setenv PATH {$PATH}:/abin    (or appropriate path name in place of /abin)

Setting Permissions In the folder whose permissions you're setting, type

$ chmod 775 *

If not in the folder, type

$ chmod 775 foldername

For an individual executable (eg a script), you can set permissions with the chmod command. Each number in the three digit code sets permissions for different levels of user. "775," for example, sets R/W/Ex abilities to the user and group, but only 5 to all others.

$ chmod 775 filename


To check on # of trial types, go to each subject's folder and type the grep command, subbing in for D1 as need (this is the trial type argument)

$ grep -c D1 bb.vec


To determine which version you're running:

$ cat /proc/version

So, for example:

[span@mpfc /]$ cat /proc/version

will return

Linux version 2.4.20-19.9smp (bhcompile@stripples.devel.redhat.com)(gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5))
#1 SMP Tue Jul 15 17:04:18 EDT 2003


$ is the BASH shell - to return to BASH, type 'bash'
% is the TCSH shell - to return to TCSH, type 'tcsh'

UNIX Commands Reference

Here is a good reference on Unix/Linux Commands: UNIX Command Summary - http://unixdocs.stanford.edu/unixcomm.html

Some more Unix/Linux Resources from Stanford Computing: UNIX Documentation at Stanford http://www.stanford.edu/services/unix/

X11 Tips and Tricks

X11 is the x window terminal of choice for Mac OS X.

Installing X11

On Mac OS X 10.5 Leopard, X11 is preinstalled.

On Mac OS X 10.4 Tiger, X11 needs to be installed off of your Tiger Installation DVD. It is a bit hidden however, you have to scroll down in the Finder window or look at the DVD in list mode to see the X11 installation add on.

X11 Scroll Bar

X11 terminal windows by default have no scroll bar. You can open a new X11 window with the command

 > xterm -sl 5000 -sb &

-sl determines how many lines to keep and -sb adds a scroll bar.

Or you can create a new executable file to do this automatically:

 > emacs xtermscroll

Add the line

 xterm -sl 5000 -sb &

Make the file executable

 > chmod 755 xtermscroll

In the FInder, make the file open with X11.

Select the file, Command-I, or File > Get Info; and set Open With: to X11.

Now you can double click on the new program to get a X11 window with a scroll bar.

X11 Window Focus Follows Mouse

When using AFNI with X11 window forwarding, you might find it more efficient to set your mouse to focus on the screen it is rolled over.

You can set this in the command line by typing the command:

 > defaults write com.apple.x11 wm_ffm -bool true

You can turn this off with the command:

 > defaults write com.apple.x11 wm_ffm -bool false