QNX时钟调研

SYSPAGE_ENTRY()的使用,SYSPAGE_ENTRY

测试QNX下printf(“poo\n”);的耗时

#include <sys/neutrino.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syspage.h>int main( void )
{uint64_t cps, cycle1, cycle2, ncycles;float sec;/* snap the time */cycle1=ClockCycles( );/* do something */printf("poo\n");/* snap the time again */cycle2=ClockCycles( );ncycles=cycle2-cycle1;printf("%lld cycles elapsed \n", ncycles);/* find out how many cycles per second */cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;printf( "This system has %lld cycles/sec.\n",cps );sec=(float)ncycles/cps;printf("The cycles in seconds is %f \n",sec);return EXIT_SUCCESS;
}

输出

在这里插入图片描述

ClockCycles() 和TIMESTAMP的使用

测试代码

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <time.h>
#include <sys/select.h>
#include <sys/ioctl.h>
#ifdef __QNX__
#include <sys/neutrino.h>
#include <sys/syspage.h>
#endif#define log(fmt, ...) printf(fmt "\n", ##__VA_ARGS__);int create_server_socket() {int sock = socket(AF_INET, SOCK_DGRAM, 0);if (sock < 0) {log("cannot create socket");return -1;}struct sockaddr_in addr;memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = htons(8080);addr.sin_addr.s_addr = htonl(INADDR_ANY);int ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr));if (ret < 0) {log("cannot bind socket");return -1;}int optval = 1;ret = setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &optval, sizeof(optval));if (ret < 0) {log("cannot setsockopt SO_TIMESTAMP");return -1;}return sock;
}int destroy_socket(int sock) {if (sock < 0) {log("invalid socket");return -1;}int ret = close(sock);if (ret < 0) {log("cannot close socket");return -1;}return 0;
}int64_t get_so_timestampns(int sock) {struct msghdr msg;struct iovec iov;char cmsgbuf[4096];char buf[1024];struct cmsghdr *cmsg;struct timeval *tv;int ret;memset(buf, 0, sizeof(buf));memset(&msg, 0, sizeof(msg));memset(&iov, 0, sizeof(iov));memset(cmsgbuf, 0, sizeof(cmsgbuf));iov.iov_base = buf;iov.iov_len = sizeof(buf);msg.msg_iov = &iov;msg.msg_iovlen = 1;msg.msg_control = cmsgbuf;msg.msg_controllen = sizeof(cmsgbuf);ret = recvmsg(sock, &msg, 0);if (ret < 0) {log("cannot recvmsg %s", strerror(errno));return -1;}write(sock, buf, strlen(buf));for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
#ifdef _QNX_if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP) {
#elseif (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
#endiftv = (struct timeval *)CMSG_DATA(cmsg);return tv->tv_sec * 1000000000 + tv->tv_usec * 1000;}}log("cannot find SO_TIMESTAMP");return -1;
}int send_to_sock(int sock, const char* buf, int len) {struct sockaddr_in addr;memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = htons(8080);// localhostaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);int ret = sendto(sock, buf, len, 0, (struct sockaddr *)&addr, sizeof(addr));if (ret < 0) {log("cannot sendto");return -1;}return 0;
}int main() {
#ifdef __QNX__uint64_t cntpclk = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
#endifint sock = create_server_socket();if (sock < 0) {return -1;}fd_set rfds;FD_ZERO(&rfds);FD_SET(sock, &rfds);const char* buf = "hello world";int64_t sec, msec, usec, nsec;int64_t ns = -1;int ret = -1;for (;;) {struct timespec start, end;#ifdef __QNX__if (clock_gettime(CLOCK_REALTIME, &start) == -1) {
#elseif (clock_gettime(CLOCK_MONOTONIC, &start) == -1) {
#endiflog("cannot get start time");return -1;}ret = send_to_sock(sock, buf, strlen(buf));if (ret < 0) {return -1;}ret = select(sock + 1, &rfds, NULL, NULL, NULL);if (ret < 0) {log("cannot select");return -1;}ns = get_so_timestampns(sock);if (ns < 0) {return -1;}#ifdef __QNX__uint64_t cycles = ClockCycles();sec = cycles / cntpclk;nsec = ((cycles % cntpclk) * 1000000000) / cntpclk;
#elsesec = ns / 1000000000;nsec = ns % 1000000000;
#endifmsec = (ns % 1000000000) / 1000000;usec = (ns % 1000000) / 1000;log("ts: %ld.%03ld.%03ld.%03ld", sec, msec, usec, nsec);#ifdef __QNX__if (clock_gettime(CLOCK_REALTIME, &end) == -1) {
#elseif (clock_gettime(CLOCK_MONOTONIC, &end) == -1) {
#endiflog("cannot get end time");return -1;}#ifdef __QNX__uint64_t elapsed = (end.tv_sec - start.tv_sec) * cntpclk + (end.tv_nsec - start.tv_nsec) * cntpclk / 1000000000;
#elseuint64_t elapsed = (end.tv_sec - start.tv_sec) * 1000000000 + (end.tv_nsec - start.tv_nsec);
#endiflog("Elapsed time: %lu ns", elapsed);}destroy_socket(sock);
}

输出
在这里插入图片描述

QNX编译server, client在x86

./so_times_client2server
-1688469126.732655764,-1688469126.728909969,-1688469126.732655764,9223372036.854776382,-1688469126.728909969,9223372036.854776382
-1688469126.732184887,-1688469126.728912115,-1688469126.732184887,9223372036.854776382,-1688469126.728909969,-1688469126.728912115
-1688469126.732127190,-1688469126.728909254,-1688469126.732127190,9223372036.854776382,-1688469126.728909254,-1688469126.728912115
-1688469126.731760502,-1688469126.728905678,-1688469126.731760502,9223372036.854776382,-1688469126.728905678,-1688469126.728912115
-1688469126.731424093,-1688469126.728862762,-1688469126.731424093,9223372036.854776382,-1688469126.728862762,-1688469126.728912115
-1688469126.731297493,-1688469126.728890896,-1688469126.731297493,9223372036.854776382,-1688469126.728862762,-1688469126.728912115
-1688469126.731182575,-1688469126.728879690,-1688469126.731182575,9223372036.854776382,-1688469126.728862762,-1688469126.728912115
-1688469126.731026411,-1688469126.728876829,-1688469126.731026411,9223372036.854776382,-1688469126.728862762,-1688469126.728912115
-1688469126.730824709,-1688469126.728859663,-1688469126.730824709,9223372036.854776382,-1688469126.728859663,-1688469126.728912115
-1688469126.730739594,-1688469126.728857994,-1688469126.730739594,9223372036.854776382,-1688469126.728857994,-1688469126.728912115
-1688469126.730360746,-1688469126.728832722,-1688469126.730360746,9223372036.854776382,-1688469126.728832722,-1688469126.728912115
-1688469126.730060339,-1688469126.728815556,-1688469126.730060339,9223372036.854776382,-1688469126.728815556,-1688469126.728912115

x86 编译server, client在x86

./so_times_client2server_x86
0.000026974,0.000043670,0.000026974,9223372036.854776382,0.000043670,9223372036.854776382
0.000017392,0.000033999,0.000026974,0.000017392,0.000043670,0.000033999
0.000016327,0.000031998,0.000026974,0.000016327,0.000043670,0.000031998
0.000023419,0.000041275,0.000026974,0.000016327,0.000043670,0.000031998
0.000022748,0.000040941,0.000026974,0.000016327,0.000043670,0.000031998
0.000023593,0.000042021,0.000026974,0.000016327,0.000043670,0.000031998
0.000041016,0.000059082,0.000041016,0.000016327,0.000059082,0.000031998
0.000022167,0.000040225,0.000041016,0.000016327,0.000059082,0.000031998
0.000029824,0.000047739,0.000041016,0.000016327,0.000059082,0.000031998
0.000021904,0.000039896,0.000041016,0.000016327,0.000059082,0.000031998
0.000024818,0.000043094,0.000041016,0.000016327,0.000059082,0.000031998
0.000022284,0.000040727,0.000041016,0.000016327,0.000059082,0.000031998
0.000024739,0.000064953,0.000041016,0.000016327,0.000064953,0.000031998
0.000021680,0.000038507,0.000041016,0.000016327,0.000064953,0.000031998
0.000039627,0.000069057,0.000041016,0.000016327,0.000069057,0.000031998

so_times_client2server.c

#include <arpa/inet.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/if_ether.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#ifdef _QNX_
#include <sys/neutrino.h>
#include <sys/siginfo.h>
#else
#include <pthread.h>
#endif
#define PORT 23333
#define log(fmt, ...) printf(fmt "\n", ##__VA_ARGS__);
int create_server_socket() {int sock = socket(AF_INET, SOCK_DGRAM, 0);if (sock < 0) {log("cannot create socket");return -1;}struct sockaddr_in addr;memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = PORT;addr.sin_addr.s_addr = htonl(INADDR_ANY);int ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr));if (ret < 0) {log("cannot bind socket");return -1;}int optval = 1;ret = setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &optval, sizeof(optval));if (ret < 0) {log("cannot setsockopt SO_TIMESTAMP");return -1;}return sock;
}
int create_client_socket(const char *ip) {int sock = socket(AF_INET, SOCK_DGRAM, 0);if (sock < 0) {log("cannot create socket");return -1;}struct sockaddr_in addr;memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = PORT;if (ip == NULL) {addr.sin_addr.s_addr = inet_addr("224.0.1.129");} else {addr.sin_addr.s_addr = inet_addr(ip);}int ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));if (ret < 0) {log("cannot connect socket");return -1;}int optval = 1;ret = setsockopt(sock, SOL_SOCKET, SO_TIMESTAMP, &optval, sizeof(optval));if (ret < 0) {log("cannot setsockopt SO_TIMESTAMP");return -1;}return sock;
}
int destroy_socket(int sock) {if (sock < 0) {log("invalid socket");return -1;}int ret = close(sock);if (ret < 0) {log("cannot close socket");return -1;}return 0;
}
void show_so_timestamp(int sock, int use_cmsg) {struct timespec inner_ts;clock_gettime(CLOCK_REALTIME, &inner_ts);struct msghdr msg;struct iovec iov;char cmsgbuf[4096];char buf[1024];struct cmsghdr *cmsg;struct timeval *tv;int ret;memset(buf, 0, sizeof(buf));memset(&msg, 0, sizeof(msg));memset(&iov, 0, sizeof(iov));memset(cmsgbuf, 0, sizeof(cmsgbuf));iov.iov_base = buf;iov.iov_len = sizeof(buf);msg.msg_iov = &iov;msg.msg_iovlen = 1;msg.msg_control = cmsgbuf;msg.msg_controllen = sizeof(cmsgbuf);ret = recvmsg(sock, &msg, 0);if (ret < 0) {return;}int64_t inner_ns = inner_ts.tv_sec * 1000000000 + inner_ts.tv_nsec;int64_t recv_ns = -1;int64_t tag_ns = -1;struct timespec *ts = (struct timespec *)buf;tag_ns = ts->tv_sec * 1000000000 + ts->tv_nsec;for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;cmsg = CMSG_NXTHDR(&msg, cmsg)) {
#ifdef _QNX_if (cmsg->cmsg_level == SOL_SOCKET &&cmsg->cmsg_type == SCM_TIMESTAMP) {
#elseif (cmsg->cmsg_level == SOL_SOCKET &&cmsg->cmsg_type == SO_TIMESTAMP) {
#endiftv = (struct timeval *)CMSG_DATA(cmsg);recv_ns = tv->tv_sec * 1000000000 + tv->tv_usec * 1000;}}if (recv_ns < 0 || tag_ns < 0) {log("recv_ns %ld, tag_ns %ld", recv_ns, tag_ns);return;}int64_t diff_ns = recv_ns - tag_ns;int64_t diff_inner_ns = inner_ns - tag_ns;static int64_t diff_ns_max = INT64_MIN;static int64_t diff_ns_min = INT64_MAX;if (diff_ns > diff_ns_max) {diff_ns_max = diff_ns;} else if (diff_ns < diff_ns_min) {diff_ns_min = diff_ns;}static int64_t diff_inner_ns_max = INT64_MIN;static int64_t diff_inner_ns_min = INT64_MAX;if (diff_inner_ns > diff_inner_ns_max) {diff_inner_ns_max = diff_inner_ns;} else if (diff_inner_ns < diff_inner_ns_min) {diff_inner_ns_min = diff_inner_ns;}log("%.9lf,%.9lf,%.9lf,%.9lf,%.9lf,%.9lf",diff_ns / 1000000000.0, diff_inner_ns / 1000000000.0,diff_ns_max / 1000000000.0, diff_ns_min / 1000000000.0,diff_inner_ns_max / 1000000000.0, diff_inner_ns_min / 1000000000.0);
}
int64_t send_to_sock(int sock) {struct timespec ts;clock_gettime(CLOCK_REALTIME, &ts);int ret = sendto(sock, &ts, sizeof(ts), 0, NULL, 0);if (ret < 0) {return -1;}return ts.tv_sec * 1000000000 + ts.tv_nsec;
}
void wait_recv(int sock, int use_cmsg) {fd_set rfds;FD_ZERO(&rfds);FD_SET(sock, &rfds);struct timeval timeOut = {0, 0};int ret = -1;for (;;) {ret = select(sock + 1, &rfds, NULL, NULL, NULL);if (ret < 0) {log("cannot select");return;}show_so_timestamp(sock, use_cmsg);}
}
void server_loop() {int sock = create_server_socket();if (sock < 0) {return;}wait_recv(sock, 1);destroy_socket(sock);
}
static const int64_t interval_us = 100 * 1000;
static int client_sock = -1;
#ifdef _QNX_
void client_notify_function() {send_to_sock(client_sock);
#else
void *client_notify_function(void *arg) {for (;;) {send_to_sock(client_sock);usleep(interval_us);}return NULL;
#endif
}
void client_loop(const char *ip) {client_sock = create_client_socket(ip);if (client_sock < 0) {return;}
#ifdef _QNX_timer_t timer_id;struct sigevent event;memset(&event, 0, sizeof(event));event.sigev_value.sival_ptr = &timer_id;event.sigev_notify = SIGEV_THREAD;event.sigev_notify_function = client_notify_function;timer_create(CLOCK_REALTIME, &event, &timer_id);struct itimerspec itime;memset(&itime, 0, sizeof(itime));itime.it_value.tv_nsec = interval_us * 1000;itime.it_interval.tv_nsec = interval_us * 1000;timer_settime(timer_id, 0, &itime, NULL);
#elsepthread_t thread;pthread_create(&thread, NULL, client_notify_function, NULL);
#endifwait_recv(client_sock, 0);destroy_socket(client_sock);
}
int main(int argc, char *argv[]) {
#ifdef _QNX_struct _clockperiod period;period.nsec = 10000;period.fract = 0;ClockPeriod(CLOCK_REALTIME, &period, NULL, 0);
#endifif (argc < 2) {server_loop();} else {client_loop(argv[1]);}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/193265.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机网络的性能

目录 一、计算机网络的性能指标——宽带 二、计算机网络的性能指标——时延 三、计算机网络的性能指标——时延带宽积 四、计算机网络的性能指标——往返时延 五、计算机网络的性能指标——吞吐量 六、计算机网络的能能指标——利用率 计算机网络的定义&#xff1a;计算机网络时…

9. 双向队列

在队列中&#xff0c;我们仅能删除头部元素或在尾部添加元素。如下图所示&#xff0c;双向队列(double-ended queue)提供了更高的灵活性&#xff0c;允许在头部和尾部执行元素的添加或删除操作。 9.1 双向队列常用操作 双向队列的常用操作如下表所示&#xff0c;具体的方法名称…

Docker镜像制作与推送

目录 Docker镜像制作 搭建私服 将本地镜像推送到私有库 Docker镜像制作 以创建一个新ubuntu镜像&#xff0c;并安装vim命令示例 运行一个ubuntu镜像&#xff0c;发现在镜像里面无法使用vim命令&#xff0c;因为该ubuntu镜像只包括了其最基本的内核命令 [rootlocalhost ~]…

qt5.15播放音频示例(4种方法)

文章目录 Qt播放音频方法一 QMediaPlayer方法二 QSound方法三 QSoundEffect方法四 QAudioOutput问题1 播放无声问题2 QAudioOutput播放嗡嗡声的问题参考Qt播放音频 在linux系统中,可以通过aplay进行简单的播放音频,如 aplay /opt/Audio/test.wav在图形界面,也可以封装apla…

【接口测试】Apifox实用技巧干货分享

前言 不知道有多少人和我有着这样相似的经历&#xff1a;从写程序只要不报错就不测试&#x1f60a;&#xff0c;到写了程序若是有bug就debug甚至写单元测试&#xff0c;然后到了真实开发场景&#xff0c;大哥和你说&#xff0c;你负责的功能模块的所有接口写完要测试一遍无误在…

canvas基础:fillStyle 和strokeStyle示例

canvas实例应用100 专栏提供canvas的基础知识&#xff0c;高级动画&#xff0c;相关应用扩展等信息。 canvas作为html的一部分&#xff0c;是图像图标地图可视化的一个重要的基础&#xff0c;学好了canvas&#xff0c;在其他的一些应用上将会起到非常重要的帮助。 文章目录 上色…

百度收录批量查询工具,免费SEO优化排名工具

拥有一个在搜索引擎中得到良好收录的网站对于个人和企业都至关重要。而百度&#xff0c;作为中国最大的搜索引擎&#xff0c;其收录情况直接影响着网站的曝光度和流量。 百度搜索引擎是中文用户获取信息的重要途径之一。而在这个竞争激烈的网络环境中&#xff0c;了解自己网站…

分治-归并排序

文章目录 &#x1f31e;315. 计算右侧小于当前元素的个数&#x1f308;1. 题目⛅2. 算法原理&#x1fa90;3. 代码实现 &#x1f315;493. 翻转对&#x1f320;1. 题目⭐2. 算法原理&#x1f31f;3. 代码实现 &#x1f31e;315. 计算右侧小于当前元素的个数 &#x1f308;1. 题…

Fiddler抓包工具之fiddler设置抓HTTPS的请求证书安装

设置抓HTTPS的请求包 基础配置&#xff1a; 路径&#xff1a;启动Fiddler 》Tools》Options》HTTPS 注意&#xff1a;Option更改完配置需重启Fiddler才能生效 选中"Decrpt HTTPS traffic", Fiddler就可以截获HTTPS请求&#xff0c;如果是第一次会弹出证书安装提…

二叉树链式结构的实现和二叉树的遍历以及判断完全二叉树

二叉树的实现 定义结构体 我们首先定义一个结构来存放二叉树的节点 结构体里分别存放左子节点和右子节点以及节点存放的数据 typedef int BTDataType; typedef struct BinaryTreeNode {BTDataType data;struct BinaryTreeNode* left;struct BinaryTreeNode* right; }BTNode;…

Kubernetes入门学习(下)

Kubernetes入门学习&#xff08;下&#xff09; 文章目录 Kubernetes入门学习&#xff08;下&#xff09;运行有状态的应用ConfigMap与SecretConfigMapSecret 卷(Volume)StatefulSet(有状态应用集)Headless Service(无头服务)Mysql主从复制Port-forward端口转发Helm参考 运行有…

Python办公自动化【Word设置文字样式、Word设置段落样式、Word生成通知书、Word读取内容】(五)-全面详解(学习总结---从入门到深化)

目录 Word设置文字样式 Word设置段落样式 Word生成通知书 Word读取内容 Word设置文字样式 常用方法与属性 函数名&属性含义docx.shared.Inches() 创建大小(英寸)docx.shared.Pt() 创建大小(像素)docx.shared.RGBColor() 创建颜色docx.text.run.Run.font.bold文字加粗…

压缩docker在主机的虚拟磁盘容量

我们在windows里使用docker时会发现&#xff0c;即使我们已经删除了无用的镜像和容器&#xff0c;主机里挂在docker虚拟磁盘的那个盘&#xff0c;可用空间也没有增加&#xff0c;这是因为虚拟磁盘不会自动缩小&#xff0c;这里我分享一个可用的解决方案。 1.先通过docker回收空…

[多线程]线程安全问题再讨论 - volatile

目录 1.引言 2.volatil关键字 2.1内存可见性 2.2指令重排序 1.引言 大家好,我是老cu,今天我们来继续聊聊线程安全问题 线程安全是我们在编程开发中遇到的非常常见,棘手 的问题.同时也是多线程部分很复杂的问题.为了线程安全我们要做很多努力.也要对线程安全部分的代码进行慎…

使用python streamlit库快速创建一个购物网站

streamlit Streamlit 是一个基于 Python 的 Web 应用程序框架&#xff0c;致力于以更高效、更灵活的方式可视化数据&#xff0c;并分析结果。 Streamlit是一个开源库&#xff0c;可以帮助数据科学家和学者在短时间内开发机器学习 (ML) 可视化仪表板。只需几行代码&#xff0c…

[GPT-1]论文实现:Improving Language Understanding by Generative Pre-Training

Efficient Graph-Based Image Segmentation 一、完整代码二、论文解读2.1 GPT架构2.2 GPT的训练方式Unsupervised pre_trainingSupervised fine_training 三、过程实现3.1 导包3.2 数据处理3.3 模型构建3.4 模型配置 四、整体总结 论文&#xff1a;Improving Language Understa…

Gossip 协议

Gossip 协议 背景 在分布式系统中&#xff0c;不同的节点进行数据/信息共享是一个基本的需求。 一种比较简单粗暴的方法就是 集中式发散消息&#xff0c;简单来说就是一个主节点同时共享最新信息给其他所有节点&#xff0c;比较适合中心化系统。这种方法的缺陷也很明显&…

Hdoop学习笔记(HDP)-Part.20 安装Flume

目录 Part.01 关于HDP Part.02 核心组件原理 Part.03 资源规划 Part.04 基础环境配置 Part.05 Yum源配置 Part.06 安装OracleJDK Part.07 安装MySQL Part.08 部署Ambari集群 Part.09 安装OpenLDAP Part.10 创建集群 Part.11 安装Kerberos Part.12 安装HDFS Part.13 安装Ranger …

ubuntu下快速搭建docker环境训练yolov5数据集

参考文档 yolov5-github yolov5-github-训练文档 csdn训练博客 一、配置环境 1.1 安装依赖包 前往清华源官方地址 选择适合自己的版本替换自己的源 # 备份源文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak # 修改源文件 # 更新 sudo apt update &&a…

LinuxBasicsForHackers笔记 --常用Linux命令

在终端中修改用户密码命令&#xff1a;passwd Linux的文件系统是逻辑文件系统。 Linux基本命令 pwd – print working directory. 返回你当前所在目录结构中的位置。 whoami – 查看您当前登录的用户身份。 cd – change directory. 从终端更改目录。 cd / – 移动到根目录…