Tags » Bash Script

sudo asks for password even if NOPASSWD is set in /etc/sudoers

TL;DR when a script is not marked as executable and you try to run it with sudo, you don’t get the usual -bash: myScript.sh: Permission denied… 314 more words

Computers

The BASH shell, and basic needs

Now we can begin!

There are some prerequisites to operating within the shell in a ‘nix environment:

1. DO NO HARM!….. I know it sounds corny (korny?), but the first commandment of a ‘nix sysadmin is a big one, and not following it, particularly when possessing elevated or root privileges, can cost you time, money, effort, and possibly your job!… You ARE backing up, right? 187 more words

Linux/UNIX

Nmap - Scan for open ports

nmap is a network exploration tool and security/port scanner.

We can list all open ports using nmap for a given IP/Host.

Use following command to list all open ports: 32 more words

Ubuntu

mutt - send mails with attachments

By using mutt we can send mails with attachments from command line.

Install mutt:

$ apt-get install mutt

Send mail with attachment:

$ mutt -s "PFA" -a attachment.txt user@example.com <┬ábody.txt… 39 more words
Debian

List all open ports in a Linux machine.

Here is the script to list all open ports in a Linux machine.

echo “TCP”; netstat -tnlp | tail -n +3 | awk ‘{print $4}’ | cut -d: -f2 | xargs | tr ‘ ‘ ‘,’; echo “UDP”; netstat -unlp | tail -n +3 | awk ‘{print $4}’ | cut -d: -f2 | xargs | tr ‘ ‘ ‘,’; echo “TCP6″; netstat -tnlp –inet6 | tail -n +3 | awk ‘{print $4}’ | cut -d: -f4 | xargs | tr ‘ ‘ ‘,’; echo “UDP6″; netstat -unlp –inet6 | tail -n +3 | awk ‘{print $4}’ | cut -d: -f4 | xargs | tr ‘ ‘ ‘,’

Bash Script

Nagios Plugin to monitor cPanel License Expiry Date.

#!/bin/bash
CP=$(grep -a license_expire_time /usr/local/cpanel/cpanel.lisc | awk {‘print $2′})
SE=$(date +%s)
let DIF=$CP-$SE
let DAY=$DIF/86400
if [ $DAY -gt 15 ]; then
echo “OK: cPanel License expires on ${CP}” 41 more words

Bash Script