AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[.profile](ubuntu)

Martin Hope
Vegar
Asked: 2020-09-24 00:24:31 +0800 CST

Ubuntu 18.04 登录循环 .- bashrc 和 .profiles 已编辑

  • 0

当我在登录屏幕上输入密码时,屏幕会变黑几秒钟,然后返回登录屏幕。即登录循环。

我可以通过远程桌面和 SSH (puTTy) 登录。

在登录循环开始发生之前,我为 bash_rc 添加了一个别名,并为 .profile 添加了一个路径。我怀疑这是问题的原因,所以我用 etc/skel 中的文件覆盖了更改。

现在我的 .profile 看起来像这样:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
            . "$HOME/.bashrc"
        fi
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/.local/bin" ] ; then
        PATH="$HOME/.local/bin:$PATH"
    fi
    fi
    ~
    ~

我的 bash rc 看起来像这样:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
                       

登录腻子时,我收到错误消息:

Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the                                                                                                                                                                              PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH                                                                                                                                                                              environment variable.

所以我粘贴:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:$PATH

进入终端,像 ls 这样的命令再次起作用。奇怪的是,我在 tty3 或远程桌面中没有收到此错误。但是当我启动到安全模式时,我确实在 putty 和 root shell 中得到了它。这对任何人都有意义吗?

我的等/环境看起来像这样

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

我现在花了两天时间,任何帮助和提示将不胜感激:)

我已经尝试了登录循环的典型建议解决方案:

  • XAuthority & ICEAuthority
  • 更新 NVIDIA 驱动程序
bashrc .profile
  • 1 个回答
  • 263 Views
Martin Hope
amortaza
Asked: 2020-07-06 08:13:37 +0800 CST

在调用 `source .profile` 之前无法识别 `.profile` 中的 `alias` 命令

  • 5

.profile我的主目录中的文件中有以下行:

alias flux='redshift -O 2500'

但是每当我登录并输入时,flux我都会得到一个flux is not a recognized command.

然后我再次source .profile输入并输入flux,它工作得很好。

我在 Ubuntu 20.04

为什么alias我.profile不工作,除非我做一个source .profile?

编辑:我现在明白这.profile不是放置这个的正确位置。

我最终使用以下命令从.bashrc文件中加载别名:source

for file in ~/.dotfiles/.{exports,aliases}; do
    [ -r "$file" ] && source "$file"
done
unset file
alias .profile
  • 1 个回答
  • 1479 Views
Martin Hope
kaspar
Asked: 2020-06-26 01:44:04 +0800 CST

~/.profile 是否已读取?[复制]

  • 2
这个问题在这里已经有了答案:
为什么打开终端时没有 .profile 来源? (2 个回答)
2年前关闭。

我是个新手,但我知道每次启动终端时,都会考虑一些文件;其中有~/.profile,其中包含以下几行:

if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi

我创建了这个目录~/bin,因为我想放一些个人的东西。我关闭了终端并重新打开它,但PATH不包括~/bin. 所以,作为一个实验,我添加了一个愚蠢的

echo "hello world!"

在底部~/.profile,保存更改并使用终端重新登录,但什么也没有。似乎该文件被完全忽略了。

我错了吗?还是有什么改变?

.profile 20.04
  • 1 个回答
  • 1335 Views
Martin Hope
Caio Vieira
Asked: 2020-06-16 13:03:18 +0800 CST

.profile 没有被采购

  • 1

前段时间我安装了byobu并运行byobu-enable它仍然没有自动启动,我只是忽略了它,因为我可以直接按超级并打开byobu终端。但是现在我尝试设置一些变量并在以下位置找到了这一行~/.profile:

byobu_sourced=1 . /usr/bin/byobu-launch 2>/dev/null || true

甚至当我在那里设置任何东西时,~/.profile文件也永远不会被获取。我知道它永远不会被采购,因为我$HOME/bin被设置在那里并echo $PATH输出:

/usr/local/clang_9.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

当我在source ~/.profile那里运行所有东西时,一切都完全符合我的预期,但这不是 .profile 行为。

我在这里看过这里和其他帖子 ,但仍然一无所获。

我的 ~/.profile :

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

_byobu_sourced=1 . /usr/bin/byobu-launch 2>/dev/null || true

有任何想法吗?

编辑:我确实有$HOME/bin目录

kubuntu environment-variables .profile
  • 1 个回答
  • 351 Views
Martin Hope
Works for a Living
Asked: 2020-04-09 21:17:39 +0800 CST

从自定义文件设置全局环境变量

  • 1

我正在尝试执行一个包含环境变量的文件,以便每当我登录时,这些变量都可以立即访问。

该$PATH变量是在/etc/environment下面定义的,我把:

. /path/to/variables

我认为不需要变量,chmod 755因为如果我手动运行上述内容,它就可以工作。但我试过chmod 755了,它仍然没有在会话开始时加载。

在里面/path/to/variables我设置了几个变量。它们都工作正常,但只有当我. /path/to/variables在每个新会话上手动运行时。

我也尝试过放置. /path/to/variables在我的内部~/.profile并重新启动会话。还是不行。

是的,我可以将我的变量声明放在/etc/environment自己内部,但我想将它们存储在我自己的文件中以用于组织目的。

我是否遗漏了一些明显的东西或完全错误?

environment-variables .profile
  • 1 个回答
  • 1530 Views
Martin Hope
BlueSkies
Asked: 2020-03-04 15:32:03 +0800 CST

$PATH 环境变量中的相同字符串两次

  • 2

当我在 Ubuntu 18.04.3 的终端上运行 $PATH 时,它显示以下内容:

/home/ubuntu/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

$PATH ( ) 的第一部分/home/ubuntu/bin出现了两次。为什么?

我努力了:

grep PATH= ~/.{bash_profile,profile,bashrc}

并得到:

grep: /home/ubuntu/.bash_profile: No such file or directory
/home/ubuntu/.profile:    PATH="$HOME/bin:$PATH"
/home/ubuntu/.profile:    PATH="$HOME/.local/bin:$PATH"
/home/ubuntu/.bashrc:export PATH="$HOME/bin:$PATH"
command-line bash bashrc grep .profile
  • 2 个回答
  • 708 Views
Martin Hope
Nav
Asked: 2019-09-11 07:42:21 +0800 CST

为什么从 ~/.profile 调用 gdbus 输出不起作用?

  • 0

如果我打开一个终端并运行以下脚本,它工作正常。调用中的值gdbus被写入lockScreenTest.txt文件。屏幕锁定时值为 true,屏幕解锁时值为 false。

#!/bin/bash
while true; do 
    echo "$(gdbus call -e -d com.canonical.Unity -o /com/canonical/Unity/Session -m com.canonical.Unity.Session.IsLocked)" >> lockScreenTest.txt
    sleep 2
    echo "called" >> lockScreenTest.txt
done

但是,如果我将此行添加./lockScreenCheck.sh&到~/.profile并重新启动计算机,则输出gdbus不会写入lockScreenTest.txt. 相反,仅写入以下输出:

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called

called  

gdbus为什么从 运行脚本时输出不可用~/.profile?
我正在对此进行调查,因为我编写了一个 Java 程序,该程序需要检查屏幕是否被锁定,并且我正在使用大致以下命令进行操作:

String command = "gdbus call -e -d com.canonical.Unity -o /com/canonical/Unity/Session -m com.canonical.Unity.Session.IsLocked";
p = Runtime.getRuntime().exec(command);
p.waitFor(); 

与 bash 脚本一样,如果我从带有 的终端运行 Java 程序,它也可以正常工作java -jar program.jar,但如果我从 调用它~/.profile,Java 程序会运行,但 gdbus 命令的输出是难以捉摸的。

bash java dbus .profile
  • 1 个回答
  • 209 Views
Martin Hope
ShoshK
Asked: 2019-09-10 12:18:56 +0800 CST

Stata 安装:如何将 stata 添加到 .profile PATH?

  • 0

我对 Linux 完全陌生,不知道该怎么做。我想做的是以下几点:我想在 Ubuntu 18.04.3 LTS 64 位上安装 Stata 16。我按照 stata 安装指南进行操作,到目前为止一切正常。现在我被要求这样做:

如果您使用 bash 、 sh 或 ksh ,则 .profile (在您的主目录中)中有一行看起来像

PATH="/bin:/usr/bin:/usr/local/bin:$HOME/bin"

编辑文件并将 /usr/local/stata 添加到列表中:

PATH="/bin:/usr/bin:/usr/local/bin:$HOME/bin:/usr/local/stata"

我的问题是:我的 .profile 中没有一行看起来像上面的行。我的 .profile 说:

如果运行 bash if [ -n "$BASH_VERSION" ]; 然后

# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then   . "$HOME/.bashrc"
fi fi

如果 [ -d "$HOME/bin" ] 存在,则设置 PATH 以包含用户的私有 bin(如果存在);然后

PATH="$HOME/bin:$PATH" fi

如果 [ -d "$HOME/.local/bin" ] 存在,则设置 PATH 以包含用户的私有 bin(如果存在);然后

PATH="$HOME/.local/bin:$PATH" fi

我的主目录中仅有的文件是 .bash_history、.bash_logout、.bashrc、.profile 和 .sudo_as_admin_successful。

为了将 stata 包含到 PATH 中,我需要做什么?有人可以如此友善地引导我完成这些步骤吗?

附带问题:我的键盘有一些错误。它不能再写任何需要 AltGr 键的标志了。

非常感谢您!

bash .profile
  • 1 个回答
  • 460 Views
Martin Hope
Mauricio Gtz
Asked: 2019-04-22 12:38:29 +0800 CST

Ubuntu 19.04 .bash_profile 不存在

  • 1

我正在尝试从他们的站点设置 WP-CLI 完成, 但我在我的主目录中找不到该~/.bash_profile文件,我尝试了该~/.bashrc文件的说明,我也遵循了 zsh 说明,但它没有用。没有.bash_profile 正常吗?如果我手动创建它会好吗? 终端文件

files .profile
  • 1 个回答
  • 963 Views
Martin Hope
Nick
Asked: 2019-04-18 20:42:19 +0800 CST

如何将 .sh 文件或路径添加到 .profile 以运行我的应用程序?

  • 1

在家里我有一个项目文件夹nomse/bin/main.dart。在终端。如果我使用类似的命令,

dart nomse/bin/main.dart 

我可以运行我的应用程序。

UPDATE-1: 我需要添加路径,.profile以便无需在终端上输入路径即可运行我的应用程序。(我知道如何为 .profile 添加路径),请耐心等待。

我所需要的只是(作为一个例子,因为我不知道该怎么做)我需要在 .profile 中添加 nomse/bin/main.dart 并像 dart nomse 一样运行。

我需要为我的路径命名,例如 nomse。所以我可以像 dart nomse 一样奔跑。我怎么做?

更新2:

in .profile I add path as 
PATH="$HOME/.nomse/bin/main.dart:${PATH}"
export PATH

如何为我的路径命名,以便可以在终端上运行?

dart nomse
scripts command-line bashrc .profile
  • 2 个回答
  • 1818 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve