Skip to content

Instantly share code, notes, and snippets.

View mckartha's full-sized avatar

Mohan Kartha mckartha

View GitHub Profile
@mckartha
mckartha / samba-tool syntax
Created May 2, 2013 16:42
samba-tool syntax
# samba-tool
Usage: samba-tool <subcommand>
Main samba administration tool.
Options:
-h, --help show this help message and exit
Version Options:
@mckartha
mckartha / .screenrc
Created September 3, 2013 19:47
.screenrc
# ~/.screenrc - but could also be /etc/screenrc
caption string "%?%F%{= Bk}%? %C%A %D %d-%m-%Y %{= kB} %t%= %?%F%{= Bk}%:%{= wk}%? %n "
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%l][%{B} %Y-%M-%d %D / %{W}%c:%s %{g}]'
{google:baseURL}search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}
@mckartha
mckartha / count-files.sh
Created December 17, 2015 05:50
filesystem count by dir
# count-files.sh
# [2015Dec17 MCK] Count files in directories the root dir of a Linux/Unix server using `find` and a `for` loop
# Edit this list of directories as necessary
rootdirs="bin boot dev etc home lib lib64 lost+found media opt root run sbin srv sys tmp usr var"
for dir in $rootdirs ; do (echo -e -n "Dir: $dir : \t"; find /$dir -print | wc -l ) ; done
# Example output
# Dir: bin : 149
# Dir: boot : 288
@mckartha
mckartha / find-proc-for-port.txt
Created May 5, 2016 20:53
Use `netstat` and `lsof` to find out which command/process is listening on a port on OS X
It is often useful to figure out which OS X command/process is listening on a specific IP port
On Linux this can be done with the `netstat -p`
On OS X, the process id along with a lot of other info can be can be shown using the verbose `-v` flag:
* `sudo netstat -anlv |grep -e Address -e LISTEN` - will display the LISTENing processes along with the column header
This variant outputs a comman-delimited list of the processes that are LISTENing:
* `sudo netstat -anlv |grep -e LISTEN | awk '{print $9}'| sort -nu| tr "\n" "," | sed s/,$//`
@mckartha
mckartha / logexec.sh
Last active December 5, 2024 22:39
logexec.sh runs a command with params and logs stderr & stdout output to a timestamped logfile
# [2016Dec26 MCK] - logexec.sh - this script runs the given command, redirects Stderr to Stdout, & tees the output to the screen and a logfile
# [2021Feb22 MCK] - updated to re-write the leading '.' character when scripts from the current directory are executed
# [2022Nov03 MCK] - commented out conditional around shortname test on line 27/28 since the '[[' causes errors
# [2024Dec05 MCK] - Adding log heading to fully print CMD before running it
TODAY=`date "+%Y%m%b%d-%H%M"`
usage ()
{
echo "
@mckartha
mckartha / !useful git scripts.md
Last active April 29, 2022 18:08
These git bash utility scripts will execute git ops on a specific date, and change/update the Author & Commiter Name and Email for all commits in a workdir

Useful Git scripts

These git bash utility scripts will:

  • execute add and commit git operations on a specific date rather than the current time/date right now
  • change the Author & Commiter Name and Email for all commits in a workdir
  • update the Author & Commiter Name currently in use in gitconfig
@mckartha
mckartha / rclone-bkup-to-s3.sh
Created January 28, 2019 07:06
Use rclone to archive directories of Db data to S3
#/bin/bash
# rclone-db-bkup-to-s3.sh
# [2018Nov30 mkartha] transfer backups from the /mnt/nas/BackupLinux/ Db pg dumps to S3 using rclone
# - do this as root from the db-server or a server with rclone in PATH and access to db dumpfiles
# - this script also assumes that rclone has been configured with S3 credentials to transfer data to S3 with rclone profile aws-s3
# skeleton example
#restore_scripts/mkartha/logexec.sh rclone sync ./2018-11-28-daily aws-s3:db-backup/db-backups/2018-11-28-daily/ --ignore-checksum --fast-list --verbose
# usage: run script from the /mnt/nas/BackupLinux/ directory on a db server, with the 1st parameter as the name of the backup directory to transfer to S3
@mckartha
mckartha / SO-useGithubPATwithTortoiseGIt
Created January 13, 2022 16:42
Github Personal Access Token usage with TortoiseGit
good docs from StackOverflow:
https://stackoverflow.com/questions/21892226/can-i-use-githubs-2-factor-authentication-with-tortoisegit
@mckartha
mckartha / initialize_linux_svr.sh
Last active December 5, 2024 22:40
Initialize Linux Server instance
echo "### This script wgets the logexec.sh script & makes it eexcutable, runs apt/yum/dnf update & upgrade, gets .screenrc and does other setup tasks ###"
# https://gist.github.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/1fe6699deafde6098c5d7e4b9651d6faeb19bccd/logexec.sh
# wget https://gist.github.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/1fe6699deafde6098c5d7e4b9651d6faeb19bccd/logexec.sh
wget https://gist.githubusercontent.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/38afcb31390cb4ca1425da2f75aeb770420102d8/logexec.sh
chmod +x logexec.sh
mkdir -p /usr/local/bin
echo "### Move the logexec.sh script to /usr/local/bin by executing sudo - enter password to continue: ###"
sudo mv logexec.sh /usr/local/bin