# Linux

# Comandos utiles

```shell
# iniciar ngrok
./ngrok http 3000

# Hacer usb booteable
sudo dd bs=512K status=progress if=linuxmint-19.1-cinnamon-64bit.iso of=/dev/sdb

# Matar proceso que este utilizando un puerto especifico
sudo kill $(sudo lsof -t -i:9001)

python3 -m http.server

#windows
 netstat -ano | findstr :8000
 taskkill /PID 684 /F
```

# Linux firewall security

```shell
sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status
sudo ufw reload
sudo ufw disable

#Fail2ban
sudo apt-get update
sudo apt-get install fail2ban

```

# Install redis

```shell
sudo apt-get install redis-server
sudo systemctl enable redis-server.service

#test redis-cli
redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
```

# Actualizar nombre linux

```shell
sudo nano /etc/hostname

sudo nano /etc/hosts
```

# Escritorio remoto - VNC

```shell
ssh -XC user@IP-ADDRESS

sudo apt install xauth

sudo systemctl restart sshd

sudo apt install x11-apps

sudo touch /dev/fuse

sudo apt install xfce4 xfce4-goodies gnome-icon-theme

sudo apt-get install tightvncserver

apt-get install xfonts-base

vncserver :1 -geometry 800x600 -depth 24

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i google-chrome-stable_current_amd64.deb

apt --fix-broken install

#-------------
vncserver -kill :1
vncserver :1 -geometry 1000x700 -depth 24

#-
tightvncserver :1
tightvncserver -kill :1
tightvncserver -geometry 1024x768 :1

#---------------- gnome -------------
apt-get install gnome-desktop-environment

apt-get install xfonts-100dpi
apt-get install xfonts-100dpi-transcoded
apt-get install xfonts-75dpi
apt-get install xfonts-75dpi-transcoded
apt-get install xfonts-base

#----------- gnome debian ---------
tasksel install desktop gnome-desktop
tasksel install laptop
systemctl set-default graphical.target
```

https://my.vps6.net/knowledgebase/52/How-to-Install-VNC-wor-GNOME-on-Debian-VPS.html

# Install Wekan on linux

[https://github.com/wekan/wekan-snap/wiki/Install](https://github.com/wekan/wekan-snap/wiki/Install)

# Debian sources.list

```shell
deb http://deb.debian.org/debian buster main
deb-src http://deb.debian.org/debian buster main

deb http://deb.debian.org/debian-security/ buster/updates main
deb-src http://deb.debian.org/debian-security/ buster/updates main

```

```shell
nano /etc/apt/sources.list
```

# Linux Benchmark

```shell
wget -qO- bench.sh | bash
```

# Instalar OpenVPN en servidor

[https://www.cyberciti.biz/faq/howto-setup-openvpn-server-on-ubuntu-linux-14-04-or-16-04-lts/](https://www.cyberciti.biz/faq/howto-setup-openvpn-server-on-ubuntu-linux-14-04-or-16-04-lts/)

[https://github.com/Nyr/openvpn-install](https://github.com/Nyr/openvpn-install)

```shell
wget https://git.io/vpn -O openvpn-install.sh

# vpn
sudo bash openvpn-install.sh
```

```shell
sudo apt install openvpn

openvpn --config client.ovpn

openvpn --config client.ovpn --auth-user-pass

```

# Instalar ZSH

```shell
sudo apt-get install zsh

# oh-my-zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

# zsh por defecto
chsh -s `which zsh`

# reinciar terminal
```

# Digital Ocean Tutorials

[https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04)

[https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-zabbix-to-securely-monitor-remote-servers-on-ubuntu-20-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-zabbix-to-securely-monitor-remote-servers-on-ubuntu-20-04)

[https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04)

# Linux - Cron Tabs

```shell
# Ubuntu cron tab file location:
# /var/spool/cron/crontabs/

# list crontabs
crontab -l

#
sudo service cron reload
sudo /etc/init.d/cron start
sudo /etc/init.d/cron stop
sudo /etc/init.d/cron status
```