---
title: "Elevating privileges with sudo"
date: "2016-01-18"
category: "terminal"
slug: "elevating-privileges-with-sudo"
---

Platforms v6 and newer provide limited `sudo` support for performing file operations with elevated (root) privileges. The available commands depend on your [[determining-platform-version]]:

- **v6:** `rm`
- **v6.5+:** `rm`, `cp`, `chown`

## Usage

The general syntax is `sudo <command> <arguments>`. Sudo is only available within the [[accessing-terminal]] and requires your password to confirm each action.

### rm -- Remove Files

Remove files or directories. Any file on your account can be removed, so use with caution.

```
sudo rm -rf /home/bob/bobswebsite.com
```

There are no restrictions on `rm` arguments.

### cp -- Copy Files

_Available on v6.5+ platforms only._

Copy files or directories from a source to a destination.

```
sudo cp myfile.txt mynewfile.txt
sudo cp -dR /home/bob/bobswebsite.com /var/www/bobstaging
```

The second example copies the site to a staging location, which could be an [[creating-addon-domain]] or [[creating-subdomain]].

**Limitations:**

- Copied system files count toward your account storage quota
- Only the `-d` (dereference symlinks) and `-R` (recursive) flags are allowed
- No other flags are accepted

### chown -- Change Ownership

_Available on v6.5+ platforms only._

Change the owner of a file or directory.

```
sudo chown -R myadmin /home/bob/bobsmysite
sudo chown apache /var/www/wp/wp-config.php
```

The second example grants the web server write access to `wp-config.php` in a [[installing-wordpress]] directory.

**Limitations:**

- Only the `-R` (recursive) flag is accepted
- Group ownership cannot be changed (e.g., `newuser:root` is not allowed)
- An absolute path is required (e.g., `chown newuser /var/www/myfile`)
    - Paths must reside within `/var` or `/home`
    - Directory traversal is not permitted (e.g., `/var/../root`)
