Informatique

CURL

Set up Host header

1
curl -H 'Host: example.com' http://203.0.113.10/path
curl --resolve example.com:443:203.0.113.10 https://example.com/path

As telnet

1
curl -v telnet://10.26.4.124:30984

LVM

scan des lvm

1
# lvscan 
  inactive          '/dev/lvm2/root' [3.47 GiB] inherit
  ACTIVE            '/dev/lvm/data' [1.80 TiB] inherit

activer un volume inactif

1
# lvchange -y /dev/lvm2/root

activer tous les volumes inactifs

1
# lvchange -ya

use 100%

1
# lvextend -l 100%FREE /dev/VolGroup00/lv_root

NFS

Troubleshooting

1
Feb 21 10:23:47 nfs-01 systemd[1]: Starting NFS server and services...
Feb 21 10:23:48 nfs-01 rpc.nfsd[15655]: error starting threads: errno 12 (Cannot allocate memory)


sync && echo 3 > /proc/sys/vm/drop_caches

date

1
date  --date="STRING"
date  --date="next Friday"
date  -d "2 days ago"
date  --date="yesterday"
date  --date="yesterday" +"%format"
# Get yesterday's date in dd-mm-yy format
date  --date="yesterday" +"%d-%m-%y"
date  -d "yesterday" +"%m-%d-%y" # US date format
date  --date="yesterday" +"%Y-%m-%d" # YYYY-mm-dd format
## store y'day date in a shell variable called yday and display it ##
yday=$(date  --date="yesterday" +"%Y-%m-%d")
echo "$yday"


date -d 'now -20 hours'

read timestamp

1
date -d @1674634504
mercredi 25 janvier 2023, 09:15:04 (UTC+0100)

Keystore

Java Keytool Commands for Creating and Importing
These commands allow you to generate a new Java Keytool keystore file, create a CSR, and import certificates. Any root or intermediate certificates will need to be imported before importing the primary certificate for your domain.

Generate a Java keystore and key pair

1
keytool -genkey -alias mydomain -keyalg RSA -keystore keystore.jks  -keysize 2048

Generate a certificate signing request (CSR) for an existing Java keystore

1
keytool -certreq -alias mydomain -keystore keystore.jks -file mydomain.csr

Import a root or intermediate CA certificate to an existing Java keystore

1
keytool -import -trustcacerts -alias root -file Thawte.crt -keystore keystore.jks

Import a signed primary certificate to an existing Java keystore

1
keytool -import -trustcacerts -alias mydomain -file mydomain.crt -keystore keystore.jks

Generate a keystore and self-signed certificate (see How to Create a Self Signed Certificate using Java Keytoolfor more info)

1
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048

Java Keytool Commands for Checking
If you need to check the information within a certificate, or Java keystore, use these commands.

Check a stand-alone certificate

1
keytool -printcert -v -file mydomain.crt

Check which certificates are in a Java keystore

1
keytool -list -v -keystore keystore.jks

Check a particular keystore entry using an alias

1
keytool -list -v -keystore keystore.jks -alias mydomain

Other Java Keytool Commands
Delete a certificate from a Java Keytool keystore

1
keytool -delete -alias mydomain -keystore keystore.jks

Change a Java keystore password

1
keytool -storepasswd -new new_storepass -keystore keystore.jks

Export a certificate from a keystore

1
keytool -export -alias mydomain -file mydomain.crt -keystore keystore.jks

List Trusted CA Certs

1
keytool -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts

Import New CA into Trusted Certs

1
keytool -import -trustcacerts -file /path/to/ca/ca.pem -alias CA_ALIAS -keystore $JAVA_HOME/jre/lib/security/cacerts

COUCHDB

Healthcheck

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_up  | jq

List all databases

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_all_dbs  | jq

Database info

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/<db>  | jq

List all docs from a database

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/<db>/_all_docs  | jq

Info from a doc

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/<db>/<id_doc>  | jq

Restart

1
# curl -s -X POST -H"Content-Type: application/json" -u $COUCHDB_USER:$COUCHDB_PASSWORD localhost:5984/_node/couchdb@<node_name>/_restart

List member of a cluster

1
# curl -s http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_membership  | jq

add member

1
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD -X PUT "http://localhost:5986/_nodes/couchdb@<node_name>" -d {}

get rev

1
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD  "http://localhost:5986/_nodes/couchdb@<node_name>"

del member

1
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD -X DELETE "http://localhost:5986/_nodes/couchdb@<node_name>?rev=1-967a00dff5e02add41820138abb3284d"

set/unset maintenance mode

1
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD -X PUT -H "Content-type: application/json" localhost:5984/_node/couchdb@<node_name>/_config/couchdb/maintenance_mode -d "\"false\""

Show config

1
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD -X GET -H "Content-type: application/json" localhost:5984/_node/couchdb@<node_name>/_config/couchdb
# curl -s -u $COUCHDB_USER:$COUCHDB_PASSWORD -X GET -H "Content-type: application/json" localhost:5984/_node/couchdb@<node_name>/_config

Force db syn

1
# curl -s -X POST -H"Content-Type: application/json" -u $COUCHDB_USER:$COUCHDB_PASSWORD localhost:5984/<db>/_sync_shards

ip

  • show ip

    1
    ip -4 addr show
    ip -4 -o addr show
  • set up ip

    1
    ip addr add 192.168.50.2/24 dev ens160
  • unset ip

    1
    ip addr del 192.168.1.5/24 dev eth0
  • link up

    1
    ip link set eth0 up
  • link down

    1
    ip link set eth0 down
  • add default gw

    1
    ip route add default via 192.168.1.1
  • add gw

    1
    ip route add 10.0.0.0/8 dev eth0

XFS

get info

1
~# xfs_info /mnt/plop

check fragmentation

1
~# xfs_db -r -c 'frag' /dev/plop

defrag

1
~# xfs_fsr

repair

1
~# xfs_repair (-L) -m 20480 /dev/plop

( flush cache)

1
~# echo 1 > /proc/sys/vm/drop_caches
~# echo 2 > /proc/sys/vm/drop_caches