【Linux】date:cannot set date:operation not permitted

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m18633778874/article/details/83377458

前言

    小编最近安装了Linux的虚拟机Centos,并在网上找到了学习Linux的网站《Linux就该这么学》,正在跟着里面的教程学习这块的知识,遇到了问题,下面是具体的解决过程。

date命令执行失败

    date命令学习时,执行设置系统时间时,出现了这个提示,意思是不允许这个操作。

原因:权限不够

    小编对这个命令执行失败的原因,在网上找到了答案:权限不够,需要提升为root 权限,具体操作如下:

[grace@localhost Desktop]$ su root
Password: 
[root@localhost Desktop]# date -s "20181024 11:51:00"
Wed Oct 24 11:51:00 PDT 2018
[root@localhost Desktop]# date
Wed Oct 24 11:51:05 PDT 2018
[root@localhost Desktop]# date -s "20181025 11:51:00"
Thu Oct 25 11:51:00 PDT 2018

 拓展:date命令

       补充两个date命令:获取当前系统时间、按照指定格式输出时间

[grace@localhost Desktop]$ date
Wed Oct 24 20:33:20 PDT 2018
[grace@localhost Desktop]$ date "+%Y-%m-%d %H:%M:%S"
2018-10-24 20:34:53

小结

扫描二维码关注公众号,回复: 3813473 查看本文章

    通过这个问题的解决,自己对于Linux系统有了更深的认识,动手实践,是获取知识的最好的途径!

                                                      感谢您的访问!

猜你喜欢

转载自blog.csdn.net/m18633778874/article/details/83377458