Development Environment / Linux Commands
This documentation provides a summary of useful Linux commands that may be used during StateMod development.
Introduction
The StateMod development environment uses MinGW, which provides a Linux environment within Windows desktop. The MinGW environment is provided as a command line terminal window that displays a prompt and responds to typed commands. Use the Windows Start / MSYS2 / MINGW64 menu to open a window to run Linux commands.
Links to internet documentation are provided in the following.
Shell Scripts
In addition to commands, the StateMod development environment makes use of shell scripts for bash
and sh
command "shells".
These scripts typically have extension .bash
and .sh
to avoid confusion with other Windows files,
but the file extension is not required by Linux.
Programs to run are located by checking the PATH
environment variable.
This concept is similar on Windows and Linux.
To display the PATH
, type:
echo $PATH
or, to see all environment variables:
printenv
If a program or shell script to be run is not found in the PATH
,
it can be run by typing the relative or full path to the file.
If the file is in the current folder,
it may be necessary to run with ./scriptname
because the current folder (.
) is often not included in the PATH
for security reasons.
Linux Command Summary
The following table lists common commands that are used during development.
Some commands are built into the shell program and others are separate programs.
Some commands (e.g., cygpath
) are available in MinGW and Git Bash environments but will not be available in full Linux environments).
Linux provides many commands to perform common tasks.
Commands may operate on more than one file, specified as multiple file separated by spaces or use *
as wildcard in names.
Click on the command name below for additional documentation.
Linux Programs used in the StateMod Development Environment
Linux Command | Similar in Windows | Description |
---|---|---|
cat |
type |
Print the contents of a file, for example: cat filenme |
cd |
cd |
Change directory (folder), for example:
|
clear |
cls |
Clear the terminal of output, useful when want to start a clean sequence of commands. |
cygpath |
cygpath |
Convert between Linux and Windows file paths, for example:
|
ls |
dir |
List files, for example:
|
mkdir |
mkdir |
Make a new directory (folder), for example: mkdir newfolder |
pwd |
cd |
Print the present working directory (folder). Although the prompt often shows the directory, it may only show part of the full path. |
rm |
del |
Remove one or more files, for example: rm *.log |
rmdir |
rmdir |
Remove one or more directories (folders), for example: rmdir folder |
which |
where |
Find where a program exists on the system by searching the PATH environment variable, for example: which gfortran |