Skip to content

Home

github-basics-command

Github git basic commands

Some basic git command and working with ssh keys to update the repository

https://help.github.com/en/enterprise/2.17/user/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account

git clone


ssh-keygen -t rsa -b 4096 -C "my comment "

vim ~/.ssh/config

eval "$(ssh-agent -s)"

ssh-add "my-private-key..."


git remote set-url origin [email protected]:"USERNAME"/"REPOSITORI.git"


git status

git add .

git commit -am "message/comment about changes"

git push

git pull

git with ssh key

  1. first create your ssh key ssh-keygen -b 4096
  2. add the .pub key into your repository
  3. check this setup - https://medium.com/@czarpino/how-to-tell-git-which-ssh-key-to-use-c8574fb243fd

Good documentation about git commands

raspberry-pi-as-a-router-nat

Transform to run as a router and NAT device

Finally! This project is now documented here - https://antonio.cloud/projects/linux/raspberry-pi/raspberry-pi-router-access-point-dns-block-ads-vpn/

Important

Below are notes from my old post

## the command below required sudo

echo "-----------------------"
echo "Shows the configs before changes..."

sysctl net.ipv4.ip_forward net.ipv4.conf.eth0.send_redirects

iptables -n -t nat -L POSTROUTING 


echo "-----------------------"
echo "Enabling IPv4 routing packets forward..."

sysctl -q -w net.ipv4.ip_forward=1 net.ipv4.conf.eth0.send_redirects=0


echo "-----------------------"
echo "Enabling routing/PAT with ip tables..."

iptables -t nat -C POSTROUTING -o eth0 -j MASQUERADE 2> /dev/null || iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


echo "-----------------------" 
echo "Show configs after changes..."
sysctl net.ipv4.ip_forward net.ipv4.conf.eth0.send_redirects
iptables -n -t nat -L POSTROUTING 


echo "-----------------------"
echo "Routing/NAT configuration completed "

python-3-http-server

A quick and simple way to start a webserver on the current directory with Python 3 using module http.server


{% highlight bash linenos %}

python3 -m http.server 8000 --directory .`

{% endhighlight %}


Happy learning and keep practicing!

Antonio.Cloud

linux-find-command

Linux find command

Warning

Use the flag -exec with care. Try the command find without the -exec rm {} \; to see which files are found,

find . -type f -name 'desktop.ini' -exec rm {} \;

find . -type f -name '.DS_Store' -exec rm {} \;

clamav-linux-free-antivuris-scan

Linux Clam AntiVirus ClamAV

ClamAV

  • clamav's logo

  • Runs on AmazonLinux, Linux RedHat, Ubuntu, MacOS, Raspberry Pi, ...

ClamAV is an open source antivirus engine for detecting trojans, viruses, malware & other malicious threats.


Basic installation ClamAV Linux open source antivirus

MacOS - brew install clamav

RaspberryPi Ubuntu - apt-get install clamav

AmazonLinux, RedHat, CentOS, Fedora - yum install clamav


Using ClamAV freshclam and clamscn

## updates anti-virus database engine

freshclam -v


## executes the scan-antivirus, -->> ATTENTION to the `--remove` flag, this deletes files!
##
# consider running the command first without the `--remove` flag.

sudo clamscan --infected --remove --recursive=yes .

brief explanation

  • sudo - run the command as superuser or root
  • clamscan - runs the ClamAV scanner
  • -v - run in verbose mode
  • --infected - only output infected files (unless you also specified the verbose)
  • --remove - removes (deletes) infected detected files

offical manual command man freshclam man clamscan

use man freshclam or man clamscan for the official command line manual.

vim and vimrc file options

vimrc file options

vimrc file options

  • Remember, if you are using a colorscheme, you need to download that scheme. Example, check the link for the happy_hacking

  • If you use this .vimrc suggestion file, it enables vim visual mode, so mouse support is enable on vim.

  • Basic commands in visual mode are :

    • shift+y to copy
    • shift+p to paste
  • Below, suggestion for file .vimrc ...

""" read first from this file
""" from " Website: https://github.com/yorickpeterse/happy_hacking.vim
"colorscheme happy_hacking
colorscheme yozakura

""" then apply personalisations
filetype off

"highlight clear

filetype plugin indent on " Filetype auto-detection
syntax on " Syntax highlighting

"set background=dark


""" set UTF-8 encoding
set encoding=utf-8
set fenc=utf-8
set termencoding=utf-8
""" disable vi compatibility (emulation of old bugs)
set nocompatible
""" use indentation of previous line
set autoindent
""" use intelligent indentation for C
"set smartindent
""" configure tabwidth and insert spaces instead of tabs
set tabstop=4        " tab width is 4 spaces
set shiftwidth=4     " indent also with 4 spaces
set expandtab        " expand tabs to spaces
""" wrap lines at 120 chars. 80 is somewaht antiquated with nowadays displays.
set textwidth=120
""" turn syntax highlighting on
set t_Co=256
"syntax on
""" colorscheme wombat256
""" turn line numbers on
set number
""" highlight matching braces
set showmatch
""" intelligent comments

set softtabstop=4
set showcmd
set showmatch
set incsearch
set hlsearch

set hidden

"if has('termguicolors')
"    set termguicolors
"endif

set mouse=a

""" https://gist.github.com/benjiao/08432d1377e768c2c4e9

" Use case insesitive search
set ignorecase
set smartcase

" Display cursor position
set ruler

" Prompt to save file on exit
set confirm

" Disable beep
set visualbell

" Highlight cursor line
set cursorline

aws-cloudwatch-logs-cloudtrail-logs-filters-sample

AWS VPC flowlogs CloudWatch logs CloudTrail logs and filters examples

Official Documentations - https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html


Basic sample VPC-flow-logs

[version, account, eni, source, destination, srcport, destport="8000", protocol, packets, bytes, windowstart, windowend, action, flowlogstatus]


VPC flow logs example with combination of AND

[version, account, eni, source="185.2*", destination, (srcport!="80" && srcport!="443"), (destport!="80" && destport!="443"), protocol, packets, bytes, windowstart, windowend, action, flowlogstatus]


Basic Expressions Operators

= -- EQUAL

!= -- NOT EQUAL

< -- SMALL THAN

> -- GRATER THEN

<= -- SMALL OR EQUAL

>= -- GRATER OR EQUAL

&& -- AND

|| -- OR


Cloud Trail Logs Filter examples

  • filter by Failure Console Logins 'ConsoleLogin="Failure"'

{ $.eventSource = "signin.amazonaws.com" && $.responseElements.ConsoleLogin = "Failure" }

  • exclude know IP address

{ ($.sourceIPAddress != "52.123.123.5") && ($.sourceIPAddress != "33.123.123.*") && ($.sourceIPAddress != "*.amazonaws.com") }

  • AWS login without using MFA

{ $.eventSource="signin.amazonaws.com" && $.additionalEventData.MFAUsed="No" }


Happy learning

Antonio Feijao UK

raspberry-pi-camera-resolution

Linux command lsusb

lsusb | grep -i cam

Bus 001 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270
  • Now, use the Bus and Device numbers with -v option for verbose and filter for "Width|Height" and grep command.
$ lsusb -s 001:002 -v | egrep "Width|Height"

    wWidth    640
    wHeight   480
    wWidth    1280
    wHeight   1024
...

lsusb with sort awk grep uniq

I also like to use command likes sort, awk, grep and uniq.

echo "Maximum --> Width <-- will come on top" && lsusb -s 001:004 -v | grep "Width"  | awk '{print $2 " " $1}' | sort | uniq | sort -nr


echo "Maximum --> Height <-- will come on top" && lsusb -s 001:004 -v | grep "Height"  | awk '{print $2 " " $1}' | sort | uniq | sort -nr

v4l2-ctl

  • or another elegant option if available to you is :

v4l2-ctl --list-formats-ext

some credits go to

https://askubuntu.com/questions/214977/how-can-i-find-out-the-supported-webcam-resolutions