Category Archives: CLI

Fedora 26 + i3 window manager

Published / by MasonCloud / Leave a Comment

# start a terminal
bindsym $mod+Return exec gnome-terminal

# thunar
bindsym $mod+t exec –no-startup-id thunar

# load nm-applet
exec –no-startup-id nm-applet

# load backdrop
exec -no-startup-id feh –bg-scale /home/paulmellors/Storage/wha.jpg

# Volume control
bindsym XF86AudioRaiseVolume exec –no-startup-id pactl set-sink-volume 0 +1%
bindsym XF86AudioLowerVolume exec –no-startup-id pactl set-sink-volume 0 -1%
bindsym XF86AudioMute exec –no-startup-id pactl set-sink-mute 0 toggle

# lock screen
bindsym $mod+l exec –no-startup-id i3lock -i /home/paulmellors/Storage/locked.png

Ok that’ll do it 🙂

Delete Files Older Than ‘x’ Days

Published / by MasonCloud / Leave a Comment

Delete Files Older Than ‘x’ Days on Linux:

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.

Command Syntax:
Ex: find /path/to/files* -mtime +5 -exec rm {} \;

# clear ; find . -type f -mtime +5 -exec rm {} \;

Note that there are spaces between rm, {}, and \;


  • The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
  • The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
  • The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.

This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.

Get Notified When Users Run “sudo”

Published / by MasonCloud / Leave a Comment
# visudo

Paste the following into your config:

###### Get every alert when user fired an command with sudo ####
Defaults        syslog=auth, insults, syslog_goodpri=alert
Defaults        logfile=/var/log/sudo.log
Defaults        timestamp_timeout=0, log_year, tty_tickets
Defaults        mailto="", mail_always, mail_badpass, mail_no_user

Process Checker (Running or Not?)

Published / by MasonCloud / Leave a Comment
# Name : service.chk
# URL:
# Purpose: A simple process checker. Find out if service is running or not.
# Tested on: Debian and RHEL based system only.
# ----------------------------------------------------------------------------
# Author: nixCraft
# Copyright: 2009 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated: 13/Mar/2013 - Added support for email and other enhancements
# Last updated: 05/Dec/2011 - Added support for binary path check
# ----------------------------------------------------------------------------
# Runn the script as below to only show "running" processes
# clear ; ./ | grep -v "not running"
# ----------------------------------------------------------------------------
echo "Service status on ${HOSTNAME} @ $(date)"
echo "------------------------------------------------------"
sleep 1 ; chkconfig --list
echo "------------------------------------------------------"
## Change as per your distro
## Add binary list here
_chklist="/usr/bin/php-cgi /usr/sbin/mysqld /usr/sbin/apache2 /usr/sbin/nginx /usr/sbin/httpd"
#_chklist="/usr/bin/php-cgi /usr/sbin/lighttpd /usr/sbin/named /usr/sbin/pgsqld /usr/sbin/mysqld /usr/sbin/apache2 /usr/sbin/nginx /usr/sbin/httpd"
## yes | no
## Add your email id
## Do not change below
_running() {
 local p="${1##*/}"
 local s="true"
 $_pgrep "${p}" >/dev/null || { s="false"; _failed="true"; _service="${_service} $1,"; }
 [[ "$s" == "true" ]] && echo "$1 running" || { echo -n "$1 not running"; [[ ! -f "$1" ]] && echo " [ $1 not found ]" || echo ; }
## header
echo "Service status on ${HOSTNAME} @ $(date)"
echo "------------------------------------------------------"
## Check if your service is running or not
for s in $_chklist
 _running "$s"
## Send a quick email update (good for cron jobs) ##
[[ "$_failed" == "true" && "$_sendemail" == "yes" ]] && { _mess="$_service failed on $HOSTNAME @ $(date)";
 $_mail -s 'Service not found' "$_email" < "${_mess}";