Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 928 Bytes

10-basic-shell-scripting.md

File metadata and controls

47 lines (37 loc) · 928 Bytes

Basic Shell Scripting

Shell Scripting

  • Create a shell script to test the services below if they are active
  • sshd, httpd, crond, firewalld, mariadb
  • Set the list of services in a txt file (services.txt)
show

#!/bin/bash

for services in $(cat services.txt); do
    sudo systemctl status $service | grep --quiet "running"
    if [ $? -eq 0 ]; then
        echo $service "is Active"
    else
        echo $service "is Inactive or Not Installed"
    fi
done

  • Update the script to verify the existence of services.txt

Filesystem Troubleshooting

  • Run fsck on xvdb device
  • Display issue of xvdb device
  • Fix issues with xvdb device
  • Force to automatically repair xvdb device
show

sudo umount /dev/xvdb
sudo fsck -n /dev/xvdb
sudo fsck -y /dev/xvdb
sudo fsck -af /dev/xvdb