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-388102

the_velour_fog's questions

Martin Hope
the_velour_fog
Asked: 2017-03-12 02:25:04 +0800 CST

如何将所需的编辑器添加到“update-alternatives”交互式菜单?

  • 8

我刚刚在数字海洋服务器上安装了 ubuntu 16.04.2 32 位。

Digital Ocean 稍微调整了 ubuntu 安装,例如,他们安装了完整的 vim 作为他们在 VPS 中使用的块映像的一部分。我现在想使用这个 - 预安装的 - vim 作为我的默认编辑器。所以我跑

sudo update-alternatives --config editor

这给出了这个菜单

$ sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

Press <enter> to keep the current choice[*], or type selection number:

注意:vim 不作为一个选项

我认为数字海洋没有将 vim 安装添加到更新替代系统中?将程序添加到此菜单
的推荐方法是什么? 我想我可以覆盖替代系统添加的符号链接,或者添加指向的符号链接?但我想在数字海洋黑客之上进行“黑客”之前尝试“官方”方式。/user/bin/vim
/usr/bin/editor/etc/alternatives/usr/bin/vim

alternative
  • 3 个回答
  • 9046 Views
Martin Hope
the_velour_fog
Asked: 2016-08-07 02:05:28 +0800 CST

为什么这个 gsettings 命令在 16.04 和 16.04.1 之间停止工作?

  • 1

我在 16.04 上使用这段代码(shell 脚本)与 Gnome 终端配置文件进行交互,它运行良好

profile=$(gsettings get org.gnome.Terminal.ProfilesList default)
profile=${profile:1:-1} # remove leading and trailing single quotes
org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:${profile}/ \
background-transparency-percent

然后,我现在通过安装 16.04.1 来更新系统,当我通过脚本或命令行运行上述命令时,gsettings只返回其“使用”消息:

$ gsettings get org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:${profile}/
用法:gsettings [--schemadir SCHEMADIR] get SCHEMA[:PATH] KEY ...

我需要做什么才能让这个命令再次工作?

gsettings
  • 1 个回答
  • 456 Views
Martin Hope
the_velour_fog
Asked: 2016-05-20 23:44:01 +0800 CST

如何在 Ubuntu 16.04 中使用命令行设置 mac 地址?

  • 6

对于 Ubuntu 14.04,当我想使用不同的 mac 地址连接到网络时,我会运行以下命令

sudo service network-manager stop
sudo ifconfig $interface down
sudo macchanger -m <mac_addresse> $interface
sudo ifconfig $interface up
sudo service network-manager start

这将分配一个新的 MAC 地址,该地址在重新启动网络管理器并建立与网络的新连接后仍然存在。
现在,在 Ubuntu 16.04 上,使用

  • sudo macchanger -m 00:60:1B:EB:F8:73 wlp2s0

然后我重新启动network-manager但尚未连接到网络,新的macchanger分配的mac地址仍然存在,即

% nmcli dev show wlp2s0
GENERAL.DEVICE:                         wlp2s0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         00:60:1B:EB:F8:73
      address assigned by macchanger -->^^^^^^^^^^^^^^^^^
GENERAL.MTU:                            0
GENERAL.STATE:                          30 (disconnected)
GENERAL.CONNECTION:                     --
GENERAL.CON-PATH:                       --

但是当我连接到网络时,mac地址被重置回原来的硬件mac地址。连接到网络后

% nmcli  dev show wlp2s0
GENERAL.DEVICE:                         wlp2s0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         E0:06:E6:A3:2C:A7
   mac is back to original hardware  -->^^^^^^^^^^^^^^^^^

GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     lowfi
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
IP4.ADDRESS[1]:                         92.10.26.193/20
IP4.GATEWAY:                            92.10.24.1
IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:                             202.8.44.226
IP4.DNS[2]:                             202.8.47.10
IP6.GATEWAY:

使用命令行连接到网络时,如何使 macchanger 分配的 mac 地址保持不变?

networking
  • 1 个回答
  • 14961 Views
Martin Hope
the_velour_fog
Asked: 2016-04-18 15:34:59 +0800 CST

同一个包的多个版本可以在同一个系统上共存吗?

  • 11

为了安装 tmux 2.1,我需要安装libtinfo5版本 6,我通过下载包含libtinfo5并直接使用命令安装的 .deb 存档来做到这一点:

sudo dpkg -i libtinfo5_6.0+20160213-1ubuntu1_amd64.deb

这满足了 tmux 2.1 的依赖并且 tmux 安装正常。
现在我尝试使用安装 vnstat

sudo apt-get install vnstat 

apt-get错误退出了以下

$ sudo apt-get install vnstat
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libncurses5 : Depends: libtinfo5 (= 5.9+20150516-2ubuntu1) but 6.0+20160213-1ubuntu1 is to be installed
 libncursesw5 : Depends: libtinfo5 (= 5.9+20150516-2ubuntu1) but 6.0+20160213-1ubuntu1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我的理解一直是 Ubuntu 的包管理系统能够安装和管理同一个包的多个版本,就像这种情况一样。换句话说 apt/dpkg 识别

  • tmux需要 libtinfo5 -version 6工作
  • vnstat需要 libtinfo5 -version 5工作

然后 apt/dpkg 说没关系,我会安装两个版本。
我可以看到某些程序如何像系统二进制文件一样,例如,bash或者ls只能安装一次,因为大多数调用只是说bash -c "<command>"而不是bashv.3.2 -c "<command>"。
所以我的问题是包管理器可以安装和管理多个依赖项吗?或者这是不可能的,因为就像上面的 bash 示例一样,大多数程序通过依赖项名称调用依赖项而不指定版本。在哪种情况下,问题超出了包管理器的控制(即,它更多的是编程编译/配置/组织问题)并且包管理器此时放弃了?

apt
  • 2 个回答
  • 19743 Views
Martin Hope
the_velour_fog
Asked: 2015-11-22 19:48:26 +0800 CST

为什么这个 cron 作业不起作用?

  • 0

我正在使用 Ubuntu 14.04 并在以下脚本中创建/etc/cron.hourly并使其可执行

文件名:remove_old_tmux_resurrect_saves

#! /bin/bash

ls ~/.tmux/resurrect/* -1dtr | head -n -10 | xargs -d '\n' rm -f



$ ls -al ~/.tmux/resurrect/

total 120
drwxrwxr-x 3 admin admin 61440 Nov 22 16:35 .
drwxrwxr-x 4 admin admin  4096 Nov  5 04:02 ..
lrwxrwxrwx 1 admin admin    38 Nov 22 16:35 last -> tmux_resurrect_2015-11-22T16:35:29.txt
drwxrwxr-x 2 admin admin  4096 Nov 22 16:35 pane_contents
-rw-rw-r-- 1 admin admin 11237 Nov 22 16:35 pane_contents.tar.gz
-rw-rw-r-- 1 admin admin   692 Nov 22 02:53 tmux_resurrect_2015-11-22T02:53:49.txt
-rw-rw-r-- 1 admin admin   692 Nov 22 05:09 tmux_resurrect_2015-11-22T05:09:18.txt
-rw-rw-r-- 1 admin admin   692 Nov 22 05:24 tmux_resurrect_2015-11-22T05:24:20.txt
-rw-rw-r-- 1 admin admin   692 Nov 22 05:39 tmux_resurrect_2015-11-22T05:39:23.txt
-rw-rw-r-- 1 admin admin   795 Nov 22 05:41 tmux_resurrect_2015-11-22T05:41:37.txt
-rw-rw-r-- 1 admin admin   795 Nov 22 05:54 tmux_resurrect_2015-11-22T05:54:32.txt
-rw-rw-r-- 1 admin admin   795 Nov 22 16:05 tmux_resurrect_2015-11-22T16:05:08.txt
-rw-rw-r-- 1 admin admin   943 Nov 22 16:20 tmux_resurrect_2015-11-22T16:20:15.txt
-rw-rw-r-- 1 admin admin   795 Nov 22 16:35 tmux_resurrect_2015-11-22T16:35:29.txt

当我手动运行它时它工作正常,当我检查 cron 是否接受它作为工作时它工作正常,即

sudo run-parts --test /etc/cron.hourly

输出

/etc/cron.hourly/remove_old_tmux_resurrect_saves

的输出cat /etc/crontab

$ cat crontab 
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
  • 应该发生什么:脚本删除该目录中除最近的 10 个文件之外的所有文件
  • 发生了什么:没有

有谁知道为什么这不起作用?

cron
  • 1 个回答
  • 250 Views
Martin Hope
the_velour_fog
Asked: 2015-11-20 17:12:18 +0800 CST

服务如何在 Ubuntu 14.04、Upstart、SysV 或两者的组合中启动?

  • 3

我在一台开发机器上安装了这两个网络服务器,因为它们都绑定到端口 80,所以在任何给定时间只能运行一个。
我希望能够修改init启动过程,这样我就可以选择启动哪个,禁用哪个。
为了知道我需要做什么来实现这一点,我正在尝试找出实际控制这些服务启动的因素。
我的理解是 Ubuntu 14.04 启动脚本由 Upstart 处理,而 upstart 初始化脚本在/etc/init.
但是 nginx 中没有nginx.conf条目/etc/init而是有条目/etc/init.d- 这是否意味着 Nginx 由 SysV 而不是 Upstart 管理?
这是否也意味着默认情况下 Ubuntu 14.04(在 15.04 上迁移到 systemd 之前)可能使用 upstart 和 initV 的组合?
还是重要的系统进程仅由 Upstart 启动,而像 Nginx 这样的个别软件包可能会选择 upstart 或 systemV init?

server
  • 1 个回答
  • 6070 Views
Martin Hope
the_velour_fog
Asked: 2015-11-07 04:00:44 +0800 CST

Iptables 防火墙规则不会在服务器重启时恢复 [重复]

  • 1
这个问题在这里已经有了答案:
如何将这些 iptables 规则设置为在启动时运行 (2 个答案)
6 年前关闭。

我正在 Ubuntu 14.04 服务器的新实例上设置 iptables。
到目前为止我有:

  • 将 iptables 规则放入文件中/etc/iptables.firewall.rules
  • 创建一个脚本/etc/network/if-pre-up.d/iptablesload.sh并将以下代码放入其中
#!/bin/sh
iptables-restore < /etc/iptables.firewall.rules
exit 0

防火墙规则有效,例如,如果我从提示符下手动运行命令

$ iptables-restore < /etc/iptables.firewall.rules

应用 iptables 规则。但是当我重新启动服务器时,防火墙没有启动——我该如何解决这个问题?

networking
  • 1 个回答
  • 1718 Views
Martin Hope
the_velour_fog
Asked: 2015-08-26 16:58:32 +0800 CST

ctags 基本用法

  • 5

我正在关注如何exuberant-ctags在 Ubuntu 14.04 上使用的教程。
我运行命令:

sudo apt-get install exuberant-ctags

然后我cd进入一个项目的根文件夹并运行:

$ ctags -R .

我也试过

  • ctags -R *
  • ctags -R <folder_name>

在所有情况下,ctags 都会消耗所有计算机资源 - 锁定 PC,我需要终止该进程,之后一个tags数 GB 的文件将位于我的当前目录中。
出了什么问题?

更新

根据@muru 的要求,当我ctags -R .在一个完全空的目录中运行时,新创建的ctags文件包含:

!_TAG_FILE_FORMAT       2       /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /[email protected]/
!_TAG_PROGRAM_NAME      Exuberant Ctags //
!_TAG_PROGRAM_URL       http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.9~svn20110310 //
14.04
  • 1 个回答
  • 10024 Views
Martin Hope
the_velour_fog
Asked: 2015-06-05 01:57:54 +0800 CST

如何查看单个会话的互联网/网络使用情况?

  • 1

我想查看单个会话的互联网使用情况,例如,我连接到本地图书馆的 WiFi,限制为 200MB。是否可以连接并开始跟踪数据使用情况——从零开始,一直跟踪直到我重置或清除历史记录?

我调查过

  • Ubuntu 的预装system monitor- 这似乎跟踪了某个特定时期的总历史数据
  • vnstat - 同样的问题 - 默认情况下 - 它会聚合历史数据 - 例如,在已经存在和消失的会话中已经使用了多少数据。
networking
  • 1 个回答
  • 2524 Views
Martin Hope
the_velour_fog
Asked: 2015-04-13 18:06:19 +0800 CST

.deb 包控制文件在哪里?

  • 6

我的理解是基于 debian 的软件包有“控制文件”,它指定了关于如何安装软件包的元数据,例如它有什么依赖关系等。

如何查看已安装软件包的这些文件?

package-management
  • 3 个回答
  • 5801 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