Homepage
Space Index
|
|||||||||||||||||||||||||||||||
0-9 |
AA List of Useful Commandsphoto_2019-02-13_06-28-37.jpg
|
||||||||||||||||||||||||||||||
BBash tricks & commandsset -e to the top level of script file: exit script if any command fails (non-zero value) exec "$@" to the end of script file will redirect input variables, see more here http://wiki.bash-hackers.org/commands/builtin/exec cd {directory} change directory
|
CChange Timezonesudo dpkg-reconfigure tzdata
|
||||||||||||||||||||||||||||||
D |
E |
||||||||||||||||||||||||||||||
FFind Files Older Than x Days and Show Last Modified Date# -mtime +2 == older than 2 days # -exec executes the following statement on the found files # stat -c with following literal shows filename with the last modified date find * -mtime +2 -exec stat -c "%n %y" {} \; # to zip; find * -mtime +2 -exec tar czvf
|
G |
||||||||||||||||||||||||||||||
HHomepage |
IImporting an Untrusted Certificate into JDK# Copy the certificate into the directory Java_home\Jre\Lib\Security # Change your directory to Java_home\Jre\Lib\Security> # Import the certificate to a trust store. # Here's the import command: keytool -import -alias ca -file somecert.cer -keystore cace
|
||||||||||||||||||||||||||||||
J |
K |
||||||||||||||||||||||||||||||
LLetsencrypt (Free SSL certificate) for tomcat# get letsencrypt bot from git git clone https://github.com/letsencrypt/letsencrypt # execute manual retrieve ./letsencrypt-auto --agree-dev-preview --server https://acme-v01.api.letsencrypt.org/directory certonly -a manual # enter email and domain name(s
List & Sort sizes of current directory (recursively)
du -hs * | sort -h
|
MMonit configuration to monitor unix systems# install first sudo apt-get install monit # setup configuration file sudo vim /etc/monit/monitrc set daemon 120 # check services at 2-minute intervals set logfile /var/log/monit.log set idfile /var/lib/monit/id set statefile /var/lib/monit/state # set ma
Monitor disk space and send mail
Install mailx for mail sending sudo apt-get install heirloom-mailx Create disk space monitoring script (alerts for disk usages over 80%) #!/bin/sh df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do echo $output
|
||||||||||||||||||||||||||||||
N |
O |
||||||||||||||||||||||||||||||
P |
Q |
||||||||||||||||||||||||||||||
RRemove Files With 0 Byte File Size# Use the Find command to find files by size and print file names to standard output. find . -type f -size 0b -print # Substitute -print with -delete to delete the files rather than print them on screen. find . -type f -size 0b -delete
|
SSetting bash as default shell# append below to the last line case $- in *i*) # Interactive session. Try switching to bash. if [ -z "$BASH" ]; then # do nothing if running under bash already bash=$(command -v bash) if [ -x "$bash" ]; then export SHELL="$bash" exec "$bash" fi fi esac
SFTP user restricted to home directory
# Create user sudo adduser sercan # Change owner as root sudo chown root:sercan /home/sercan # Give almost all rights for root to that folder sudo chmod 750 /home/sercan/ # Then create a public folder to give it user completely sudo mkdir /home/sercan/pub
SSH login - .ssh permissions
# change directory to home cd mkdir .ssh chmod 700 .ssh cd .ssh touch authorized_keys chmod 600 authorized_keys
|
||||||||||||||||||||||||||||||
T |
U |
||||||||||||||||||||||||||||||
VVi / Vim# to delete all lines :%d #ENTER # copy a line and paste, make sure that cursor on top of the line to be copied yyp # insert at the end of line A #SHIFT+a
|
W |
||||||||||||||||||||||||||||||
X |
Y |
||||||||||||||||||||||||||||||
Z |
!@#$ |