---
title: "启动系统时以普通用户执行rc.local中命令"
author: "conkeyn"
date: "2017-01-12T17:21:17Z"
tags: []
categories: ["操作系统"]
slug: "rc-local"
draft: false
lastmod: "2017-01-12T17:21:17Z"
id: 2352682
url: "https://conkeyn.iteye.com/blog/2352682"
---

引用：[http://unix.stackexchange.com/questions/210939/what-user-runs-the-commands-defined-in-etc-rc-local](http://unix.stackexchange.com/questions/210939/what-user-runs-the-commands-defined-in-etc-rc-local "http://unix.stackexchange.com/questions/210939/what-user-runs-the-commands-defined-in-etc-rc-local") 

 

 Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.  
You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...  
su - oracle /do/something/as/oracle/user