# CLI Tools Cheat Sheet

## awk

* A tool with similar capabilities to `cat` and `cut` where it can read file contents and customize the output.

{% code lineNumbers="true" %}

```
// Selecting text fields from a file
root@box ~ $ awk '{print $1 ""}' subdomains.txt
blog.techwithtyler.dev
braindump.techwithtyler.dev
techwithtyler.dev
www.techwithtyler.dev
```

{% endcode %}

## cat

* A tool for reading file contents onto standard output (STDOUT).

{% code lineNumbers="true" %}

```sh
// Reading files
root@box ~ $ cat subdomains.txt
blog.techwithtyler.dev 234234234
braindump.techwithtyler.dev 25346536
techwithtyler.dev 43564356743
www.techwithtyler.dev 45776568
```

{% endcode %}

## cut

* A tool for removing sections from each line of files

{% code lineNumbers="true" %}

```
// Selecting text fields from a file
root@box ~ $ cut -f2 -d " " subdomains.txt
234234234
25346536
43564356743
45776568
```

{% endcode %}

```
// Another option, piping output to cut
root@box ~ $ cat subdomains.txt | cut -f2 -d " "
234234234
25346536
43564356743
45776568
```

## export

* Useful to create env vars or updating your $PATH

```sh
# adds a tool to your path
export PATH=$PATH:/opt/aws/bin
```

## find

* More advanced than the `locate` tool.
* It can search based on several attributes e.g., permissions, timestamp, file size, and more.

```
// Finding a file

$ find -name my-*
./a/b/c/d/e/f/g/my-lost-file
```

```
// Finding files owned by root where all users have 'write' permissions

$ find / -type f -group root -perm -a=w 2>/dev/null
/proc/sys/kernel/ns_last_pid
/proc/pressure/io
/proc/pressure/cpu
[SNIP]
```

## locate

* A useful tool for quickly finding files and directories.&#x20;
* Install it with: `sudo apt install mlocate`
* It's a local database that gets updated regularly with a cron job but can otherwise be forced to update with: `sudo updatedb`

```
// Finding a file

$ locate my-lost-file
/home/parrot/a/b/c/d/e/f/g/my-lost-file
```

## which

* Searches the `$PATH` environment variable for any executable matching the search.

```
// Checking if python3 is installed 

$ which python3
/usr/bin/python3
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.techwithtyler.dev/operating-systems/linux/cli-tools-cheat-sheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
