在我的文件系统上,文件 /var/log/lastlog 非常大
ll /var/log/lastlog
-rw-rw-r-- 1 root utmp 494536286056 May 28 17:27 /var/log/lastlog
是否有一种 Ubuntu 原生的方式来记录它?
在我的文件系统上,文件 /var/log/lastlog 非常大
ll /var/log/lastlog
-rw-rw-r-- 1 root utmp 494536286056 May 28 17:27 /var/log/lastlog
是否有一种 Ubuntu 原生的方式来记录它?
我已经读过这篇关于在哪里放置别名的帖子。
现在,假设我的自定义命令非常复杂(在输入中接受参数,由几个相继运行的命令组成,为了清楚起见,我想将其保留为多行,涉及引号、双引号等),所以我想将它定义为一个函数,例如
sshdev_system_loop () {
while true; do
echo "[$(date +'%Y-%m-%d %H:%M:%S')] Trying to log into ststem $2 as user $1 ."
timeout 10 ssh $1@$2
done
}
我应该把它放在.bash_aliases
或 的末尾.bashrc
或 中.profile
吗?
一方面,我不想把它放进去,.bash_aliases
因为它会“破坏”列表
alias alias_name='command/list of commands'
另一方面,.bashrc
它看起来像是操作系统管理的文件,所以我不想向其中添加内容。
那么在 Ubuntu 中将功能添加为自定义命令的最佳实践是什么?
今天,当我启动 Virtualbox VM 并尝试启用第二个屏幕时,我发现启用它的按钮已“变灰”并且无法单击。直到昨天它还在工作。
我做了一些研究,发现几个线程(即这个)表明问题可能出在 VM Guest Additions 上。实际上,其他功能(例如主机和来宾操作系统之间的复制粘贴)被禁用。
因此,我尝试从 VM 顶部菜单(设备 > 升级来宾添加)更新 Virtualbox 来宾添加,但出现以下弹出错误:
Creating installation directory "/tmp/" on guest failed: VERR_NOT_FOUND.
Result Code:
VBOX_E_IPRT_ERROR (0X80BB0005)
Component:
GuestSessionWrap
Interface:
IGuestSession {234f0627-866d-48c2-91a5-4c9d50f04928}
我已经检查了我的机器上是否存在 /tmp/ 目录,但我猜由于某种原因它无法在那里下载新的安装文件。
所以我想通过终端更新 Virtualbox Guest Additions。
我该怎么做?
通过遵循本教程,我尝试重新安装来宾添加项
sudo apt update
我在这里收到消息
4 packages can be upgraded. Run 'apt list --upgradable' to see them
然后出现此错误消息:
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-hidpi (main/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (restricted/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-small (restricted/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-hidpi (restricted/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (restricted/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (restricted/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
E: The repository 'http://security.ubuntu.com/ubuntu hirsute-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-hidpi (main/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (restricted/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-small (restricted/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-hidpi (restricted/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (restricted/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (restricted/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-hidpi (main/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11 (restricted/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-small (restricted/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target DEP-11-icons-hidpi (restricted/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (restricted/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target CNF (restricted/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:50
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-hidpi (main/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Packages (restricted/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (restricted/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target Translations (restricted/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (restricted/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11 (restricted/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-small (restricted/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons (restricted/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target DEP-11-icons-hidpi (restricted/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (restricted/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
W: Target CNF (restricted/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:48 and /etc/apt/sources.list:51
所以我跑
apt list --upgradable
并得到
tommaso@tommaso-VirtualBox:~$ apt list --upgradable
Listing... Done
gjs/jammy-updates 1.72.4-0ubuntu0.22.04.1 amd64 [upgradable from: 1.72.2-0ubuntu2]
libgjs0g/jammy-updates 1.72.4-0ubuntu0.22.04.1 amd64 [upgradable from: 1.72.2-0ubuntu2]
transmission-common/jammy-updates,jammy-updates 3.00-2ubuntu2.1 all [upgradable from: 3.00-2ubuntu2]
transmission-gtk/jammy-updates 3.00-2ubuntu2.1 amd64 [upgradable from: 3.00-2ubuntu2]
然后
sudo apt install build-essential linux-headers-$(uname -r) -y
VM顶部菜单> Guest Additions CD Image,似乎什么也没发生,但我猜是因为它们已经安装了,但没有更新。
cd /media/<MY_USER>/VBox_GAs_7.0.4/
sudo ./VBoxLinuxAdditions.run
但我得到
Cannot reload kernel modules: one or more modules is still in use
所以我重新启动虚拟机,然后sudo ./VBoxLinuxAdditions.run
再次运行,但没有任何变化。
我已经更新了 VirtualBox 应用程序,但这并不能解决问题。
我在 Ubuntu 22.04 上安装了 postgres 13.10 和 PGAdmin4 7.1
在 PGAdmin4 UI 中,我想使用这些配置“添加新服务器”
name
postgres-local
username
postgres
pw
postgres
hostanme / address
127.0.0.1
port
5432
server group
Servers
所以我在我的终端运行
sudo -i -u postgres
psql
ALTER USER postgres WITH PASSWORD 'postgres';
然后我登录到 PGAdmin4,尝试添加新服务器插入上面的配置,但是当我点击保存时我得到这个错误
unable to connect to server: connection failed: connection refused is the server running on that host accepting tcp/ip connections?
可能是什么问题呢?
我已经通过sudo service postgresql status
.
我已经尝试过
编辑文件/etc/postgresql/13/main/postgresql.conf
取消注释
listen_addresses = 'localhost'
并将其更改为
listen_addresses = '*'
编辑文件/etc/postgresql/13/main/pg_hba.conf
更改行
# IPv4 local connections:
host all all 127.0.0.1/32 md5
到
# IPv4 local connections:
host all all 0.0.0.0/0 md5
重新启动 postgres
sudo service postgresql restart
但我没有成功。
我需要一个单行命令,给定一个端口号,返回有关启动在该端口上运行的进程的命令的信息。
通常,我通过运行一个sudo netstat
sudo netstat -antpv | grep PORT_NUMBER
它返回PID_NUMBER
第 4 列,在列字符 ( :
) 之后,然后我使用PID_NUMBER
作为输入的ps aux
ps aux | grep PID_NUMBER
它在第 11 列返回有关“启动命令”的信息。
例如
# use the port number to get the process id
my_machine:~$ sudo netstat -antpv | grep 30001
tcp 0 0 0.0.0.0:30001 0.0.0.0:* LISTEN 616/python
# use the process id to get info on the command which started the process
my_machine:~$ ps aux | grep 616
my_user 616 0.8 0.5 220112 89596 ? S 01:10 6:59 /usr/bin/python my_program.py --log=INFO
是否可以通过一行命令获取此信息?
例如
my_machine:~$ ps aux | grep get_only_the_number_after_the_column_character_in_the_4th_column_of(sudo netstat -antpv | grep PORT_NUMBER)
/usr/bin/python my_program.py --log=INFO
我几乎在做。
我得到我想要的
my_machine ~$ ps aux | awk '{if ($2 == "616") print $0;}'
my_user 616 0.7 0.5 220112 89596 ? S 01:10 8:11 /usr/bin/python my_program.py --log=INFO
但是当我尝试将 PID 保存在 bash 变量中然后将其传递给 awk 时它不起作用
my_machine:~$ mypid=$(sudo lsof -ti :30001)
my_machine:~$ echo $mypid
616
my_machine:~$ ps aux | awk '{if ($2 == "$mypid") print $0;}'
my_machine:~$
my_machine:~$ ps aux | awk -v mypid="$mypid" '{if ($2 == "mypid") print $0;}'
my_machine:~$
my_machine:~$ ps aux | awk -v mypid="616" '{if ($2 == "mypid") print $0;}'
my_machine:~$
我想在无法连接到互联网的运行 Ubuntu Server OS(无 GUI)的 PC(我们称之为 PC_1)上重新安装 Ubuntu。
为此,我已经从另一台 PC 下载了Ubuntu 18.04 iso,但我不知道该怎么做。
我已经用Balena Etcher在 USB 驱动器上刷新了 iso ,但是我不知道如何继续。
我想我应该将 USB 驱动器连接到 PC_1,找到 USB 驱动器并从命令提示符运行一些东西来告诉 PC 从 USB 驱动器安装 Ubuntu OS....
我应该运行哪些命令?
我正在尝试调整在 Windows 10 上运行的 VM(Virtualbox)内运行的 Ubuntu 操作系统的硬盘大小(从 20 GB 到 270 GB)。
按照这个线程中的说明,我关闭了我的虚拟机并在我的 Windows 10 Powershell 上运行:
C:\Users\Bob> C:\"Program Files"\Oracle\VirtualBox\VBoxManage.exe modifyhd C:\Users\Bob\"VirtualBox VMs"\Tommaso_Ubuntu01\Tommaso_Ubuntu01.vdi --resize 270000
我很容易得到
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
这样当我在 Virtualbox 面板上检查我的虚拟机设置时,我会看到:
然后我继续按照线程中的步骤进行操作:我启动我的虚拟机,转到
应用程序(底部栏中的 9 点正方形)> 磁盘 > 硬盘(左侧栏)
然后
选择Partition 3
(我之前调整为 21 的分区)> 齿轮按钮 > 调整大小 > 将分区设置为 270 GB
但我得到:
调整分区大小时出错
调整分区 /dev/sda3 大小时出错:无法在设备“/-dev/sda/”上进行分区大小(无法满足分区上的所有约束。)(udisk-error-quark,0)
有什么问题?我该如何解决?
我正在开发在 Windows 10 上由 Virtualbox 制成的 VM 内运行的 Ubuntu。
通过寻找一种方法来选择终结者终端中的所有文本,我开始关注这个 AU 线程,指示如何安装Thierry Ds copyall-Terminator-Plugin。
copyall.py插件由 Enno Gröper 修改并转换为selectall.py插件,可在 Github 上找到。
我试图重做 AU 线程中提到的步骤,但我无法让我的插件工作:
从我的终结者:
cd /usr/share/terminator/terminatorlib/
sudo mkdir plugins
cd plugins
sudo vim selectall.py
我将来自https://github.com/egroeper/terminator-plugins/blob/master/selectall.py的代码粘贴到那里
退出并保存并检查文本是否有效保存在那里
重启终结者
右键单击终结者 > 首选项 > 插件
但是没有新插件。
我怎样才能让它出现和工作?
- - 更新 - -
为了给你更多的背景信息,我在这里粘贴:
ls -al /usr/share/terminator/terminatorlib/plugins/