# Shell (Linux)

## Shell Cheat Sheet

### File & Folder Operations

Delete a directory:`rm -r directory`

Delete file:`rm FILETODELETE`

New directory:`mkdir FOLDERNAME`

Copy file:`cp SOURCE DEST`

Copy folder:`cp -avr SOURCE DEST`

Watch file:`less +F YOUR.LOG`

Move/Rename folder:`mv OLD NEW`

### CURL

Download file:`curl -O URLHERE`

### Zipping & Uzipping

Unzip:`unzip FILENAME.ZIP`

Untar & Gzip:`tar -xzf FILENAME.TAR.GZ`

Ungzip: `gzip -d FILENAME.GZ`

Zip folder:`zip -er DESTINATION.ZIP FOLDER`

### Processes

Kill process:`kill -9 PROCESSID`

Kill process on port: `kill $(lsof -t -i:PORT_HERE)`

Find process:`ps -ef | grep PROCESS NAME`

Process list:`ps aux`

Root process list:`ps -u root`

Check memory usage in megabytes:`free -m`

List of ports in use: `sudo lsof -i -P -n`

### Permissions

Set all new files and folders to[ inherit the group of the current folder](https://unix.stackexchange.com/a/401751): `$ chmod -R g+s somefolder`


---

# 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://kb.chrisltd.com/cheat-sheets/shell-linux.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.
