<< previous | top of page | table of contents | next >> |
Below is a list of commands that are very commonly used. Of these, cd and ls are essential to using the command line, and you should be familiar with them.
Each command has a syntax line, which gives a brief description of how it should be used. The first item on the line is always the name of the command, followed by a number of arguments. Arguments given in square brackets are optional and can be omitted. If an argument is followed by three dots ('...'), it means that any number of that type of argument can be provided, and each will be processed in turn. In addition, any options that are of particular interest are listed in the corresponding section for each command. Each part of the command syntax is highlighted using the different styles outlined in the options section.
top of page | table of contents |
> pwd
Print the current working directory onto the screen.
top of page | table of contents |
> cd [folder]
Change the current working directory. If no folder is specified, the current working directory will be set to the home folder. Otherwise, it will be set to folder, assuming that it is a valid path.
top of page | table of contents |
> ls [option]... [target]...
List files. If no target is specified, the contents of the current working directory are listed. Otherwise, the files specified are listed in the order provided, assuming that they are valid paths. If a target is a folder, its contents will be listed.
top of page | table of contents |
> cp [option]... source target
> cp [option]... source... folder
In its first form, copy the file source to create the file target, assuming both are valid paths. You should be aware that in general, if the file target already exists, it will be overwritten (although in MR2, the systems have been set up to ask for confirmation first).
The second form is used to copy one or more source files into the target folder. In this case, target must be a pre-exising folder. Each newly created file will have the same base name as the original.
top of page | table of contents |
> mv [option]... source target
> mv [option]... source... folder
In its first form, move or rename the file (or folder) source to target, assuming both are valid paths. Note that renaming is essentially equivalent to moving the file to a different location, if source and target reside in different folders.
The second form is used to move one or more source files into the target folder. In this case, target must be a pre-existing folder.
top of page | table of contents |
Below are some examples of commands in typical use, illustrating some of the concepts explained in this document. To fully understand the examples, you may need to refer back to the sections on specifying filenames, using special filenames, or using wildcards.
To change your current working directory to its parent folder (move one branch down the directory tree):
> cd ..
To change your current working directory from whatever it was to the data folder in your home directory:
> cd ~/data
To list the headers for all normalised smoothed SPM images (assumed to start with ns and end with .hdr) from the controls folder:
> ls controls/ns*.hdr
To move the file data.mat, residing in the current working directory, into the parent folder of that directory:
> mv data.mat ..
To copy the file info.txt from the folder important into the current working directory:
> cp important/info.txt .
To copy all SPM header files from the data folder in your home directory into the headers folder in the current working directory:
> cp ~/data/*.hdr headers
To copy all Siemens Vision images for study 3 of patient Joe Bloggs into the current working directory:
> cp /MR2/scantmp/vision/bloggsj_010203_123/*-3-*.ima .
<< previous | top of page | table of contents | next >> |