# ADB Cheatsheet

## Proxy

To start the proxy

```ruby
adb shell settings put global http_proxy <ip>:<port>
```

To stop the proxy

```csharp
adb shell settings put global http_proxy :0 
```

## Installation

```bash
# to install app
adb install apk.apk # /path/to/apk
```

## List and find packages/apk path

{% code overflow="wrap" %}

```bash
# to list path
adb shell pm list package
adb shell pm list package | grep <app info> #com.example.myapp

# to find path
adb shell pm path <package> #com.example.myapp
#-> output: /data/app/~ysdfoLA==/com.example.myapp-itdhuLUMgJXxQY_8dIt7RA=/
```

{% endcode %}

## Port forwarding

```bash
# this will forward your android 127.0.0.1:8001 to your computer 127.0.0.1:9001
$> adb reverse tcp:8001 tcp:9001

# to list your current port forwarding rules
$> adb reverse --list
host-26 tcp:9001 tcp:9001
host-26 tcp:8001 tcp:9001

# to kill/close any port forwarding rule
$> adb reverse --remove tcp:8001
$> adb reverse --list
host-26 tcp:9001 tcp:9001

# to kill/close ALL port forwarding rules
$> adb reverse --remove-all
```
