在这个问题中提到,.profile在当今的Linux和Unix系统中,用户从GUI登录时是否被读取并没有标准的行为。那么对于 Ubuntu,是.profile在我从 GUI 登录时读取的吗?
在一个有点不相关的说明中,有没有办法仅通过终端在本地登录 Ubuntu(即不使用 GUI 和不使用 SSH 远程登录)?
我正在尝试将我的路径变量设置为如下所示:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jgrande/android-sdk-linux/platform-tools:/usr/lib/jvm/java-7-openjdk-amd64/bin/:/usr/lib/jvm/java-7-openjdk-amd64/jre/bin
Run Code Online (Sandbox Code Playgroud)
并且出于某些原因,无论我编辑什么文件,该变量总是看起来像这样(java 路径重复了很多次):
PATH=/usr/local/java/jdk1.7.0_79/bin:/home/jgrande/bin:/usr/local/java/jdk1.7.0_79/bin:/home/jgrande/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/java/jdk1.7.0_79/bin:/usr/local/java/jdk1.7.0_79/jre/bin:/usr/local/java/jdk1.7.0_79/bin:/usr/local/java/jdk1.7.0_79/jre/bin
Run Code Online (Sandbox Code Playgroud)
我试图编辑我的个人.bashrc和.profile以及/etc/environment,/etc/bash.bashrc,/etc/profile,并将其设置/etc/profile.d。现在,有jdk.sh在/etc/profile.d其中PATH变量是相同的不正确的一个I张贴以上。但是,我试图注释掉该行甚至jdk.sh完全删除,但仍然没有解决。
否则,我已经注意到,如果我以另一个用户身份登录,我将拥有正确的 PATH 变量,并且不会让 java 重复一堆乱七八糟的变量。
所以,我想知道,我还没有检查过的 PATH 变量还能在哪里定义?
我使用 GNOME,它首先/etc/profile从~/.profile. 这是我通过将语句放入echo 'something' > test我能想到的所有文件中发现的,例如 .bashrc、.bash_profile、.profile、/etc/profile 和其他文件。
我很好奇的是,是否有任何标准文件要求所有桌面管理器执行命令?桌面管理人员之间在这方面是否有任何协议,或者他们是否使用他们想要的任何文件。
过去,我一直设置umask为~/.profile。我设置了一个umask,077所以我的文件获得了600 (rw-------). 但是~/.profile在 Ubuntu 17.04 中将其设置为不再有效。
因此,当在 Ubuntu 17.04 上的 gnome 会话中创建新文档时,我可以在哪里配置以便使用权限 600 创建它们?
我了解交互式登录和交互式非登录之间的区别
\n根据这篇优秀的文章:Zsh/Bash 启动文件加载顺序(.bashrc、.zshrc 等),我们有下表
\n+----------------+-----------+-----------+------+\n| |Interactive|Interactive|Script|\n| |login |non-login | |\n+----------------+-----------+-----------+------+\n|/etc/profile | A | | |\n+----------------+-----------+-----------+------+\n|/etc/bash.bashrc| | A | |\n+----------------+-----------+-----------+------+\n|~/.bashrc | | B | |\n+----------------+-----------+-----------+------+\n|~/.bash_profile | B1 | | |\n+----------------+-----------+-----------+------+\n|~/.bash_login | B2 | | |\n+----------------+-----------+-----------+------+\n|~/.profile | B3 | | |\n+----------------+-----------+-----------+------+\n|BASH_ENV | | | A |\n+----------------+-----------+-----------+------+\n| | | | |\n+----------------+-----------+-----------+------+\n| | | | |\n+----------------+-----------+-----------+------+\n|~/.bash_logout | C | | |\n+----------------+-----------+-----------+------+\nRun Code Online (Sandbox Code Playgroud)\n第一个链接引用了另一篇优秀的文章:清理 bash 自定义,其中提供了有关交互式登录和交互式非登录的出色解释,如下所示:
\n\n交互式登录shell 是您正在输入的 …
我想添加一个路径,以便系统可以找到一些手动安装的可执行文件。但是,我没有PATH=xxx:$PATH;export PATH在 ~/.profile 的末尾输入xxx 是可执行文件所在的目录,而是错误地使用了PATH=xxx;export PATH.
注销后,我无法以通常的方式登录。我该如何解决这个问题而不是重新安装?
存储用户本地可执行文件的正确位置在哪里?
echo $PATH 给
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Run Code Online (Sandbox Code Playgroud)
它不包括例如。 $HOME/bin
将$HOME/bin是可取的?或者$HOME/opt/bin……
我想我也必须将它添加到我的 .profile 中?
我创建了一个小脚本来在 Nautilus 中添加书签,以将用户重定向到网络共享。如果我手动运行该脚本,它运行得非常好,但是一旦我尝试将其添加到 /etc/profile.d 中,我就无法连接到计算机。似乎只要我执行一个循环或任何类似的“花哨”的事情,脚本就会出错。这是我当前正在工作的脚本的示例:
#!/bin/bash
# Creating gtk-bookmarks if it doesn't exists
if [[ ! -f ~/.gtk-bookmarks ]]
then
touch ~/.gtk-bookmarks
fi
# Adding bookmarks if not present
if ! grep -Fxq "smb://example.com/R03C01 Software:" ~/.gtk-bookmarks
then
echo "smb://example.com/R03C01 Software:" >> ~/.gtk-bookmarks
fi
Run Code Online (Sandbox Code Playgroud)
一旦我有了这样的功能:
####
# Function find_server_by_ip()
# Desc : This function find the server to use for the current host IP Address
# Parameters : None
# Return : echo Server to use
####
function find_server_by_ip()
{
hostname_ip=$(hostname …Run Code Online (Sandbox Code Playgroud) When the system loads it gives the following error:
Error found while loading /home/[username]/.profile
mesg: ttyname failed: inappropriate ioctl for device
As a result the session should not be configured correctly
You should fix the problem as soon as feasible
Run Code Online (Sandbox Code Playgroud)
The output of grep -i mesg for .profile and .bash* is as follows:
$ grep -i mesg .profile
mesg n || true
$ grep -i mesg .bash*
$
Run Code Online (Sandbox Code Playgroud) 我安装了 texlive,我想将其作为环境变量添加到我的 Path 中,以便当我从 GUI 或命令行启动 emacs 时,Emacs AucTeX 可以读取它。到目前为止,我已经了解到 emacs 只读取来自~/.profile.
因此,我的计划是将 texlive 添加到我的路径中,.profile以使 emacs GUI 能够读取它,然后~/profile从中获取源代码.bashrc,以便在我的非登录交互式 GNOME 终端中启动的 emacs 查看路径。
.profile注意:我的主目录中没有文件,仅在我的/etc目录中,我不想碰那个文件,但我.bash_profile的主目录中有一个文件。但是我读到它.bash_profile仅针对交互式登录会话(即我不使用的控制台模式)运行。
.profile文件并执行以下操作:第 1 步:创建~/.profile
步骤2:将texlive环境变量添加到path中.profile
export PATH=/usr/local/texlive/2018/bin/x86_64-linux:$PATH
export MANPATH=/usr/local/texlive/2018/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2018/texmf-dist/doc/info:$INFOPATH
Run Code Online (Sandbox Code Playgroud)
步骤 3:.profile来源.bashrc
#Adding this at the bottom or start of .bashrc to source .profile when the terminal is opened.
if [-s ~/.profile]; then;
source …Run Code Online (Sandbox Code Playgroud)