DevOps Commands Sheet
DevOps Commands Sheet
Networking Commands
System Monitoring
Package Management
11.git branch
Lists branches or creates a new branch.
Example: git branch feature-branch
12.git checkout
Switches between branches or restores files.
Example: git checkout feature-branch
13.git switch
Switches branches (modern alternative to git checkout).
Example: git switch feature-branch
14.git merge
Combines changes from one branch into another.
Example: git merge feature-branch
15.git rebase
Moves or combines commits from one branch onto another.
Example: git rebase main
16.git cherry-pick
Applies specific commits from one branch to another.
Example: git cherry-pick <commit-hash>
Remote Repositories
17.git remote
Manages remote repository connections.
Example: git remote add origin https://github.com/user/repo.git
18.git push
Sends changes to a remote repository.
Example: git push origin main
19.git pull
Fetches and merges changes from a remote repository.
Example: git pull origin main
20.git fetch
Downloads changes from a remote repository without merging.
Example: git fetch origin
21.git remote -v
Lists the URLs of remote repositories.
Example: git remote -v
22.git stash
Temporarily saves changes not yet committed.
Example: git stash
23.git stash pop
Applies stashed changes and removes them from the stash list.
Example: git stash pop
24.git stash list
Lists all stashes.
Example: git stash list
25.git clean
Removes untracked files from the working directory.
Example: git clean -f
Tagging
26.git tag
Creates a tag for a specific commit.
Example: git tag -a v1.0 -m "Version 1.0"
27.git tag -d
Deletes a tag.
Example: git tag -d v1.0
28.git push --tags
Pushes tags to a remote repository.
Example: git push origin --tags
Advanced Commands
29.git bisect
Finds the commit that introduced a bug.
Example: git bisect start
30.git blame
Shows which commit and author modified each line of a file.
Example: git blame file.txt
31.git reflog
Shows a log of changes to the tip of branches.
Example: git reflog
32.git submodule
Manages external repositories as submodules.
Example: git submodule add https://github.com/user/repo.git
33.git archive
Creates an archive of the repository files.
Example: git archive --format=zip HEAD > archive.zip
34.git gc
Cleans up unnecessary files and optimizes the repository.
Example: git gc
GitHub-Specific Commands
28.docker-compose up
Starts services defined in a docker-compose.yml file.
Example: docker-compose up
29.docker-compose down
Stops and removes services defined in a docker-compose.yml file.
Example: docker-compose down
30.docker-compose logs
Displays logs for services managed by Docker Compose.
Example: docker-compose logs
31.docker-compose exec
Runs a command in a service’s container.
Example: docker-compose exec service_name bash
32.docker save
Exports an image to a tar file.
Example: docker save -o my_image.tar my_image:tag
33.docker load
Imports an image from a tar file.
Example: docker load < my_image.tar
34.docker export
Exports a container’s filesystem as a tar file.
Example: docker export container_name > container.tar
35.docker import
Creates an image from an exported container.
Example: docker import container.tar my_new_image
36.docker system df
Displays disk usage by Docker objects.
Example: docker system df
37.docker system prune
Cleans up unused Docker resources (images, containers, volumes, networks).
Example: docker system prune
38.docker tag
Assigns a new tag to an image.
Example: docker tag old_image_name new_image_name
39.docker push
Uploads an image to a Docker registry.
Example: docker push my_image:tag
40.docker login
Logs into a Docker registry.
Example: docker login
41.docker logout
Logs out of a Docker registry.
Example: docker logout
42.docker swarm init
Initializes a Docker Swarm mode cluster.
Example: docker swarm init
43.docker service create
Creates a new service in Swarm mode.
Example: docker service create --name my_service nginx
44.docker stack deploy
Deploys a stack using a Compose file in Swarm mode.
Example: docker stack deploy -c docker-compose.yml my_stack
45.docker stack rm
Removes a stack in Swarm mode.
Example: docker stack rm my_stack
46.docker checkpoint create
Creates a checkpoint for a container.
Example: docker checkpoint create container_name checkpoint_name
47.docker checkpoint ls
Lists checkpoints for a container.
Example: docker checkpoint ls container_name
48.docker checkpoint rm
Removes a checkpoint.
Example: docker checkpoint rm container_name checkpoint_name
11.kubectl apply
Applies changes defined in a YAML file.
Example: kubectl apply -f deployment.yaml
12.kubectl delete
Deletes resources defined in a YAML file.
Example: kubectl delete -f deployment.yaml
13.kubectl scale
Scales a deployment to the desired number of replicas.
Example: kubectl scale deployment my-deployment --replicas=3
14.kubectl expose
Exposes a pod or deployment as a service.
Example: kubectl expose deployment my-deployment
--type=LoadBalancer --port=80
15.kubectl exec
Executes a command in a running pod.
Example: kubectl exec -it pod-name -- /bin/bash
16.kubectl port-forward
Forwards a local port to a port in a pod.
Example: kubectl port-forward pod-name 8080:80
17.kubectl get configmaps
Lists all ConfigMaps in the namespace.
Example: kubectl get configmaps
18.kubectl get secrets
Lists all Secrets in the namespace.
Example: kubectl get secrets
19.kubectl edit
Edits a resource definition directly in the editor.
Example: kubectl edit deployment my-deployment
20.kubectl rollout status
Displays the status of a deployment rollout.
Example: kubectl rollout status deployment/my-deployment
15.helm create
Creates a new Helm chart in a specified directory.
Example: helm create my-chart
16.helm lint
Lints a chart to check for common errors.
Example: helm lint ./my-chart
17.helm package
Packages a chart into a .tgz file.
Example: helm package ./my-chart
18.helm template
Renders the Kubernetes YAML files from a chart without installing it.
Example: helm template my-release ./my-chart
19.helm dependency update
Updates the dependencies in the Chart.yaml file.
Example: helm dependency update ./my-chart
20.helm rollback
Rolls back a release to a previous version.
Example: helm rollback my-release 1
21.helm history
Displays the history of a release.
Example: helm history my-release
22.helm get all
Gets all information (including values and templates) for a release.
Example: helm get all my-release
23.helm get values
Displays the values used in a release.
Example: helm get values my-release
24.helm test
Runs tests defined in a chart.
Example: helm test my-release
50. terraform --help = Displays general help for Terraform CLI commands.
51. terraform init = Initializes the working directory containing Terraform configuration
files. It downloads the necessary provider plugins.
52. terraform validate = Validates the Terraform configuration files for syntax errors or
issues.
53. terraform plan - Creates an execution plan, showing what actions Terraform will
perform to make the infrastructure match the desired configuration.
54. terraform apply = Applies the changes required to reach the desired state of the
configuration. It will prompt for approval before making changes.
56. terraform output = Displays the output values defined in the Terraform
configuration after an apply.
58. terraform refresh = Updates the state file with the real infrastructure's current state
without applying changes.
59. terraform taint = Marks a resource for recreation on the next apply. Useful for
forcing a resource to be recreated even if it hasn't been changed.
61. terraform state = Manages Terraform state files, such as moving resources
between modules or manually
64. terraform providers = Lists the providers available for the current Terraform
configuration.
65. terraform state list = Lists all resources tracked in the Terraform state file.
66. terraform backend = Configures the backend for storing Terraform state remotely
(e.g., in S3, Azure Blob Storage, etc.).
67. terraform state mv = Moves an item in the state from one location to another.
68. terraform state rm = Removes an item from the Terraform state file.
69. terraform workspace = Manages Terraform workspaces, which allow for creating
separate environments within a single configuration.
71. terraform module = Manages and updates Terraform modules, which are reusable
configurations.
72. terraform init -get-plugins=true = Ensures that required plugins are fetched and
available for modules.
73. TF_LOG = Sets the logging level for Terraform debug output (e.g., TRACE, DEBUG,
INFO, WARN, ERROR).
75. terraform login = Logs into Terraform Cloud or Terraform Enterprise for managing
remote backends and workspaces.
76. terraform remote = Manages remote backends and remote state storage for
Terraform configurations.