2020-11-07

修改文件属主和属组的命令 chown

总用量 4
-rw-------. 1 root root 818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# touch abc
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 root root   0 11月  7 17:48 abc
-rw-------. 1 root root 818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# useradd qx1128
[root@localhost ~]# chown qx1128 abc
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 root   0 11月  7 17:48 abc
-rw-------. 1 root   root 818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# ]chown :qx1128 abc
[root@localhost ~]# ll
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 qx1128   0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# chown root:root abc
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 root root   0 11月  7 17:48 abc
-rw-------. 1 root root 818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# chown .qx1128 abc
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 root qx1128   0 11月  7 17:48 abc
-rw-------. 1 root root   818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# chown qx1128.root abc
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 root   0 11月  7 17:48 abc
-rw-------. 1 root   root 818 11月  6 21:32 anaconda-ks.cfg
[root@localhost ~]# mkdir hehe
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 root   0 11月  7 17:48 abc
-rw-------. 1 root   root 818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 root   root   6 11月  7 18:04 hehe
[root@localhost ~]# ll hehe/
总用量 0
[root@localhost ~]# chown qx1128.qx1128 hehe
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 root     0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 qx1128 qx1128   6 11月  7 18:04 hehe
[root@localhost ~]# ll hehe/
总用量 0
[root@localhost ~]# chown -R qx1128.qx1128 hehe
[root@localhost ~]# ll
总用量 4
-rw-r--r--. 1 qx1128 root     0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 qx1128 qx1128   6 11月  7 18:04 hehe
root@localhost ~]# mkdir 123
[root@localhost ~]# ll
总用量 4
drwxr-xr-x. 2 root   root     6 11月  7 18:10 123
-rw-r--r--. 1 qx1128 root     0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 qx1128 qx1128   6 11月  7 18:04 hehe
[root@localhost ~]# chown .qx1128 123
[root@localhost ~]# ll
总用量 4
drwxr-xr-x. 2 root   qx1128   6 11月  7 18:10 123
-rw-r--r--. 1 qx1128 root     0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 qx1128 qx1128   6 11月  7 18:04 hehe

遮罩码

[root@localhost ~]# ll
总用量 4
drwxr-sr-x. 2 root   qx1128   6 11月  7 18:10 123
-rw-r--r--. 1 qx1128 root     0 11月  7 17:48 abc
-rw-------. 1 root   root   818 11月  6 21:32 anaconda-ks.cfg
drwxr-xr-x. 2 qx1128 qx1128   6 11月  7 18:04 hehe
[root@localhost ~]# cd 123
[root@localhost 123]# touch 456
[root@localhost 123]# mkdir abc
[root@localhost 123]# ll
总用量 0
-rw-r--r--. 1 root qx1128 0 11月  7 18:12 456
drwxr-sr-x. 2 root qx1128 6 11月  7 18:13 abc
[root@localhost ~]# cd 123
[root@localhost 123]# ll
总用量 0
-rw-r--r--. 1 root qx1128 0 11月  7 18:12 456
drwxr-sr-x. 2 root qx1128 6 11月  7 18:13 abc
[root@localhost 123]# touch xixi
[root@localhost 123]# ll
总用量 0
-rw-r--r--. 1 root qx1128 0 11月  7 18:12 456
drwxr-sr-x. 2 root qx1128 6 11月  7 18:13 abc
-rw-r--r--. 1 root qx1128 0 11月  7 18:19 xixi
[root@localhost 123]# rm -f xixi
[root@localhost 123]# ls
456  abc
[root@localhost 123]# rm -f 456
[root@localhost 123]# ls
abc
[root@localhost ~]# ps -elf|head -3
F S UID         PID   PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD
4 S root          1      0  0  80   0 - 12693 ep_pol 17:40 ?        00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 23
1 S root          2      0  0  80   0 -     0 kthrea 17:40 ?        00:00:00 [kthreadd]
[root@localhost ~]# ps -elf|grep vi
0 S root       2772   2751  0  80   0 - 28164 pipe_w 18:23 pts/0    00:00:00 grep --color=auto vi


可以使用 Java 中的 LocalDateTime 类来处理时间。 首先,我们需要将给定的时间段转换为 LocalDateTime 对象: ```java LocalDateTime start = LocalDateTime.of(2020, 11, 20, 0, 0, 0); LocalDateTime end = LocalDateTime.of(2021, 10, 9, 23, 59, 59); ``` 这里将结束时间设置为 23:59:59 是因为我们想要包含该日期的所有时间。 接下来,我们可以使用一个循环来遍历时间段中的每一天,并获取该天的开始时间和结束时间: ```java LocalDateTime current = start; while (!current.isAfter(end)) { LocalDateTime dayStart = current.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime dayEnd = current.withHour(23).withMinute(59).withSecond(59).withNano(999999999); System.out.println("Day " + current.toLocalDate() + " starts at " + dayStart + " and ends at " + dayEnd); current = current.plusDays(1); } ``` 这里,我们使用 `withHour`、`withMinute`、`withSecond` 和 `withNano` 方法来设置每天的开始时间和结束时间。然后,我们可以使用 `plusDays` 方法来增加 `current` 对象的日期,以便遍历整个时间段。 完整代码如下: ```java import java.time.LocalDateTime; public class Main { public static void main(String[] args) { LocalDateTime start = LocalDateTime.of(2020, 11, 20, 0, 0, 0); LocalDateTime end = LocalDateTime.of(2021, 10, 9, 23, 59, 59); LocalDateTime current = start; while (!current.isAfter(end)) { LocalDateTime dayStart = current.withHour(0).withMinute(0).withSecond(0).withNano(0); LocalDateTime dayEnd = current.withHour(23).withMinute(59).withSecond(59).withNano(999999999); System.out.println("Day " + current.toLocalDate() + " starts at " + dayStart + " and ends at " + dayEnd); current = current.plusDays(1); } } } ``` 输出结果如下: ``` Day 2020-11-20 starts at 2020-11-20T00:00 and ends at 2020-11-20T23:59:59.999999999 Day 2020-11-21 starts at 2020-11-21T00:00 and ends at 2020-11-21T23:59:59.999999999 Day 2020-11-22 starts at 2020-11-22T00:00 and ends at 2020-11-22T23:59:59.999999999 ... Day 2021-10-07 starts at 2021-10-07T00:00 and ends at 2021-10-07T23:59:59.999999999 Day 2021-10-08 starts at 2021-10-08T00:00 and ends at 2021-10-08T23:59:59.999999999 Day 2021-10-09 starts at 2021-10-09T00:00 and ends at 2021-10-09T23:59:59.999999999 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值