小编NoE*_*ert的帖子

如何验证我的硬盘是否已清零/擦除?

我曾经shred擦拭过我的外部硬盘: sudo shred -vz /dev/sdb

我还应该补充一点,磁盘有 5 个坏扇区。

我想验证磁盘是否已归零,按照https://superuser.com/questions/1510233/is-there-a-faster-way-to-verify-that-a-drive-has-been-complete-zeroed

我不太熟悉dd,但我相信这些表明它已被归零:

sudo dd if=/dev/sdb status=progress | hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
5000916670976 bytes (5.0 TB, 4.5 TiB) copied, 45754 s, 109 MB/s
9767541167+0 records in
9767541167+0 records out
5000981077504 bytes (5.0 TB, 4.5 TiB) copied, 45756.7 s, 109 MB/s
48c61b35e00
Run Code Online (Sandbox Code Playgroud)
sudo dd if=/dev/sdb status=progress | od | head
5000952267264 bytes (5.0 TB, 4.5 TiB) copied, 45739 s, 109 …
Run Code Online (Sandbox Code Playgroud)

linux dd hard-disk shred

16
推荐指数
3
解决办法
7374
查看次数

OpenSSH:如果服务器设置为“PasswordAuthentication no”,那么如果 *client* 设置为“PasswordAuthentication yes”会不会有任何风险?

对于我所有的服务器PasswordAuthenticationnosshd_config文件中设置。这意味着只允许密钥验证。

在这种情况下,如果在客户端PasswordAuthentication设置为,是否有任何风险?yes ssh_config

ssh openssh sshd

2
推荐指数
1
解决办法
45
查看次数

测量脚本执行时间时的各种语法错误

使用 Cygwin (W10) 我历来用它来测量脚本中的执行时间:

#!/bin/sh

(time {
sleep 1;
})
Run Code Online (Sandbox Code Playgroud)

我现在已经转移到 Debian(Linux 的 Windows 子系统),同样的脚本给出了这个错误:

Syntax error: "}" unexpected (expecting ")")
Run Code Online (Sandbox Code Playgroud)



我也在这里尝试了两个建议的脚本:https : //askubuntu.com/a/431184但都失败了:

$ foo() {
    sleep 1;
    echo "Hello World"
  }
$ time foo
Hello World 
Run Code Online (Sandbox Code Playgroud)

$ foo() {
    sleep 1;
    echo "Hello World"
  }
$ export -f foo
$ echo foo | /usr/bin/time /bin/bash
Hello World
Run Code Online (Sandbox Code Playgroud)

具有相同的错误消息:

Syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)


顺便说一下,我已经安装了/usr/bin/time.

有人可以帮忙吗?

谢谢

编辑:根据要求,脚本很简单:

#!/bin/bash

(time {
sleep 1;
})
Run Code Online (Sandbox Code Playgroud)

linux shell bash debian time

2
推荐指数
1
解决办法
81
查看次数

无法从 grep 中排除包含 ^M 的行

我有以下文件,我只想Removed '2022-01-30_01-00-05'在最后从中提取。

Removing '2022-01-30_01-00-05'...
  0.46% complete (00:03:45 remaining)^M  5.49% complete (00:00:17 remaining)^M 24.90% complete (00:00:06 remaining)^M 60.56% complete (00:00:01 remaining)^M 82.12% complete (00:00:00 remaining)^M 82.39% complete (00:00:01 remaining)^M 84.24% complete (00:00:01 remaining)^M 86.48% complete (00:00:01 remaining)^M 88.58% complete (00:00:01 remaining)^M 89.66% complete (00:00:01 remaining)^M101.08% complete (00:00:00 remaining)^M104.62% complete (00:00:00 remaining)^M                                                                                ^MRemoved '2022-01-30_01-00-05'
Run Code Online (Sandbox Code Playgroud)

我已经尝试过dos2unix,但没有成功。

我已经尝试了下面的这些变体,但是当我less output他们要么不删除^M字符,要么捕获整行:

tr -d $'\r' < /file | grep "Removed" > output
tr -d '^M' < /file | grep …
Run Code Online (Sandbox Code Playgroud)

linux grep sed awk tr

2
推荐指数
2
解决办法
445
查看次数

标签 统计

linux ×3

awk ×1

bash ×1

dd ×1

debian ×1

grep ×1

hard-disk ×1

openssh ×1

sed ×1

shell ×1

shred ×1

ssh ×1

sshd ×1

time ×1

tr ×1