BASIC LINUX COMMANDS These are a few useful Linux terminal commands (independent of shell type): ls : list contents of dir (short format, alphabetical) ls -l, ll : list contents of dir (long format, alphabetical) ls -ltr : list contents of dir (long format, time-reversed--newest last) cd NAME : change dir, "down" into NAME ("NAME" can be single dir or a path) cd .. : change dir, "up" to parent dir cd - : change dir, jump back to previous dir cd : change dir, jump to user home dir pwd : display present working dir ~ : ("tilde") abbreviation for user home dir, same as $HOME cat NAME : display contents of NAME (likely a text file) in the terminal (just a dump of text, no paging) less NAME : display contents of NAME (likely a text file) in the terminal (with paging, scrolling, searching, etc.) NB: type 'q' to quit this, 'h' for help up arrow : display previous command, e.g. to re-run or edit and run; can be hit repeatedly to go through command history history : display record of all commands run in the terminal; can save it to a text file with redirect: history > FILE.txt echo $0 : display current shell ('-' out front means it is the login shell) ... and see afni00_unix.pdf for more Linux commands and shell notes. *Also note:* Tab-autocompletion helps a lot when using the terminal. Directory, file, command and/or option names can be long and complicated. Hit Tab often as you type, to either partially or fully complete strings: + Hit Tab once to autocomplete as far as uniquely possible. + Hit Tab a few times to be presented with possible completions if more than one exists. ------------------------------------------------------------------------------- OPENING FILES FROM THE TERMINAL The following are commands to open text and other kinds of file. AFNI contains some commands that work on any operating system (OS). Feel free to use these, or any equivalent commands (we provide some common but OS-specific programs, too, that may depend on the user's setup): + Open a text file NAME (e.g., *.txt, *.dat, *.1D) in a text editor: any OS : afni_open -e NAME macOS : open -t NAME linux : gedit NAME + Open an image NAME (e.g., JPG, PNG, etc.) in a viewer: any OS : aiv NAME macOS : open NAME linux : eog NAME + Open a PDF NAME.pdf: any OS : afni_open NAME.pdf macOS : open NAME.pdf linux : evince NAME.pdf + Open an HTML file NAME.html in a web browser: any OS : afni_open -b NAME.html macOS : open NAME.html linux : firefox NAME.html NB: When opening one or more APQC HTML files specifically, use: open_apqc.py -infiles FILE1.html [FILE2.html FILE3.html ...] ------------------------------------------------------------------------------- THE HELPFUL WILDCARD CHARACTER Wildcards can be useful with Linux commands, particularly with 'ls'. * : a wildcard that can be filled by 0, 1 or more characters ls *.pdf -> list any file ending in ".pdf", like: FILE.pdf, 1.pdf, .pdf, ... but not: .pdf.jpg, FILE.pdf2, FILE.PDF, ... ls sub-*.nii.gz -> list any zipped NIFTIs starting with "sub-", like: sub-001.nii.gz, sub-7654321.nii.gz, ... but not unzipped NIFTI files: sub-001.nii, sub-7654321.nii, ... ls sub-*.nii* -> list any NIFTI files that start with "sub-", like: sub-101.nii, sub-101.nii.gz, ... but not: part-101.nii, sub-101.json, sub-101.HEAD, ... ? : a wildcard that is filled by exactly one character ls sub-00?.nii -> list any unzipped NIFTI file with three characters in the label like: sub-000.nii, sub-001.nii, sub-009.nii, sub-00b.nii, ... but not: sub-00.nii, sub-0000.nii, ... ls sub-???.nii -> list any unzip NIFTI file that has three characters after 'sub-', like: sub-000.nii, sub-101.nii, sub-999.nii, sub-ABC.nii, ... but not: sub-0.nii, sub-1a2b3c.nii, ...