Category: Bash / Terminal / Scripts

gnu linux bash – ssh login as different user
12.01.2020

situation: one is userA but wants to ssh login to server with ipv4: 123.123.123.123 via userB (dedicated user for that server/task). so what one does is: make sure one can login as userB than as userA: userA: ssh -v -i […]

10.01.2020

mdadm -E /dev/sd[a-z] # -E, –examine # Print contents of the metadata stored on the named device(s). # Note the contrast between –examine and –detail. # –examine applies to devices which are components of an array, while # –detail applies […]

09.09.2019

yum install ascii # or apt install ascii ascii Usage: ascii [-dxohv] [-t] [char-alias…] -t = one-line output -d = Decimal table -o = octal table -x = hex table -h = This help screen -v = version information Prints […]

29.08.2019

update: safety first! when it comes to important files: safety comes first thus recommend to the user that wants to go pro the following backup system: have two complete backups at two different places: backupA: at the company, USB 3.0 […]

05.06.2019

WARNING! BE VERY VERY CAREFUL! YOU CAN DESTROY YOUR SYSTEM! so better use a system that is not production important/not a live server. use a laptop that has NOTHING ATTACHED TO IT! (unplug all USB Sticks and external USB Drives) […]

15.05.2019

will do exactly that: last -F # -F Print full login and logout times and dates. # output will look like this # username (who logged in) ip (from which was logged in) duration of session username pts/0 123.123.123.123 Tue […]

linux bash – show all crontabs of all users
14.05.2019

cat /scripts/crontab_show_all.sh for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done outputs a nice list like this: in format: user command root no crontab for root actualuser * * * * * echo “stuff” […]

linux bash arrays example
09.04.2019

arrays are pretty useful variables that hold key:value data pairs, per default the “key” is an integer number, BUT: as shown there can also be associative arrays, meaning the index can be any string (needs bash version4) this script demonstrates […]

self hosted wordpress setup script
07.02.2019

WARNING! BACKUP YOUR MACHINE! UNTESTED! before running this script change to your new web root: /home/UserName/web/domain.com/public_html then run it like /scripts/install_wordpress.sh it tries to: download and unpack the latest wordpress into the current directory disable xmlrpc.php disable wp-cron.php requirements: a […]

linux bash script – test if host is alive – internet connection test script – uptime test script
15.12.2018

tested with: tested with/on: Static hostname: CentOS1.localdomain Operating System: CentOS Linux 7 (Core) Kernel: Linux 4.15.9 Architecture: x86-64 bash -version GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) ping -V ping utility, iputils-s20160308 usage: /scripts/count_host_uptime.sh domain.com cat /scripts/count_host_uptime.sh domain.com #!/bin/bash # ping -c […]

09.08.2018

i want to create a autostart script that starts whenever the server starts. mkdir /scripts vim /scripts/start.sh #!/bin/bash echo “========= starting up docker service” systemctl start docker echo “========= starting up docker containers” docker start containername vim /scripts/stop.sh #!/bin/bash echo […]