Skip to content

Instantly share code, notes, and snippets.

@zeqk
Last active February 19, 2021 12:11
Show Gist options
  • Save zeqk/2a71570051433f5b64239f53d91aa91f to your computer and use it in GitHub Desktop.
Save zeqk/2a71570051433f5b64239f53d91aa91f to your computer and use it in GitHub Desktop.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment