> For the complete documentation index, see [llms.txt](https://charliepage.gitbook.io/book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://charliepage.gitbook.io/book/command-line-linux.md).

# Command Line (Linux)

### Find/Replace

#### Find and replace all instances of a phrase with another one

```
sudo find /folder/path -type f -exec sed -i -e 's/originalword/newword/g' {} \;
```

#### Delete Folder with many files

```
cd /path/to/folder && perl -e 'for(<*>){((stat)[9]<(unlink))}'
```

#### Largest folders listed out

```
du -a /path/to/folder | sort -n -r | head -n 10
```

#### Rsync

{% embed url="<https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps>" %}

**SCP**

```
scp file_to_transfer.txt root@remotehost.com:/directory_to_drop_file/location/
```

For AWS pem file:

```
scp -i ~/path/to/key.pem file_to_transfer.txt root@remotehost.com:/directory_to_drop_file/location/
```

### Curl

#### Get redirect URL

If I want to see where a URL redirects to, run this command:

```
curl -I -Ls -o /dev/null -w %{url_effective} https://www.google.com
```
