Hydra Cheat Sheet - by Codelivly

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Hydra Cheat Sheet - by Codelivly

Hydra is a powerful password-cracking tool that can perform rapid dictionary attacks against
more than 50 protocols, including SSH, FTP, HTTP, HTTPS, SMB, pop3, IMAP, and many more.
It’s included in Kali Linux by default.

Category Feature Syntax / Command Description

Installs Hydra via


Basic Setup Install Hydra pip install hydra-core --upgrade
pip.

Decorator to
make a function
Basic Invocation @hydra.main()
configurable by
Hydra.

Specifies the
path to the
Config Path Override @hydra.main(config_path="path/to/conf")
configuration
files directory.

Specifies a
particular
Config Name @hydra.main(config_name="config.yaml")
configuration file
Override to use when
calling the
application.

Manually
initialize Hydra
Initialize Config configuration
hydra.initialize(config_path="path")
without Decorator when not using
the @hydra.main
decorator.

Use Python
dataclasses to
Using Structured
@dataclass create structured
Configs
configuration
with type-safety.

Access a
Working with Access Config in configuration
cfg.<param>
Configs Code parameter in
code using cfg .

Convert Config to cfg = OmegaConf.to_container(cfg) Converts Hydra's


Dictionary cfg object to a
Python
dictionary for

Hydra Cheat Sheet - by Codelivly 1


easier
manipulation.

Access a nested
Access Nested parameter from
cfg.<nested_param>.<sub_param>
Config the configuration
file.

In a config file,
the defaults
keyword allows
Default Config
defaults: composition
Composition
from other
configuration
files or groups.

Append or
Appending/Overriding replace list items
python my_app.py +param=[1,2,3]
Lists in the
configuration.

Dynamically
override a
Override Config from configuration
python my_app.py param=value
Command Line parameter from
the command
line.

Override multiple
python my_app.py param1=value1
Multiple Overrides param2=value2 parameters via
command line.

Replace the
python my_app.py param= values in a list
Override List Items [new_value1,new_value2] from the
command line.

Use YAML
anchors and
Override YAML
&anchor , *alias aliases to reuse
Anchors and Aliases
sections in YAML
config files.

Choose a
configuration
Selecting Config group (e.g.,
Config Groups python my_app.py db=mysql
Groups selecting mysql
configuration in
the db group).

Overriding Multiple python my_app.py db=mysql server=apache Override multiple


Config Groups configuration

Hydra Cheat Sheet - by Codelivly 2


groups in a
single command.

Run a multirun
(grid search),
executing your
Multirun and
Multirun (Grid Search) python my_app.py -m program with
Sweep
multiple
parameter
combinations.

Specify multiple
Specify Multirun values for a
python my_app.py -m param=1,2,3
Values parameter in a
multirun.

Define a custom
output directory
Custom Sweep hydra.sweep.dir=outputs/ for sweep
Directory
outputs during
multiruns.

Control how
Limiting Sweep many multirun
hydra.sweeper.max_batch_size=10
Combinations combinations are
run at once.

Changes the
working
directory for the
Logging and run to a custom
Custom Run Directory hydra.run.dir=outputs/
Output Control directory.
Defaults to a
timestamped
folder.

Configure how
logs are written
Hydra Logging Config hydra/job_logging for jobs,
including custom
logging behavior.

Changes where
Sweep Logging logs are stored
hydra.sweep.dir=logs/
Config during sweep
runs.

Specify custom
Configuring the names for the
hydra.output_subdir=custom_name
Output File Name output
subdirectories.

Hydra Cheat Sheet - by Codelivly 3


Example of using
Hydra plugins for
Plugins and
Using Hydra Plugins hydra.run.dir=slurm:// remote job
Customizations
execution (e.g.,
SLURM).

Integrate custom
Define Custom plugins for
hydra.plugins.<plugin_name>
Plugins extended
functionality.

Manually
initialize Hydra
config in your
Config Manual Config initialize(config_path="path/to/config") program,
Initialization Initialization
required when
not using the
decorator.

Override the task


Specify Overrides configuration
hydra.overrides.task
Path dynamically
during runtime.

Programmatically
load
Programmatic configurations
compose(config_name="config", overrides=
Config Hydra Compose API ["param=value"]) and apply
Composition overrides using
the compose API
in Python.

Show help
message for
Help and available
Hydra Help Command python my_app.py --help
Documentation parameters and
configuration
options.

Displays
command-line
Hydra Command-line python my_app.py -h help with
Multirun Help
multirun
capabilities.

Show verbose
information from
Logging Help python my_app.py hydra.verbose=true Hydra during the
Information
execution
process.

Hydra Cheat Sheet - by Codelivly 4


Load config files
Loading Configs from dynamically
Advanced
Environment hydra.environment.config_path based on
Configuration
Variables environment
variables.

Reference other
configuration
parameters
Using Interpolations ${path.to.some_value} dynamically
in Configs
using
interpolations in
YAML.

Hydra’s
instantiate
function allows
creating
Config Instantiation instantiate(cfg) instances from
config objects
(e.g., initializing
classes from
configurations).

Enable parallel
Optimization
Control Multirun execution for
and hydra.sweeper.search.parallel=true
Concurrency grid search
Performance
(multirun).

Customizes how
Specifying Sweep sweeps are
hydra.sweep.task
Configurations conducted for
different tasks.

Save the outputs


Changing Output Path
Saving Outputs hydra.output_subdir=my_output_dir/ of the run to a
for Runs
custom directory.

Specify custom
Multirun Output Path hydra.sweep.dir=outputs/ directories for
multirun outputs.

Specify
subdirectories to
Save Output for store outputs for
hydra.output_subdir=results/
Multirun Jobs each run during
a multirun
sweep.

This cheatsheet categorizes Hydra's features and provides detailed commands to configure,
manage, and extend Hydra’s functionality.

Hydra Cheat Sheet - by Codelivly 5


Hydra Cheat Sheet - by Codelivly 6

You might also like