diff --git a/src/shell/binary/mod.rs b/src/shell/binary/mod.rs
index 1a75dc993430309536ce00a3b5867ee88f5e7767..bbf5ba40a2a17cf9d08ed372345e91d801b6229b 100644
--- a/src/shell/binary/mod.rs
+++ b/src/shell/binary/mod.rs
@@ -14,13 +14,13 @@ use super::status::*;
 use liner::{Buffer, Context};
 use smallvec::SmallVec;
 use std::env;
+use std::error::Error;
 use std::fs::File;
+use std::io::{stdout, Write};
 use std::io::ErrorKind;
 use std::iter::{self, FromIterator};
 use std::path::Path;
 use std::process;
-use std::io::{stdout, Write};
-use std::error::Error;
 
 const MAN_ION: &'static str = r#"NAME
     ion - ion shell
@@ -208,7 +208,7 @@ impl Binary for Shell {
                     match stdout
                         .write_all(MAN_ION.as_bytes())
                         .and_then(|_| stdout.flush())
-                        {
+                    {
                         Ok(_) => return,
                         Err(err) => panic!("{}", err.description().to_owned()),
                     }
diff --git a/src/shell/variables/mod.rs b/src/shell/variables/mod.rs
index 26633b6a409d1447d57ad4e66452681e890c556d..15708e9602eb3b10e2f51faed355a3f5b93bda5c 100644
--- a/src/shell/variables/mod.rs
+++ b/src/shell/variables/mod.rs
@@ -6,7 +6,7 @@ use fnv::FnvHashMap;
 use liner::Context;
 use std::env;
 use std::io::{self, BufRead};
-use sys::{self, getpid, is_root};
+use sys::{self, geteuid, getpid, getuid, is_root};
 use sys::variables as self_sys;
 use types::{
     Array, ArrayVariableContext, HashMap, HashMapVariableContext, Identifier, Key, Value,
@@ -41,11 +41,20 @@ impl Default for Variables {
              ${c::reset}"
                 .into(),
         );
-        // Set the PID variable to the PID of the shell
-        let pid = getpid()
-            .map(|p| p.to_string())
-            .unwrap_or_else(|e| e.to_string());
-        map.insert("PID".into(), pid.into());
+
+        // Set the PID, UID, and EUID variables.
+        map.insert(
+            "PID".into(),
+            getpid().ok().map_or("?".into(), |id| id.to_string()),
+        );
+        map.insert(
+            "UID".into(),
+            getuid().ok().map_or("?".into(), |id| id.to_string()),
+        );
+        map.insert(
+            "EUID".into(),
+            geteuid().ok().map_or("?".into(), |id| id.to_string()),
+        );
 
         // Initialize the HISTFILE variable
         if let Ok(base_dirs) = BaseDirectories::with_prefix("ion") {
@@ -206,8 +215,8 @@ impl Variables {
 
     pub fn get_var(&self, name: &str) -> Option<Value> {
         match name {
-            "SWD" => return Some(self.get_simplified_directory()),
             "MWD" => return Some(self.get_minimal_directory()),
+            "SWD" => return Some(self.get_simplified_directory()),
             _ => (),
         }
         if let Some((name, variable)) = name.find("::").map(|pos| (&name[..pos], &name[pos + 2..]))
diff --git a/src/sys/redox.rs b/src/sys/redox.rs
index 3746becf1062c18a4928ef7ceddab04478d350ab..6c15bb46a581fb7fb49b3921df3527e48d89c766 100644
--- a/src/sys/redox.rs
+++ b/src/sys/redox.rs
@@ -22,6 +22,10 @@ pub(crate) const STDIN_FILENO: RawFd = 0;
 pub(crate) const STDOUT_FILENO: RawFd = 1;
 pub(crate) const STDERR_FILENO: RawFd = 2;
 
+pub(crate) fn geteuid() -> io::Result<u32> { cvt(syscall::geteuid().map(|pid| pid as u32)) }
+
+pub(crate) fn getuid() -> io::Result<u32> { cvt(syscall::getuid().map(|pid| pid as u32)) }
+
 pub(crate) fn is_root() -> bool { syscall::geteuid().map(|id| id == 0).unwrap_or(false) }
 
 pub unsafe fn fork() -> io::Result<u32> { cvt(syscall::clone(0)).map(|pid| pid as u32) }
diff --git a/src/sys/unix/mod.rs b/src/sys/unix/mod.rs
index 28ff14ea401658e05efda0812282a8c3733ff20c..5f6ff0866eea25e5b8109c39b31db24187a7b460 100644
--- a/src/sys/unix/mod.rs
+++ b/src/sys/unix/mod.rs
@@ -23,6 +23,10 @@ pub(crate) const STDOUT_FILENO: i32 = libc::STDOUT_FILENO;
 pub(crate) const STDERR_FILENO: i32 = libc::STDERR_FILENO;
 pub(crate) const STDIN_FILENO: i32 = libc::STDIN_FILENO;
 
+pub(crate) fn geteuid() -> io::Result<u32> { Ok(unsafe { libc::geteuid() } as u32) }
+
+pub(crate) fn getuid() -> io::Result<u32> { Ok(unsafe { libc::getuid() } as u32) }
+
 pub(crate) fn is_root() -> bool { unsafe { libc::geteuid() == 0 } }
 
 pub unsafe fn fork() -> io::Result<u32> { cvt(libc::fork()).map(|pid| pid as u32) }