Skip to content

Instantly share code, notes, and snippets.

View mhadidg's full-sized avatar

Mustapha Hadid mhadidg

View GitHub Profile
@mhadidg
mhadidg / apt-manually-installed.sh
Created September 13, 2025 15:49
List only truly manually installed APT packages on Debian/Ubuntu (exclude auto-installed dependencies)
apt-mark showmanual \
| sort -u \
| xargs -r -n1 sh -c \
'LC_ALL=C aptitude -q=2 why "$0" 2>/dev/null | grep -q "Manually installed" && echo "$0"'
@mhadidg
mhadidg / curl-post-examples.md
Last active March 15, 2024 13:43
curl POST examples

Simple HTTP POST request

The simplest use of curl for a POST request is with the -d or --data flag followed by the data to be sent. This sends an HTTP POST request with the specified data to the provided URL:

curl -d "param1=value1&param2=value2" -X POST http://localhost:3000/data

-X POST explicitly specifies a POST request, but it's optional when using -d or --data since curl defaults to POST when data is provided.

@mhadidg
mhadidg / detect-tls-versions
Last active June 13, 2023 15:01
Detect supported TLS/SSL versions for a host
nmap --script ssl-enum-ciphers -p 443 www.google.com
// or (public host only)
https://www.cdn77.com/tls-test
@mhadidg
mhadidg / docker-clear-logs.sh
Last active April 8, 2019 09:17
Clear Docker Logs for all Containers
#!/bin/bash
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
@mhadidg
mhadidg / find-jar-by-class
Last active January 30, 2019 08:16
Find JARs that provides a specific class
find path/to/libs -name '*.jar' -exec grep -Hls ClassName {} \;
# source: https://stackoverflow.com/a/1343026/5631308
@mhadidg
mhadidg / dpkg-list-files
Last active June 29, 2018 15:07
List file(s) of installed package (dpkg)
#!/bin/bash
dpkg-query -L $1
@mhadidg
mhadidg / list-by-size.sh
Created June 26, 2018 13:14
List all files of directory recursively ordered by size
find ~/Downloads/ -type f -print0 | xargs -0 du -h | sort -rh | head -n 30
# Author: https://unix.stackexchange.com/questions/53737/how-to-list-all-files-ordered-by-size#comment493469_53738
@mhadidg
mhadidg / docker-volume-backup.sh
Last active June 25, 2018 13:14
Backup and restore Docker volumes
# Backup
docker run --rm --volumes-from container_id -v $(pwd):/backup ubuntu:18.04 tar cvf /backup/file.bak.tar /path/to/volume
ls # file.bak.tar
# Restore
docker run --rm --volumes-from container_id -v $(pwd):/backup ubuntu:18.04 bash -c "cd /path/to/volume && tar xvf /backup/file.bak.tar --strip 3"
# Example for MySQL database
docker run --rm --volumes-from mysql -v $(pwd):/backup ubuntu:18.04 tar cvf /backup/db.bak.tar /var/lib/mysql
docker run --rm --volumes-from mysql -v $(pwd):/backup ubuntu bash -c "cd /var/lib/mysql && tar xvf /backup/db.bak.tar --strip 3"
@mhadidg
mhadidg / update-images.sh
Last active June 13, 2018 07:29 — forked from ColinLeverger/update-images.sh
Update all Docker images
docker images | grep -v REPOSITORY | awk '{print $1":"$2}' | xargs -L1 docker pull
@mhadidg
mhadidg / bash-cheatsheet.sh
Created June 10, 2018 08:51 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04