Default
Simple Linux Scripts
C. BinKadal --- Sendirian, Berhad


List of Contents


Set /bin/sh as /bin/bash

  • To set symbolic link from /bin/sh to /bin/bash (account: root)
  • Script name: “.doBASH.sh”

cat > $HOME/.doBASH.sh << EOF
#!/bin/bash
# REV02: Tue 27 Jun 2023 15:00
# START: Fri 16 Jun 2023 16:00
# .doBASH.sh

readlink -- /bin/sh
[[ "$(readlink -- /bin/sh)" == "/bin/bash" ]] || { /bin/rm -f /bin/sh; ln -s /bin/bash /bin/sh; }
readlink -- /bin/sh
exit
EOF
### #####


DNS Server

  • To alter DNS Servers (account: root)
  • Script name: “.doDNS.sh”

cat > $HOME/.doDNS.sh << EOF
#!/bin/bash
# REV04: Sun 10 Sep 2023 10:00
# REV03: Wed 16 Aug 2023 09:30
# REV02: Tue 27 Jun 2023 16:00
# START: Fri 16 Jun 2023 16:00
# .doDNS.sh

RESOLV="/etc/resolv.conf"

echo   "===== \$RESOLV was:"
cat    \$RESOLV
cat >  \$RESOLV <<< "nameserver 8.8.8.8"
cat >> \$RESOLV <<< "nameserver 1.1.1.1"
cat >> \$RESOLV <<< "nameserver 8.8.4.4"
echo   "===== \$RESOLV now:"
cat    \$RESOLV
EOF



Fill ZERO

  • Clean HardDisk by filling zero (account: root)
  • Script name: “.doZERO.sh”

cat > $HOME/.doZERO.sh << EOF
#!/bin/bash
# REV04: Wed 04 Oct 2023 18:00
# REV03: Sun 10 Sep 2023 15:00
# REV02: Tue 27 Jun 2023 16:00
# START: Fri 16 Jun 2023 16:00
# .doZERO.sh

TMPF=tmptmp.bin

for II in /tmp /mnt/lfs /mnt/\$(hostname) ; do
  [ -d \$II/ ] || continue
  echo "==== ===="
  rm -fv \$II/\$TMPF
  df \$II/ | tail -1
  echo -n "WAIT  ..."
  dd if=/dev/zero of=\$II/\$TMPF bs=4M >& /dev/null
  echo ""
  df \$II/ | tail -1
  rm -fv \$II/\$TMPF
  df \$II/ | tail -1
  sync
done
echo "==== ===="
exit
EOF
### #####


UPDATE

  • Update Debian (account: root)
  • Script name: “.doUPDATE.sh”

cat > $HOME/.doUPDATE.sh << EOF
#!/bin/bash
# REV01: Wed 16 Aug 2023 07:30
# START: Wed 16 Aug 2023 07:00
# .doUPDATE.sh

time (
  aptitude update          &&
  echo " ===== 1 ====== "  &&
  aptitude safe-upgrade -y &&
  echo " ===== 2 ====== "  &&
  aptitude autoclean -y;
)

exit
EOF
### #####


TEST SCRIPTS

who am i

cd

pwd

ls -al .do*


# To set symbolic link from /bin/sh to /bin/bash (account: root)
[ -f .doBASH.sh ] && bash .doBASH.sh


# To alter DNS Servers (account: root)
[ -f .doDNS.sh ] && bash .doDNS.sh


# Clean HardDisk by filling zero (account: root)
[ -f .doZERO.sh ] && bash .doZERO.sh


# Update Debian (account: root)
[ -f .doUPDATE.sh ] && bash .doUPDATE.sh



© 2021-2024 --- C. BinKadal --- About --- Revision: Mon 18 Nov 2024 17:00.