linux 第二天作业

作业要求

1.手动调整当前主机时间和时区

[root@localhost ~]# date 031823562003.32
2003年 03月 18日 星期二 23:56:32 CST
[root@localhost ~]# timedatectl set-timezone "Asia/Shanghai"

2. 查看系统时间按照年/月/日 时:分:秒格式显示冰将结果写入time文件

[root@localhost ~]# date +'%Y/%m/%d %H:%M:%S'>time
[root@localhost ~]# cat time
2003/03/18 00:31:46

3.查看主机/etc/下是否存在 group文件,是什么类型文件

[root@localhost ~]# cd /etc
[root@localhost etc]# ll
-rw-r--r--.  1 root root       982 7月  27 2022 group
[root@localhost etc]# file -f group

4.查看/etc/sysconfig目录文件的属性

[root@localhost sysconfig]# ls -l
总用量 120
-rw-r--r--. 1 root root  111 7月  27 2022 anaconda
-rw-r--r--. 1 root root  403 8月  12 2018 atd
-rw-r--r--. 1 root root   46 6月  15 2021 chronyd
drwxr-xr-x. 2 root root    6 2月  15 2021 console
-rw-r--r--. 1 root root  150 10月  5 2021 cpupower
-rw-r--r--. 1 root root  110 6月  13 2019 crond
-rw-------. 1 root root  417 8月  13 2021 ebtables-config
-rw-r--r--. 1 root root   73 7月  30 2021 firewalld
lrwxrwxrwx. 1 root root   15 8月  19 2021 grub -> ../default/grub
-rw-------. 1 root root 2134 8月  13 2021 ip6tables-config
-rw-------. 1 root root 2116 8月  13 2021 iptables-config
-rw-r--r--. 1 root root  903 1月  31 2021 irqbalance
-rw-r--r--. 1 root root 2478 8月  27 2021 kdump
-rw-r--r--. 1 root root  185 7月  27 2022 kernel
-rw-r--r--. 1 root root  168 10月  2 2021 ksm
-rw-r--r--. 1 root root  823 11月 27 2019 libvirtd
-rw-r--r--. 1 root root  310 6月  24 2021 man-db
drwxr-xr-x. 2 root root    6 2月  15 2021 modules
-rw-r--r--. 1 root root   22 7月  27 2022 network
drwxr-xr-x. 2 root root   26 7月  27 2022 network-scripts
-rw-------. 1 root root  364 8月  20 2021 nftables.conf
-rw-r--r--. 1 root root  911 10月  2 2021 qemu-ga
-rw-r--r--. 1 root root  186 4月  15 2020 radvd
-rw-r--r--. 1 root root 2915 8月   5 2021 raid-check
-rw-r--r--. 1 root root   73 11月 25 2020 rpcbind
-rw-r--r--. 1 root root  196 8月   6 2021 rsyslog
-rw-r--r--. 1 root root    0 1月   8 2021 run-parts
-rw-r--r--. 1 root root  428 7月  13 2021 samba
-rw-r--r--. 1 root root  429 5月   8 2020 saslauthd
lrwxrwxrwx. 1 root root   17 7月  27 2022 selinux -> ../selinux/config
-rw-r--r--. 1 root root  186 4月  22 2020 smartmontools
-rw-r-----. 1 root root  591 7月  12 2021 sshd
-rw-r--r--. 1 root root  161 7月  27 2022 sshd-permitrootlogin
-rw-r--r--. 1 root root   55 11月 27 2019 virtlockd
-rw-r--r--. 1 root root   53 11月 27 2019 virtlogd
-rw-r--r--. 1 root root  258 3月   1 2021 wpa_supplicant

 5.在root用户的家目录下创建file文件,在/pub创建该文件的软连接文件newfile,在/test创建硬链接文件file.lnk

[root@localhost ~]# touch file
[root@localhost pub]# ln -s file newfile

6.在文件编辑内容

[root@localhost ~]# cat >>file<<EOF
> Good good study,day day up.
> EOF
[root@localhost ~]# cat file
Good good study,day day up.

 总结

1.查看命令手册

--help        man        info       pinfo     

2.日期

        查看日期

        (1).+%F     输出格式:年-月-日

        (2).+%T     输出格式:时-分-秒

          (3).timedatectl     显示时间,使用前必须关闭网络同步

          (4).timedatectl      后加  list-timezones  显示所有时区

          (5).clock 或者 hwclock  显示硬件时间,后加  -s   是系统时间向硬件时间同步    后加-w是硬件时间向系统时间同步。

          (6).cal  显示日历

3.查看文件

          (1).ls   后可加 -a   -A   -l   -d   -h   -i   -R    -S

        修改日期

          (1). -s        后加  年-月-日

          (2).date     后加  月日时分年.秒

          (3).timedatectl    加   set-timezone  "Asia/Shanghai"

4.创建软硬链接

          (1).创建软链接:ln -s  a   b    建立b为a的软链接

          (2).创建硬链接:  ln   a    b    建立b为a的硬链接,需在同意目录下才能创建成功

5.创建文件

          (1).创建文件:touch

          (2).创建目录文件:mkdir

6.删除文件

          (1).rm    加 -r 删除目录文件

                        加 -f 强制删除

                        加*  删除任意长度文件,通配符

7. > 重定向符     >>追加重定向符

    <输入重定向符    <<终止结束符

8.向文件中写东西

  (1).cat >>文件名<<EOF

      >要写的内容

      >EOF

(2).echo '要写的内容' <<文件路径(在文件原有内容后直接加)

     echo '要写的内容' <文件路径  (把文件原有内容删除,再写入)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值