zeqk
3/17/2020 - 9:35 AM

My Linux Cheatsheet

My Linux Cheatsheet

Check port

(echo >/dev/tcp/{host}/{port}) &>/dev/null && echo "open" || echo "close"

Example:

$ (echo >/dev/tcp/localhost/80) &>/dev/null && echo "open" || echo "close"

Get url content

curl -Lv http://localhost:5006/v2/

Source

Update or install package (Ubuntu)

$ sudo apt-get update
$ sudo apt-get install nginx

Users

Create user

# adduser username

Add to sudoers

# usermod -aG sudo username

Delete user

# userdel username

Remove home directory

# userdel -r username

SSH

Generate a passphraseless SSH key and push it to server

$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
$ ssh-copy-id id@server

Variables

NAME=VALUE

For al process

export NAME=VALUE

Crontab

Editar

sudo crontab -e -u usuario

Recargar

sudo service cron reload