linux系统clock命令详解有哪些?让我们一起来了解下。
clock命令的作用是调整 RTC 时间,RTC是电脑内建的硬件时间,执行指令可以显示现在时刻,调整硬件时钟的时间,将系统时间设成与硬件时钟之时间一致,或是把系统时间回存到硬件时钟。
语法:clock [--adjust][--debug][--directisa][--getepoch][--hctosys][--set --date="<日期时间>"][--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]
参考例子:
显示当前硬件时钟时间:
显示utc硬件时钟时间:
[root@linux265 ~]# clock --utc
参数:
- -adjust 自动调整硬件时钟时间
-- -debug 详细显示指令执行过程,便于排错或了解程序执行的情形
-- -directisa 不通过设备文件/etc/rtc,直接对硬件时钟进行存取
-- -getepoch 输出硬件时钟的数值到标准输出
-- -hctosys 时钟同步,使系统时钟和硬件时钟同步
-- -set- -date 设置硬件时间
-- -show 显示硬件时钟到标准输出
-- -systohc 系统时间写入硬件时钟
-- -test 仅作测试,并不真的将时间写入硬件时钟或系统时间
-- -utc 把硬件时钟上的时间时为CUT,有时也称为UTC或UCT
-- -version 显示版本信息
今天的分享就是这些,希望能帮助大家。
通过14个示例掌握 linux ls 命令,小白也能学明白
Linux / UNIX 中的 ls 命令用于列出目录内容。当我们不带任何选项运行 ls 命令时,它显示当前目录下的有关文件信息,按字母顺序排列。
ls 命令语法$ ls <options> <file | directory>
在本教程中,我们将通过 14 个有用的实际示例介绍 Linux 中的 ls 命令。
(1) 列出当前工作目录的内容当我们运行不带任何选项的 ls 命令时,它将列出如下所示的文件和目录
$ lsDesktop Documents Downloads Music myscript.sh Pictures playbook.yaml Public snap Templates Videos$(2) 以长列表格式列出内容
使用 ls 命令中的 -l 选项,以长列表格式列出目录内容。
如上所示,ls -l 还显示了文件和目录的权限、修改时间和大小。
(3) 列出特定目录的内容要列出特定目录的内容,示例如下:
$ ls -l /var/log/apt/
如果你只希望列出目录权限,那么使用-ld 选,示例如下:
$ ls -ld /var/log/apt/drwxr-xr-x 2 root root 4096 Oct 14 06:58 /var/log/apt/$(4) 显示目录内容的文件类型 (ls -F)
To list file types with ls command then use ‘-F’ option, in the
following example, we are listing the file types from present working
directory
ls 命令使用 -F 选项,可以列出文件类型,示例如下:
$ ls -FDesktop/ Documents/ Downloads/ Music/ myscript.sh* Pictures/ playbook.yaml Public/ snap/ Templates/ Videos/$
在上面的输出中,将为各自的类型追加以下内容:
ls 命令中使用 -t 选项,按时间排序列出目录内容。
$ ls -lt
按修改时间倒序列出文件,使用如下命令:
$ ls -ltr(6) 以人类可读格式列出内容
ls 命令中的 -h 选项用于以人可读格式列出文件大小 (2K、34M 或 5G)。
$ ls -lh
ls 命令中的 -a 选项用于列出目录下的所有文件,包括隐藏文件。
$ ls -la /home/linuxtechi/
ls 命令中使用 -R 选项,可以递归列出文件和目录,示例如下
$ ls -R /etc/
Use ‘-lhs’ option in ls command to list file sorted by size (human readable size like K, M & G), example is shown below:
使用 -lhs 选项按大小 (人类可读的格式如 K, M 和 G)列出文件,示例如下:
$ ls -lhS
To list inode numbers of file and directory using ls command then use ‘-i’ option,
使用使用 -i 选项, 可以列出文件和目录的 inode 号
$ ls -li
ls 命令的输出可以使用 --format 选项进行格式化。
基本语法:
$ ls --format=WORD
支持格式:
$ ls -mor$ ls --format=commas
以单列输出
$ ls -1
To list file’s and directory’s UID and GID with ls command, use ‘-n’ option, example is shown below
使用-n 选项,列出文件和目录的 UID 和 GID,示例如下
$ ls -n
Type the alias and grep command on the terminal to display the default aliases set for ls command.
在终端上输入 alias 和 grep 命令,将显示 ls 命令设置的默认别名。
$ alias | grep lsalias l='ls -CF'alias la='ls -A'alias ll='ls -alF'alias ls='ls --color=auto'$(14) 回显中启用时间戳
$ ls -l --time-style=" %Y-%m-%d $newline%m-%d %H:%M"
酷瓜云课堂 - koogua.com