The following kills all processes (in ubuntu) which match the word ‘test123’;
kill $(ps aux | grep test123 | awk '{print $2}')
The ramblings of a software developer
The following kills all processes (in ubuntu) which match the word ‘test123’;
kill $(ps aux | grep test123 | awk '{print $2}')
If something gets committed to a GIT repo, the following command can be run to reverse it;
$ git reset HEAD~
Eg;
$ git commit -m "Something terribly misguided" # (1) $ git reset HEAD~ # (2) << edit files as necessary >> # (3) $ git add ... # (4) $ git commit -c ORIG_HEAD # (5)
If the commit has already been pushed to your external repo, you’ll need to add ‘–force’ next time you push if the commit is rejected (the repo is probably going to be ‘ahead’ of the commit you’re trying to push to it);
$ git push origin master --force
Ref; https://stackoverflow.com/questions/927358/how-to-undo-the-most-recent-commits-in-git
du -h -d 1 .
Ordering this by size can be done by;
du -h -d 1 . | sort -h
Adding ‘r’ in the sort options (… | sort -rh ) will sort it in reverse order (largest at the top)
The following lists the virtual-host configuration for apache2 (in the command-line)
apache2ctl -S
Update “/etc/ssh/sshd_config”
Add;
DebianBanner no
Restart it;
sudo service ssh restart
Ref;
How to Hide OpenSSH Ubuntu version from Nmap and other scanners
Enable headers module in Apace2;
a2enmod headers
In :80 host-entry;
In :443 host-entry;
Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains;"
This means browsers *should* remember that for the next year (31536000 seconds) you’ll have your site accessible via HTTPS
Ref;
To prevent clickjacking, add in the following header as well;
Header always append X-Frame-Options "DENY"
Header always append Content-Security-Policy "frame-ancestors 'none';"
The 2nd line is to cater for older browsers whom don’t support the X-Frame-Options header
Ref;
The resulting :443 conf file will contain;
Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains;" Header always append X-Frame-Options "DENY" Header always append Content-Security-Policy "frame-ancestors 'none';"
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
Ref; https://askubuntu.com/questions/81293/what-is-the-command-to-update-time-and-date-from-internet
To renamed from ‘*.abcd.def’ to ‘*.abc’;
find ./ -depth -name "*.abcd.def" -exec sh -c 'mv "$1" "${1%.abcd.def}.abc"' _ {} \;
When using GIT;
find ./ -depth -name "*.abcd.def" -exec sh -c 'git mv "$1" "${1%.abcd.def}.abc"' _ {} \;
Source; https://askubuntu.com/questions/35922/how-to-change-extension-of-multiple-files-from-command-line
https://help.ubuntu.com/community/SSH/OpenSSH/Keys
http://unix.stackexchange.com/questions/26924/how-do-i-convert-a-ssh-keygen-public-key-into-a-format-that-openssl-pem-read-bio
Generate 4096 bit keys;
ssh-keygen -t rsa -b 4096
Convert to PEM format;
openssl rsa -in ms-test -pubout -outform pem > ms-test.pub-509
So i’m using a standard SSL cert like any other server would have (with a cert for the domain, and intermediate cert)
The following combines the intermediate & server cert into one. Goes in order of your server cert first, followed by intermediate, next intermediate (if needed), etc.
sudo cat my-domain.crt intermediate.crt > cert-chain.txt
These then convert the chain cert & key into a pkcs12 format
openssl pkcs12 -export -inkey my-domain.key -in cert-chain.txt -out my-domain.pkcs12
This then uses the pkcs12 file and imports it into your keystore. I used a new keystore as i’ve only got the one domain on the Jetty server
sudo keytool -importkeystore -srckeystore my-domain.pkcs12 -srcstoretype PKCS12 -destkeystore keystore
These came from a number of Stack Overflow articles (accidentally closed them prior to writing this — sorry guys!)