如何$@在不首先将所有位置参数复制到这样的另一个数组的情况下在 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和file2inode 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)