Skip to content

Instantly share code, notes, and snippets.

View vhbui02's full-sized avatar

VH vhbui02

View GitHub Profile
@vhbui02
vhbui02 / baterry-laptop.md
Last active May 2, 2023 04:17
[powercfg command] Keep track of your laptop battery #windows #laptop

powercfg /batteryreport /output "%USERPROFILE%\battery_report_2.html" /duration 14

powercfg /energy

@vhbui02
vhbui02 / networking-problem.md
Last active May 1, 2023 14:12
[Most common networking problem and their solutions] #linux

How to check if port is in use in

  • sudo lsof -i -P -n | grep LISTEN
  • sudo netstat -tulpn | grep LISTEN
  • sudo ss -tulpn | grep LISTEN
  • sudo lsof -i:22 ## see a specific port such as 22
  • sudo nmap -sTU -O
@vhbui02
vhbui02 / permission.md
Created May 1, 2023 13:55
[Change permission to increase Linux security] #linux

chmod 700 /home/[your-username]

chmod 700 ~/.ssh

chmod 600 ~/.ssh/authorized_keys

@vhbui02
vhbui02 / ufw.md
Last active November 17, 2023 14:34
[ufw command] ubuntu uncomplicated firewall #linux

sudo ufw [COMMAND]

Using IPv6 with UFW

sudo nano /etc/default/ufw - IPV6=yes

Options

status verbose: list all custom and default rules.

@vhbui02
vhbui02 / ss.md
Created May 1, 2023 08:37
[ss command] yet another networking tool :v #fish

ss stands for "socket statistics", a CLI tool to display information about network sockets on a Linux or Unix-like OS.

ss can be used to display:

  • the state of the connection.
  • the type of the socket.
  • the process that is using the socket.

Note: ss is similar to netstat, but it's generally faster and more efficient when dialing with large numbers of network connections

Options

@vhbui02
vhbui02 / lsof.md
Created May 1, 2023 08:29
[lsof command] another command that can handle networking by can't remember #linux

lsof stands for list open files, a CLI tool to display infos about the files currently open by processes on a Unix or Unix-like OS.

lsof can be used to identify which processes are using specific files, which files are being used by specific processes, which network connections are open.

Options

-c NAME: filter by process name or command name.

-u NAME: filter by user name or user ID.

@vhbui02
vhbui02 / nc-netcat.md
Created May 1, 2023 08:21
[nc command] another networking tool that i've never remembered anything :v #linux

Options

-l: listen for incoming connections

-p: specify the local port to use for the connection

-v: enables verbose output, which can be helpful when debugging

-n: disables DNS resolution, which can speed up connections.

@vhbui02
vhbui02 / netstat.md
Last active May 1, 2023 08:38
[netstat command] I can never remember these options :v #linux

Options

-a: display all active connections, including those in LISTEN state

-n: don't resolve names (display addresses and port numbers in numerical format, rather than resolving them to host and service names)

-p, --programs: display PID/Program name for sockets.

-l, --listening: display listening server sockets.

@vhbui02
vhbui02 / for.md
Last active May 2, 2023 03:41
[for command] perform a set of commands multiple times #fish #linux

local variable inside for body isn't exported to outside, remember to use set -x option.

Syntax

for <var-name> in $list_variable
	echo $<var-name>
end