Useful linux commands
linux bash shellssh
- copy a remote file to localhost using scp, run on localhost
scp me@somewhere:/var/www/html/00000001.jpg ~/Documents/
- show the linux flavor of localhost
cat /etc/*release
misc tips & tricks
- if a docker images is not available because you are behind a firewall in production:
pull the image on a different machine: docker pull jboss/keycloak:6.0.1 save it to a binary: docker save -o keycloak_601_image.tar jboss/keycloak:6.0.1 transfer it to production and load it into docker: docker load -i keycloak_601_image.tar
- basic docker commands
shutdown with docker-compose: docker-compose down --remove-orphans rebuild and boot containers: docker-compose up --build -d check logs: docker-compose logs --follow get the name of the existing container docker ps connect to a docker container: docker exec -it keycloak /bin/sh docker exec -it nginx /bin/sh get network info: docker network ls docker network connect to invoice-service docker exec -it invoice-service /bin/sh show running docker instances docker ps show logs docker-compose logs shutdown docker-compose down startup docker-compose up (this does not rebuild the images!) rebuild images docker-compose build startup as deamon docker-compose up -d cleanup volumes docker volume rm keycloak_keycloak_data docker volume rm keycloak_keycloak_postgresql docker volume rm keycloak_keycloak_postgresql_data stream logs to stdout docker logs --follow inspect volume docker volume inspect kundenportal_keycloak_data
- ansible
deploy containers on online-atomic ansible-playbook ./setup-online-atomic.yml
deploy containers on online-esb ansible-playbook ./setup-esb-atomic.yml
- working inside a container:
add additional tools: apk add busybox-extras apk add iptables apk add openssl listen on ports: nc -lv -p 5060 nc -lv -p 443
- keycloak certs: (see: https://hub.docker.com/r/jboss/keycloak/)
create a key: openssl genrsa 2048 > tls.key create a cert (make sure CN is hostname) openssl req -new -x509 -nodes -sha1 -days 365 -key tls.key -out tls.crt import cert into a truststore: keytool -importcert -file certificate.cer -keystore keystore.jks list keys in truststore: keytool -keystore /etc/ssl/certs/java/cacerts -storepass changeit -list download cert from site: echo -n | openssl s_client -connect portal.netcom-bw.de:443 > keycloak.cert import cert into a truststore: keytool -import -file keycloak.cert -alias keycloak -keystore keycloak.jks -storepass changeit
- postgress commands
connect to invoice-db docker exec -it invoice-db /bin/sh logon to postgres psql invoice invoice psql keycloak keycloak show all rows select * from invoice; select count(*) from invoice; show all tables SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name; show available documents select * from invoice where mime_type is not null; empty table delete from invoice where 1=1; descript a table structure invoice=# \d invoice; drop a constraint invoice=# alter table invoice drop constraint unique_invoice_number_type; exit posgres \q
keycloak=# select * from realm_smtp_config where value = ''; realm_id | value | name ----------------------------------------- kundenportal | | replyToDisplayName kundenportal | | ssl master | | ssl (3 rows)
keycloak=# delete from realm_smtp_config where value = ''; DELETE 3