# Aliases

This page documents the command aliases defined in the DMK (Database Management Kit) environment configuration. These aliases are shortcuts designed to simplify frequent navigation and command execution for MongoDB administration tasks.

#### Global Aliases (`[GLOBAL]`)

These aliases are independent of any specific MongoDB instance.

| Alias     | Description                                                           | Definition                                    | Usage                                                                                            |
| --------- | --------------------------------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `dmk`     | Load DMK environment                                                  | `. ${DMK_HOME}/bin/dmk.sh`                    | `dmk` to setup basic environment, `dmk <instance_name>` for a specific instance.                 |
| `vilst`   | Edit the MongoDB instances list file (`mongodb.lst`).                 | `vi ${MONGO_BASE}/etc/mongodb.lst`            |                                                                                                  |
| `dmkc`    | View the default DMK configuration file (read-only).                  | `vi -R ${DMK_HOME}/etc/dmk.conf.default`      |                                                                                                  |
| `dmkl`    | Edit the local DMK configuration file.                                | `vi ~/.dmk/dmk.conf.local`                    |                                                                                                  |
| `cdb`     | Change directory to the MongoDB base directory.                       | `cd ${MONGO_BASE}`                            |                                                                                                  |
| `cde`     | Change directory to the MongoDB configuration directory.              | `cd ${MONGO_BASE}/etc`                        |                                                                                                  |
| `cdh`     | Change directory to the MongoDB home directory (`MONGO_HOME`).        | `cd ${MONGO_HOME}`                            |                                                                                                  |
| `cdd`     | Change directory to the DMK tool installation directory (`DMK_HOME`). | `cd ${DMK_HOME}`                              |                                                                                                  |
| `cdml`    | Change directory to the MongoDB global log directory.                 | `cd ${MONGO_LOG_ROOT}`                        |                                                                                                  |
| `sta`     | Show all MongoDB instances status in a table.                         | `${DMK_HOME}/bin/dmk_status.py --all`         |                                                                                                  |
| `lsta`    | Show one or more MongoDB instance status in a list.                   | `${DMK_HOME}/bin/dmk_status.py --list`.       | `lsta` (current instance), `lsta -a` (all instances), `lsta -i mdb01,mdb02`                      |
| `tsta`    | Show one or more MongoDB instance status in a table.                  | `${DMK_HOME}/bin/dmk_status.py --table`       | `tsta` (current instance), `tsta -a` (all instances, equivalent to `sta`), `tsta -i mdb01,mdb02` |
| `rsta`    | Show one or more MongoDB instance replica set status.                 | `${DMK_HOME}/bin/dmk_status.py --replica_set` | `rsta` (current instance), `rsta -a` (all instances), `rsta -i mdb01,mdb02`                      |
| `dmkhelp` | Display DMK help documentation file (`dmkhelp.lst`).                  | `cat ${DMK_HOME}/docs/dmkhelp.lst`            |                                                                                                  |
| `f`       | Run the `fsdisc.sh -r` script (specific to dbi services).             | `fsdisc.sh -r`                                |                                                                                                  |
| `c`       | Clear the terminal screen.                                            | `clear`                                       |                                                                                                  |
| `ll`      | List files in long format.                                            | `ls -l`                                       |                                                                                                  |
| `psg`     | Search for processes (excluding the `grep` command itself).           | `ps -ef \| grep`                              |                                                                                                  |

***

#### Instance-Specific Aliases (`[INSTANCE]`)

These aliases depend on the current MongoDB instance (via `MONGO_INSTANCE`).

| Alias       | Description                                                                   | Definition                                                            |
| ----------- | ----------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| `vic`       | Edit the MongoDB instance configuration file with `vi`.                       | `vi ${MONGO_BASE}/admin/${MONGO_INSTANCE}/etc/${MONGO_INSTANCE}.conf` |
| `cdc`       | Open the MongoDB instance configuration directory.                            | `cd ${MONGO_BASE}/admin/${MONGO_INSTANCE}/etc`                        |
| `vil`       | View the MongoDB instance log file with `vi -R` (read only).                  | `vi -R ${MONGO_LOG_ROOT}/${MONGO_INSTANCE}/${MONGO_INSTANCE}.log`     |
| `tal`       | Tail the MongoDB instance log file with `tail -f`.                            | `tail -f ${MONGO_LOG_ROOT}/${MONGO_INSTANCE}/${MONGO_INSTANCE}.log`   |
| `cdl`       | Change directory to the instance-specific log folder.                         | `cd ${MONGO_LOG_ROOT}/${MONGO_INSTANCE}`                              |
| `cda`       | Change directory to the MongoDB admin folder for the instance.                | `cd ${MONGO_BASE}/admin/${MONGO_INSTANCE}`                            |
| `ms`        | Open a `mongosh` session connected via the instance URI.                      | `${MONGO_HOME}/bin/mongosh ${MONGO_URI}`                              |
| `msp`       | Open `mongosh` using credentials parsed from the instance's `cred.yaml` file. | `ms` + credentials                                                    |
| `mgstart`   | Start the MongoDB instance using `dmk_db_ctl.py`.                             | `${DMK_HOME}/bin/dmk_db_ctl.py -a start -i ${MONGO_INSTANCE}`         |
| `mgstop`    | Stop the MongoDB instance using `dmk_db_ctl.py`.                              | `${DMK_HOME}/bin/dmk_db_ctl.py -a stop -i ${MONGO_INSTANCE}`          |
| `mgrestart` | Restart the MongoDB instance using `dmk_db_ctl.py`.                           | `${DMK_HOME}/bin/dmk_db_ctl.py -a restart -i ${MONGO_INSTANCE}`       |
