如何$@
在不首先将所有位置参数复制到这样的另一个数组的情况下在 Bash 中获取切片?
argv=( "$@" )
echo "${argv[@]:2}";
Run Code Online (Sandbox Code Playgroud) 我的系统使用dm-crypt
和完全加密LVM
。我最近将加密分区从/dev/sda5
到/dev/sda2
.
我的问题是:如何将加密分区映射到的名称从sda5_crypt
更改为sda2_crypt
?
我可以正常启动系统。但是我在启动时得到的提示(sda5_crypt)
虽然UUID
映射到/dev/sda2
:
Volume group "vg" not found
Skipping volume group vg
Unlocking the disk /dev/.../UUID (sda5_crypt)
Enter passphrase:
Run Code Online (Sandbox Code Playgroud)
我想现场引导,解密sda2
,激活vg
,chroot
来/dev/vg/root
和运行update-grub2
,但无济于事。
仅仅编辑/etc/crypttab
也不起作用。
如果没有给出路径,为什么会find
打印出导致./
结果的结果?
$ find
./file1
./file2
./file3
Run Code Online (Sandbox Code Playgroud)
不打印出来的原因是什么?
$ find
file1
file2
file3
Run Code Online (Sandbox Code Playgroud) 在ext4
文件系统中,假设file1
有 inode number1
和file2
inode number 2
。现在,无论任何crtime
可能可用的时间戳如何,假设它的file1
创建时间早于file2
仅因为 inode1
小于inode是错误的2
吗?
如何知道foo
压缩文件的原始原始时间戳gzip
而无需解压缩foo.gz
?
gzip --verbose --list foo.gz
并且file foo.gz
将打印格式的日期和时间。
我知道我可以\
enter在bash
命令行的末尾键入以在另一行中继续该命令。但是我怎样才能将一个提示命令行——已经完全输入——分成两部分?
例如,我怎样才能在then
不必切断剩余部分并重新输入的情况下打破这条线?
$ if true; then ls; fi
Run Code Online (Sandbox Code Playgroud) 如何创建 zip 文件v2.0?
似乎 OpenDocument 文件是 zip 文件 v2.0:
$ file foo.odt
foo.odt: OpenDocument Text
$ hexdump -C -n 16 foo.odt
00000000 50 4b 03 04 14 00 00 08 00 00 03 0d 47 42 5e c6 |PK..........GB^.|
00000010
Run Code Online (Sandbox Code Playgroud)
第五个字节是0x14
。
但是,如果我解压缩foo.odt
并将其压缩回bar.odt
.zip 文件,则会得到一个 v1.0 zip 文件:
$ unzip -d foo foo.odt
$ cd foo/
$ zip -0 -X ../bar.odt mimetype
$ zip -r ../bar.odt * -x mimetype
$ file ../bar.odt
bar.odt: Zip …
Run Code Online (Sandbox Code Playgroud) 我可以在{}
扩展中使用变量而不吸引eval
吗?如果是这样,如何?
这不起作用:
$ touch 1.foo 1.bar
$ ls 1.{foo,bar}
1.bar 1.foo
$ extensions=foo,bar
$ ls 1.{$extensions}
ls: cannot access 1.{foo,bar}: No such file or directory
Run Code Online (Sandbox Code Playgroud)
它适用于eval
:
$ eval ls 1.{$extensions}
1.bar 1.foo
Run Code Online (Sandbox Code Playgroud) 如何持续阻止wpa_supplicant
在漫游模式下使用的无线接口连接到特定的开放网络foo
?
这不起作用:
$ sudo wpa_cli
> blacklist 00:11:22:33:44:55
FAIL
Run Code Online (Sandbox Code Playgroud)
以下内容也没有:
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
Run Code Online (Sandbox Code Playgroud)
network={
ssid="foo"
key_mgmt=NONE
priority=0
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个加密卷并将LUKS
其上传到不受信任的主机上的远程目录。
不过我可以在本地安装它。我首先在本地安装远程目录sshfs
,然后打开我的卷,就 cryptsetup
好像它是本地文件一样。
$ sshfs user@host: remote/
# cryptsetup luksOpen remote/disk.img disk
$ mount /dev/mapper/disk mount_point/
Run Code Online (Sandbox Code Playgroud)
mount_point/
我的问题是:我是否可以使远程主机上的用户看到任何内容?另外,我在挂载的目录中执行的命令sshfs
对远程主机上的管理员来说是透明的吗?
假设我安排了一个at
作业在 3 小时后运行:
$ echo command | at now +3 hours
$ atq
9 Mon Dec 5 14:00:00 2016 a nr
Run Code Online (Sandbox Code Playgroud)
但是过了 1 小时后我改变了主意,然后需要立即#9
从队列中运行该特定作业a
,即比计划运行的时间早 2 小时。
我该怎么做?
我知道我可以将作业命令打印到stdout
,将其复制并粘贴到命令行,手动运行它,然后删除作业#9
:
$ at -c 9
command
$ command
$ atrm 9
Run Code Online (Sandbox Code Playgroud)
但这相当于运行另一个作业,而不是#9
从 queue 运行a
。
如何将不可见标记埋入随机文本行中?这样的标记必须存在,但对于阅读打印在控制台上的文本的人来说,它是不可见的。
我想通过一个不可见的标记来识别这些行,例如,稍后将它们放入或取出。
我试过0x00
没有成功。我希望grep
在0x00
某处打印匹配的行。但这不起作用:
$ echo -e "a\0b" | hexdump -C
00000000 61 00 62 0a |a.b.|
00000004
$ echo -e "a\0b" | grep "a\0b"
Run Code Online (Sandbox Code Playgroud)