Unix Basics
Unix
Unix is an operating system (like Windows).
It uses a command line interface (or command line) where you type commands you want to run into a terminal.
Command line interpreters are called shells (two commonly used ones are bash [Bourne-again shell] and zsh [Z-shell])
Most neuroimaging packages need to be run from a command line
MacOS and Linux have Terminals installed. To use Unix commands on Windows, you would need to install a Terminal emulator, or to enable `Windows Subsystem for Linux (WSL)<https://docs.microsoft.com/en-us/windows/wsl/install>`_ feature.
Note
You can practice using Unix online with JupyterLab (see https://neuroimaging-core-docs.readthedocs.io/en/latest/pages/unix.html for an excellent tutorial).
An excellent tutorial on the use of the Unix Shell is available here.
Basic Unix Commands
pwd
Print Working Directory, tells you the current directory you are incd directory
Change Directory, takes to you the directory specifiedcd ~
Go to home directorycd /
Go to root directoryls
List, lists the contents of the directory you are inls <directory>
lists contents of the specified directoryls -a
lists all files and directories in the directory you are in (including hidden ones which start with an “.” and don’t appear is you just you the “ls” command)ls -l
Long list, lists all files and directory with ownership and user permissionsls -al
Long list (including hidden files and directories)mkdir <name>
creates a directory with that namemkdir .<name>
creates a hidden directory with that namehistory
lists all recently run commands!<number>
re-runs command specified (by number from history list)cp -r <from> <to>
copies a directory from one path to another pathmv <from> <to>
renames a file or directoryrm <file>
deletes a filerm -rf <directory>
deletes a directory
Important Unix Directories
/bin
Where built-in Unix commands (e.g.ls
,mkdir
, etc…) are stored./etc
Where system profiles are stored (e.g. users and passwords)./usr/local/bin
Where user-installed programmes are often stored, unless user specifies a different install location