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
    • 最新
    • 标签
主页 / user-332437

emk2203's questions

Martin Hope
emk2203
Asked: 2023-08-18 23:10:26 +0800 CST

不小心删除了系统`uuidd`用户和组——要重新安装哪个包?

  • 5

uuidd我不小心从系统中删除了系统用户及其组。

uuidd我想重新安装它们所属的软件包,但是当我在网上查找手册时,它引用了该util-linux软件包。重新安装此软件包sudo apt --reinstall install util-linux不会恢复此用户。

如何找到要重新安装和修复系统的软件包?

package-management
  • 1 个回答
  • 13 Views
Martin Hope
emk2203
Asked: 2020-10-12 03:19:14 +0800 CST

在启动时以与文件管理器相同的方式挂载分区 - 不是 /etc/fstab

  • 1

我想在登录后挂载一个分区,就像我单击“设备”下的未挂载设备时文件管理器一样。理想情况下,我想使用文件管理器使用的相同底层守护进程。

它不应该通过 fstab 安装。基本上,结果应该就像我在登录后打开文件管理器并单击设备一样,无需提升权限,用户不可挂载,相同的访问权限,在文件层次结构中的相同位置(/media/user/partitionlabel-or-UUID)。

登录后 - 例如,可以为不同的用户安装不同的设备。

怎么可能做到这一点?搜索淹没了海量答案中的相关信息/etc/fstab。在登录时安装 samba fs 的一个建议答案在这里没有帮助。

mount login
  • 2 个回答
  • 542 Views
Martin Hope
emk2203
Asked: 2020-08-29 01:36:31 +0800 CST

是否可以检查连接是本地连接还是通过 ssh *after* 使用 `sudo` 提升到 root 帐户?

  • 5

我想看看我是通过 ssh 连接还是运行本地终端。

如果我只是 ssh 进入服务器而不通过更改为 root sudo,这很容易。任何变量$SSH_CLIENT,$SSH_CONNECTION或$SSH_TTY可用于检查一个是通过 SSH 连接还是本地连接。

问题:当我提升到 root 帐户sudo -i以执行管理任务时,这些变量都没有帮助 - 它们都是空的。

找出连接是本地连接还是通过 SSH 的最佳方法是什么?

编辑:通过接受的答案,很容易有一个反映 ssh 状态和权限的不显眼的 bash 提示:

if [ "$color_prompt" = yes ]; then
    # when system is accessed via SSH, hostname with light grey background
    if [[ $(pstree -s $$) = *sshd* ]]; then sshbg="\[\033[48;5;7m\]"; fi
    # when used as root, change username to orange and '#' to red for prompt
    if [ $(id -u) -eq 0 ]; then usercol="\[\033[38;5;3m\]"; hashcol="\[\033[38;5;1m\]"; else usercol="\[\033[38;5;2m\]"; fi
    # bash PS1 prompt
    PS1="${usercol}\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;4m\]${sshbg}\h\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;6m\]\w\[$(tput sgr0)\]${hashcol}\\$ \[$(tput sgr0)\]"
    unset sshbg rootcol hashcol
fi

该pstree部分的定时版本运行时间不到 20 毫秒,因此可以在不引入明显延迟的情况下使用它。

networking server command-line ssh
  • 2 个回答
  • 766 Views
Martin Hope
emk2203
Asked: 2020-03-21 00:49:39 +0800 CST

如何使用 zfs-on-root 重新安装 Ubuntu 双引导?

  • 2

我正在使用以 zfs 作为根文件系统的 Ubuntu 系统(19.10)。

我将系统安装为双引导系统,方法是安装在一个较小的磁盘上,然后将分区转移到一个较大的磁盘上,其中已经有 Windows 分区,因此 gpt 分区方案现在具有以下分区:

第 1 部分 - UEFI 引导 - /boot/efi
第 2 部分 - Grub 引导分区 - /boot/grub
第 3 部分 - 交换
第 4 部分 - zfs 引导 (bpool)
第 5 部分 - zfs root (rpool)
第 6 部分 - Windows MSR
第 7 部分 - Windows系统
第 8 部分 - Windows RE

所以,我现在想重新安装系统,原因不相关。如果它更灵活,我什至愿意测试 20.04。我怎样才能最好地重新安装系统?普通的 Ubuntu 安装程序不了解 zfs,并且 zfs 选项仅适用于整个磁盘。

换句话说,我想再次安装 Ubuntu,第 3 - 5 部分可以删除/格式化,其他部分应该保持不变。

system-installation dual-boot uefi zfs
  • 1 个回答
  • 1436 Views
Martin Hope
emk2203
Asked: 2018-09-07 04:00:27 +0800 CST

如何在 tmux 会话中配置 conky?

  • 3

我想在我的tmux会话中有一个自定义页脚conky,我的 conky 配置按照 conky 官方推荐screen:

conky.config = {
    out_to_x = false,
    out_to_console = true,
    total_run_times = 1
};
conky.text = [[${time %H:%M}|free space:${fs_free /}|$loadavg|free mem:$memeasyfree]]

tmux仅包含一行.tmux.conf:

set-option -g status-left "#(conky -i 1 -c ~/.conkyintmux) |"

但是当我开始时tmux,页脚行显示

13:48|free0:bash*                                     "D830-2" 13:48 06-Sep-18

并且没有任何.tmux.conf(不叫 conky),它会读

[0] 0:bash* "D830-2" 13:53 06-Sep-18

预期输出:

13:48|free space:8.0GB|0.1 0.1 0.1|free mem:548MB|[0] 0:bash* "D830-2" 13:53 06-Sep-18

开始看看是否一切都如预期的那样。

我怎样才能改变 的行为tmux?

conky console tmux
  • 1 个回答
  • 409 Views
Martin Hope
emk2203
Asked: 2018-02-24 09:47:08 +0800 CST

dist 升级后手册页损坏

  • 8

在最近一次 dist-upgrade 之后,我破坏了手册页。症状是man <any command here>拒绝加载任何内容并显示空白控制台,除了左上角的行:

Manual page man(1) line ?/? (END) (press h for help or q to quit)

退出后,我收到以下错误行:

man: command exited with status 4: /usr/lib/man-db/zsoelim | /usr/lib/man-db/manconv -f UTF-8:ISO-8859-1 -t UTF-8//IGNORE | preconv -e UTF-8 | tbl | nroff -mandoc -rLL=195n -rLT=195n -Tutf8

这对我没有帮助。我试过了sudo mandb,sudo mandb -c但没有成功。

manpage
  • 1 个回答
  • 1519 Views
Martin Hope
emk2203
Asked: 2018-02-14 09:19:16 +0800 CST

尽管在 .bashrc 中设置了 PS1,但无法获得彩色提示

  • 1

我通过 ssh 登录的其中一台机器没有给我一个彩色提示,尽管它是通过.bashrc. 有问题的.bashrc部分是

# 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
    if [ $(id -u) -eq 0 ];
    then # you are root, make the prompt red
        PS1='${debian_chroot:+($debian_chroot)}\[\e[00;33m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]\e[01;31m#\e[00m '
    else
        PS1='${debian_chroot:+($debian_chroot)}\[\e[00;32m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]$ '
    fi
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

我在其他几台机器上使用它并获得所需的结果。

我不知道为什么这台特定的计算机不使用 this .bashrc。如果我使用

export PS1='${debian_chroot:+($debian_chroot)}\[\e[00;32m\]\u\[\e[00m\]@\[\e[00;34m\]\h\[\e[00m\]:\[\e[00;36m\]\w\[\e[00m\]$ '

(上面的行),我的提示得到了所需的格式。/etc/bash.bashrc也存在,/etc/profile在我看来都不错。

另外,如果我 ssh 进入这台计算机,xterm 标题不会被设置。通常,它被设置为这台机器的 user@host。我怀疑同样的根本原因,但我不知道去哪里找。

command-line ssh bash bashrc prompt
  • 1 个回答
  • 1344 Views
Martin Hope
emk2203
Asked: 2017-03-02 10:38:43 +0800 CST

仅当 vpn 启动时才运行 cronjob / 定期作业

  • 0

我有一个脚本,只有在 VPN启动时才想运行。

当 VPN 启动和关闭时,我可以通过 OpenVPN 运行作业,但我希望在 VPN 启动时定期运行一项作业,而不是在它关闭时运行。

实现这一目标的最优雅的方法是什么?

scripts
  • 1 个回答
  • 1474 Views
Martin Hope
emk2203
Asked: 2016-03-16 05:56:13 +0800 CST

如何通过 rdp 远程进入 16.04

  • 13

所有可用信息均适用于古代版本,因此这里专门针对 16.04:

是否可以通过带有 mstsc.exe 的 MSWindows PC 远程访问运行 xrdp 的 Ubuntu 16.04 PC,而无需安装备用桌面?

这自 12.04 以来就被破坏了,所以这里的任何更新都将不胜感激。

rdp
  • 1 个回答
  • 79839 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