linux - 如何在 Linux 的主文件夹中运行命令作为另一个用途 + 使用用户的环境/配置变量?
问题描述
/home/B/.config
我在另一个用户的主文件夹(和其他文件夹)中有很多 Kwin(窗口管理器)的配置。
有没有办法从我的会话中运行 Kwin,但让 Kwin 也考虑其他用户的配置和环境?
我无法将文件复制到我的帐户,因为它们分散在 B 的主文件夹中,我不想冒险覆盖内容。
我尝试使用sudo
,但它不会像运行 B 的会话一样运行命令,而是使用我自己的配置文件来运行程序而不是/home/B/
.
解决方案
如果-H
sudo 参数不够,也许你还需要 shell 资源文件中的-i
一些东西,比如sudo -i -uusername command
.
从 sudo 的手册页:
-i, --login Run the shell specified by the target user's password
database entry as a login shell. This means that
login-specific resource files such as .profile or
.login will be read by the shell. If a command is
specified, it is passed to the shell for execution
via the shell's -c option. If no command is
specified, an interactive shell is executed. sudo
attempts to change to that user's home directory
before running the shell. The command is run with an
environment similar to the one a user would receive
at log in. The Command environment section in the
sudoers(5) manual documents how the -i option affects
the environment in which a command is run when the
sudoers policy is in use.
推荐阅读
- php - 当两个不同的路由组内有相同的路由时,如何管理 Blade 中的路由?
- python - 提取量的正则表达式
- mongoose - 猫鼬 findByIdAndUpdate - 检查字段并修改它
- list - 如何使用菜单驱动的序言程序插入成员列表?
- python - 如何最好地为 python selenium chrome 安装代理
- node.js - 我无法安装 gatsby
- node.js - 如何在节点 js 中连接字符串以调用列
- c# - ASP.NET 核心 3.1。*.cshtml 位置未找到
- xpath - 我需要为以下场景编写一个动态 XPath
- excel - Excel 网页查询