What is /?

• An Unix Tutorial (like Windows and OS X) for • Linux is the free, modifiable, and FreeSurfer Users redistributable version of Unix

Allison Stevens •Why use it?

What is Unix/Linux? Getting Started

• An operating system Communicate with operating system (like Windows and OS X) through a “shell” or terminal window.

• Linux is the free, modifiable, and For Linux: redistributable version of Unix Double click Terminal icon on Desktop

•Why use it? For Macs: – power to many scripts with many Double click on hard drive commands to work with lots of data Applications > Utilities > X11 (double click)

1 Warm Up Warm Up

Type: : date and hit enter. date and hit enter. Should see Mon Apr 6 8:05:24 EDT 2009

Warm Up Warm Up

Type: Type: date and hit enter. Should see Mon Apr 6 8:05:24 EDT 2009 date and hit enter. Should see Mon Apr 6 8:05:24 EDT 2009

Type: Type:

April 2009 and hit enter. cal and hit enter. Should see Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

2 Directories Directories

• Unix uses a hierarchical system • Unix uses a hierarchical (think (think folders in Windows) folders in Windows) Home is like “My Computer”

Directories Directories

• Unix uses a hierarchical file system (think • Unix uses a hierarchical file system (think folders in Windows) folders in Windows) Home is like Home is like “My Computer” “My Computer”

Like “My Like “My Documents” Documents”

Like “My Photos”

3 Directories Opening a Directory

• Unix uses a hierarchical file system (think • There is no “double click” folders in Windows) • Must enter for Home is like “My Computer” “double click” aka “open” the command prompt

Like “My Documents”

Like “My Photos”

picture.jpg • Different command for “open” depending on file, program

Location Directories

Type: /home/nmrclass • Unix uses a hierarchical file system (think

and hit enter. Should see OR folders in Windows) Home is like /Users/YourName “My Computer”

Like “My shows “present working directory” or current Documents” location as a path

Like “My similar to: Photos” /MyComputer/MyDocuments/MyPhotos picture.jpg

4 Navigating Directories Navigating Directories

__ “change directory”: move into a folder cd __ “change directory”: move into a folder

ls “list”: see contents of directory “list”: see contents of directory ls __ ls __

Desktop multimodal_poster2.ppt subjects tmp matlab oct08 surfer.log vrfp-savoy-techs

Save Some Anatomy of a Command

Filename Completion

ls Des hit Tab key command -argument1 –argument2 file should seels Desktop hit enter

History command -- hit key should see ls Desktop

5 Anatomy of a Command Directory Contents

• List contents of directory you are in ls lists names of directories/files

ls -a command -argument1 –argument2 file ls -l

ls -lrt command --help

Try:

ls --help

Directory Contents Directory Contents

• List contents of directory you are in • List contents of directory you are in ls lists names of directories/files ls lists names of directories/files ls -a lists hidden files too ls -a lists hidden files too ls -l ls -l lists file details

ls -lrt ls -lrt drwxrwx--- .xdebug_tkmedit .cshrc . user group others

6 Directory Contents Changing Directories

• List contents of directory you are in practice makes a new directory “practice” ls lists names of directories/files ls OR ls -lrt ls -a lists hidden files too pwd should see /home/nmrclass ls -l lists file details

ls -lrt lists recent files last cd practice changes to directory “practice”

pwd should see /home/nmrclass/practice

ls should see Nothing!

Changing Directories Changing Directories

mkdir stuff makes folder “stuff” inside practice ls should see “stuff”

cd stuff change to directory “stuff”

ls

pwd should see /home/nmrclass/practice/stuff

7 Changing Directories Using an Editor

emacs mynotes.txt If using a Mac: pico mynotes.txt

Type: I could write a script in here.

File > Save (Buffer) Ctrl-x if using pico and then ‘Y’ and enter

can also do: ls .. shows one directory up File > emacs cd .. cd ../.. ls ls ../.. goes up two! should see “mynotes.txt”

pwd should see /home/nmrclass/practice

Using an Editor Copying files

is the copy command

cp --help learn all the options or “arguments”

cp mynotes.txt stuff/

cd stuff

ls

mynotes.txt

8 Copying files Copying / Moving files

cp is the copy command Could also use do: cp --help learn all the options or “arguments” cp mynotes.txt myothernotes.txt

cp mynotes.txt stuff/ mynotes.txt myothernotes.txt

cd stuff mv mynotes.txt stuff/

ls

mynotes.txt

Removing Files Removing Files

pwd should be in “stuff” pwd should be in “stuff” ls ls

mynotes.txt rm mynotes.txt

ls ls

cd .. goes to “practice” cd .. goes to “practice”

ls ls

stuff rmdir stuff

ls ls

rm mynotes.txt rm mynotes.txt

9 Removing Files Removing Files pwd should be in “stuff” pwd should be in “practice” ls cd .. goes to “Home” rm mynotes.txt rmdir practice ls

cd .. goes to “practice” ls

ls

rmdir stuff

ls rm mynotes.txt

Review Using FreeSurfer

• no double clicking With FreeSurfer, certain variables must be • a directory set in order to use it correctly: • list contents of directory FREESURFER_HOME • go in and out of a directory and determine tell Operating System where FreeSurfer is current location • make a text file SUBJECTS_DIR • copy files tell FreeSurfer where data is • remove files and directories

10 Required Variables Required Variables

• To use FreeSurfer you’ll have to do: setenv SUBJECTS_DIR /path/to/data

setenv FREESURFER_HOME /home/apps/freesurfer To go to location of your data: tell Operating System where FreeSurfer is cd $SUBJECTS_DIR source $FREESURFER_HOME/SetUpFreeSurfer.csh source this script to get your computer $ means take the value of the variable ready to use FreeSurfer (sources other scripts & sets other variables)

setenv SUBJECTS_DIR /path/to/data

Required Variables $

setenv SUBJECTS_DIR /path/to/data To set a variable: setenv TEST_VARIABLE yourfirstname To go to location of your data: How ‘’ works: cd $SUBJECTS_DIR aka echo Allison is cool. cd /path/to/data

$ means take the value of the variable To check what a variable is set to: echo $TEST_VARIABLE

11 Visualization Tools More Help

• For FreeSurfer visualization tools: http://surfer.nmr.mgh.harvard.edu/fswiki /FsTutorial/CommandLineNavigation tkmedit subj001 T1.mgz -aux wm.mgz

tksurfer subj001 lh inflated Links on Wiki under “Unix Tutorial”

VisualizationTool subject data_file -aux other_data_file Glossary of Unix commands

VisualizationTool subject hemisphere data_file

The End

Good Luck!

12