• 【开源项目】libfaketime安装、使用——小白教程


    项目

    GithubGitHub - wolfcw/libfaketime: libfaketime modifies the system time for a single application


    libfaketime安装

    01.切换路径,目标路径:/usr/local

    (在/usr/local路径下git clone 开源项目)

    切换路径指令:

    cd /usr/local

    02.拉取

    git clone https://github.com/wolfcw/libfaketime.git

    eg:

    1. root@DESKTOP-ER8E8NH:~# cd /usr/local
    2. root@DESKTOP-ER8E8NH:/usr/local# ls -l
    3. total 0
    4. drwxr-xr-x 1 root root 4096 May 30 2023 bin
    5. drwxr-xr-x 1 root root 4096 May 30 2023 etc
    6. drwxr-xr-x 1 root root 4096 May 30 2023 games
    7. drwxr-xr-x 1 root root 4096 May 30 2023 include
    8. drwxr-xr-x 1 root root 4096 May 30 2023 lib
    9. lrwxrwxrwx 1 root root 9 May 30 2023 man -> share/man
    10. drwxr-xr-x 1 root root 4096 May 30 2023 sbin
    11. drwxr-xr-x 1 root root 4096 May 31 2023 share
    12. drwxr-xr-x 1 root root 4096 May 30 2023 src
    13. root@DESKTOP-ER8E8NH:/usr/local# git clone https://github.com/wolfcw/libfaketime.git
    14. Cloning into 'libfaketime'...
    15. remote: Enumerating objects: 2536, done.
    16. remote: Counting objects: 100% (660/660), done.
    17. remote: Compressing objects: 100% (254/254), done.
    18. remote: Total 2536 (delta 427), reused 555 (delta 399), pack-reused 1876 (from 1)
    19. Receiving objects: 100% (2536/2536), 839.43 KiB | 55.00 KiB/s, done.
    20. Resolving deltas: 100% (1596/1596), done.
    21. root@DESKTOP-ER8E8NH:/usr/local# ls -l
    22. total 0
    23. drwxr-xr-x 1 root root 4096 May 30 2023 bin
    24. drwxr-xr-x 1 root root 4096 May 30 2023 etc
    25. drwxr-xr-x 1 root root 4096 May 30 2023 games
    26. drwxr-xr-x 1 root root 4096 May 30 2023 include
    27. drwxr-xr-x 1 root root 4096 May 30 2023 lib
    28. drwxr-xr-x 1 root root 4096 Oct 28 21:51 libfaketime
    29. lrwxrwxrwx 1 root root 9 May 30 2023 man -> share/man
    30. drwxr-xr-x 1 root root 4096 May 30 2023 sbin
    31. drwxr-xr-x 1 root root 4096 May 31 2023 share
    32. drwxr-xr-x 1 root root 4096 May 30 2023 src
    33. root@DESKTOP-ER8E8NH:/usr/local#

    03.切换到libfaketime路径

    指令:

    cd libfaketime

    04.make

    指令:

    make

    eg:

    1. root@DESKTOP-ER8E8NH:/usr/local/libfaketime (master)# make
    2. make -C src all
    3. make[1]: Entering directory '/usr/local/libfaketime/src'
    4. cc -o libfaketime.o -c -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -Wno-nonnull-compare libfaketime.c
    5. cc -o libfaketime.so.1 -Wl,-soname,libfaketime.so.1 -Wl,--version-script=libfaketime.map -shared libfaketime.o -ldl -lm -lrt -lpthreadcc -o libfaketimeMT.o -c -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -Wno-nonnull-compare -DPTHREAD_SINGLETHREADED_TIME libfaketime.c
    6. cc -o libfaketimeMT.so.1 -Wl,-soname,libfaketimeMT.so.1 -Wl,--version-script=libfaketime.map -shared libfaketimeMT.o -ldl -lm -lrt -lpthread
    7. cc -o faketime -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -Wno-nonnull-compare faketime.c -Wl,--version-script=libfaketime.map -lrt -lpthread
    8. make[1]: Leaving directory '/usr/local/libfaketime/src'

    05.make install

    指令:

    make install

    eg:

    1. root@DESKTOP-ER8E8NH:/usr/local/libfaketime (master)# sudo make install
    2. make -C src install
    3. make[1]: Entering directory '/usr/local/libfaketime/src'
    4. Copying the faketime libraries to /usr/local/lib/faketime and the faketime wrapper script to /usr/local/bin ...
    5. install -dm0755 "/usr/local/lib/faketime/"
    6. install -m0644 libfaketime.so.1 libfaketimeMT.so.1 "/usr/local/lib/faketime/"
    7. install -Dm0755 faketime "/usr/local/bin/faketime"
    8. make[1]: Leaving directory '/usr/local/libfaketime/src'
    9. make -C man install
    10. make[1]: Entering directory '/usr/local/libfaketime/man'
    11. install -Dm0644 faketime.1 "/usr/local/share/man/man1/faketime.1"
    12. gzip -nf "/usr/local/share/man/man1/faketime.1"
    13. make[1]: Leaving directory '/usr/local/libfaketime/man'
    14. install -dm0755 "/usr/local/share/doc/faketime/"
    15. install -m0644 README "/usr/local/share/doc/faketime/README"
    16. install -m0644 NEWS "/usr/local/share/doc/faketime/NEWS"

    libfaketime使用

    修改时间

    语法:

    export LD_PRELOAD=[libfaketime.so.1文件的绝对路径] FAKETIME="[@目标时间]"

    eg:

    export LD_PRELOAD=/usr/local/libfaketime/src/libfaketime.so.1 FAKETIME="@2024-06-04 00:00:01"

    同步时间

    语法:

    export LD_PRELOAD=/usr/local/libfaketime/src/libfaketime.so.1 FAKETIME= date

  • 相关阅读:
    数据挖掘与统计分析——T检验,正态性检验和一致性检验——代码复现
    SpringCloud-Gateway网关实现入参统一解密
    rust变量绑定、拷贝、转移、引用
    表面声波滤波器——SAW 基本介绍(1)
    使用Python实现文字的声音播放
    计算机竞赛 深度学习机器视觉车道线识别与检测 -自动驾驶
    ARP攻击原理
    【毕业设计】20-基于单片机的指纹识别系统设计(原理图工程+源代码工程+实物操作图+答辩论文+答辩PPT)
    java基于微信小程序的灯具销售商城 uniapp小程序
    通信算法之九十六:电力通信系统-HRF多载波通信系统-物理层收发信道开发
  • 原文地址:https://blog.csdn.net/Acloasia/article/details/143314796