diff --git a/envsetup.py b/envsetup.py
index 40ac86e4bf5993c07c7f5f09211b432fef711f04..1676e2ac8b1732428a040043ff8d6497fffdecb1 100755
--- a/envsetup.py
+++ b/envsetup.py
@@ -65,7 +65,7 @@ class EnvSetup():
         self.debug = '-d' in args
         if self.debug:
             args.remove('-d')
-        whoami = subprocess.check_output(['whoami']).decode('utf-8')
+        whoami = subprocess.check_output(['whoami']).decode('utf-8').strip()
         if whoami != 'root' and not self.debug:
             log('This script should be run as root user.')
             sys.exit(1)
diff --git a/tester.py b/tester.py
index c593cb7a0e1bcaf6ec69bad350000ab3b2474f2b..2d4e75e64222971d9a070ab6446755e19c8f92d9 100755
--- a/tester.py
+++ b/tester.py
@@ -60,7 +60,7 @@ class Tester():
         debug = '-d' in args
         if debug:
             args.remove('-d')
-        whoami = subprocess.check_output(['whoami']).decode('utf-8')
+        whoami = subprocess.check_output(['whoami']).decode('utf-8').strip()
         if whoami != 'root' and not debug:
             log('This script should be run as root user.')
             sys.exit(1)