Skip to content

Instantly share code, notes, and snippets.

@duksis
Last active March 26, 2025 07:37
Show Gist options
  • Save duksis/64de5d7c3c59087b8ae763ad7163df4f to your computer and use it in GitHub Desktop.
Save duksis/64de5d7c3c59087b8ae763ad7163df4f to your computer and use it in GitHub Desktop.
Unix cheat sheet

Add your ssh key to a remote server

ssh-copy-id user@remote

Copy files from one remote to another

scp user@source:/path/to/file user@target:/path/to/file

Add a trusted CA (Ubuntu)

Copy your certificate in PEM format (the format that has ----BEGIN CERTIFICATE---- in it) into /usr/local/share/ca-certificates and name it with a .crt file extension.

Then run sudo update-ca-certificates

Testing The CA

You can verify if this worked by looking for the certificate that you just added in /etc/ssl/certs/ca-certificates.crt (which is just a long list of all of your trusted CA's concatenated together).

You can also use OpenSSL's s_client by trying to connect to a server that you know is using a certificate signed by the CA that you just installed.

$ openssl s_client -connect foo.whatever.com:443 -CApath /etc/ssl/certs

CONNECTED(00000003)
depth=1 C = US, ST = Virginia, O = "Whatever, Inc.", CN = whatever.com, emailAddress = [email protected]
verify return:1
depth=0 C = US, ST = Virginia, L = Arlington, O = "Whatever, Inc.", CN = foo.whatever.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=Virginia/L=Arlington/O=Whatever, Inc./CN=foo.whatever.com
   i:/C=US/ST=Virginia/O=Whatever, Inc./CN=whatever.com/[email protected]

... snip lots of output ...

    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1392837700
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

The first thing to look for is the certificate chain near the top of the output. This should show the CA as the issuer (next to i:). This tells you that the server is presenting a certificate signed by the CA you're installing.

Second, look for the verify return code at the end to be set to 0 (ok).

Docker

Check resource usage

docker system df && docker system df -v

docker containers and their size

docker ps --size

Ubuntu system

print 10 larges folders sorted by size

du -shx * | sort -rh | head -10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment