Skip to content

2019

python3-merry-christmas

Python 3 prints Merry Christmas Everyone!

Merry Christmas with Python3 script

var="Merry Christmas Everyone!"

print (var)

pip3-list-installed-upgrade-all

So, I want to list the packages installed with pip3 and now that I can see them, I want to update them all.

List pip3 installed packages

pip3 list

Update all my pip3 packages

with a for loop you can loop through all your packages, exclude what is not a package and run the command pip3 {package} --upgrade on the installed packages.

for n in $(pip3 list | awk '{print $1}' | egrep -v 'Package|^-'); do
    pip3 install --upgrade ${n} ;
done

pip update outdates packages

Just another way of doing it.

for package in $(pip list -o | cut -f 1 -d ' ' | tail -n +3); do pip install --upgrade ${package}; done

If you know a better way, do let me know! :)

Beware of dependencies packages or minimum and max versions.

Use at your own responsibility.

Happy learning,

Antonio Feijao

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