当前位置:网站首页>树莓派初步使用
树莓派初步使用
2022-06-27 15:41:00 【xieyang929】
一、创建新用户
创建用户:
sudo useradd -m 用户名
设置密码:
sudo passwd 用户名
给予用户sudo权限(后面文件传输时需要):
#切换到root用户
sudo su
#编辑配置文件
vi /etc/sudoers
#增加配置(按i开始编辑,Esc退出编辑,:wq!保存强制退出), 在打开的配置文件中,找到root ALL=(ALL) ALL, 在下面添加一行
#其中xxx是你要加入的用户名称
xxx ALL=(ALL) ALL
二、C程序练习
进入vi编辑模式,按i开始写代码
#include <assert.h>
#include <stdio.h>
int main()
{
int a;
char str[50];
printf("请输入一个整数值: ");
scanf("%d", &a);
assert(a >= 10);
printf("输入的整数是: %d\n", a);
printf("请输入字符串: ");
scanf("%s", str);
assert(str != NULL);
printf("输入的字符串是: %s\n", str);
return(0);
}
按Esc退出编辑模式,输入:wq
编译程序
gcc 程序名.c -o 程序名
运行程序
./程序名
三、assert()理解
简介
C 标准库的 assert.h头文件提供了一个名为 assert 的宏,它可用于验证程序做出的假设,并在假设为假时输出诊断消息。
库宏
assert.h头文件定义了唯一的函数:assert()
void assert(int expression) 这实际上是一个宏,不是一个函数,可用于在 C 程序中添加诊断。
C 库宏 - assert()
描述:C 库宏 void assert(int expression) 允许诊断信息被写入到标准错误文件中。换句话说,它可用于在 C 程序中添加诊断。
声明:void assert(int expression);
expression :这可以是一个变量或任何 C 表达式。如果 expression 为 TRUE,assert() 不执行任何动作。如果 expression 为 FALSE,assert() 会在标准错误 stderr 上显示错误消息,并中止程序执行。
返回值:无
实例:
#include <assert.h>
#include <stdio.h>
int main()
{
int a;
char str[50];
printf("请输入一个整数值: ");
scanf("%d", &a);
assert(a >= 10);
printf("输入的整数是: %d\n", a);
printf("请输入字符串: ");
scanf("%s", str);
assert(str != NULL);
printf("输入的字符串是: %s\n", str);
return(0);
}

四、不同Linux系统之间文件传输
scp命令介绍
Linux scp 命令用于 Linux 之间复制文件和目录。
scp 是 secure copy 的缩写, scp 是 linux 系统下基于 ssh 登陆进行安全的远程文件拷贝命令。
scp 是加密的,rcp 是不加密的,scp 是 rcp 的加强版。
从本地复制到远程:
scp local_file [email protected]_ip:remote_folder
或者
scp local_file [email protected]_ip:remote_file
或者
scp local_file remote_ip:remote_folder
或者
scp local_file remote_ip:remote_file
第1,2个指定了用户名,命令执行后需要再输入密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名;
第3,4个没有指定用户名,命令执行后需要输入用户名和密码,第3个仅指定了远程的目录,文件名字不变,第4个指定了文件名;
可能出现连接超时问题(虚拟机可以ping通树莓派,树莓派无法ping通虚拟机),此时需要把将VMware的网络连接模式修改为 桥接模式,更改完之后如果是使用SSH客户端(Putty、Xshell类)去连接Ubuntu的,要重新连接,IP地址已经改变
然后再执行scp命令,即可成功上传

参考文献:
https://blog.csdn.net/qq_55691662/article/details/125344629?spm=1001.2014.3001.5502
边栏推荐
- Create a database and use
- 设计原则和思想:设计原则
- Design principles and ideas: design principles
- 3.4 fixed number of cycles II
- #28对象方法扩展
- Design of electronic calculator system based on FPGA (with code)
- Leetcode daily practice (Yanghui triangle)
- express
- Beginner level Luogu 2 [branch structure] problem list solution
- Basic configuration and usage of Jupiter notebook
猜你喜欢
![Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp](/img/80/4edf21e0ac316fe3dd727159621acb.png)
Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp

Numerical extension of 27es6

substrate 技术每周速览 20220411

事件监听机制

Julia constructs diagonal matrix

SIGKDD22|图“预训练、提示、微调”范式下的图神经网络泛化框架

#yyds干货盘点# 解决剑指offer:二叉树中和为某一值的路径(三)

字节跳动埋点数据流建设与治理实践

数据中心表格报表实现定制统计加班请假汇总记录分享

面试半年,上个月成功拿到阿里P7offer,全靠我啃烂了这份2020最新面试题!
随机推荐
等保三级密码复杂度是多少?多久更换一次?
数据中心表格报表实现定制统计加班请假汇总记录分享
PSS:你距離NMS-free+提點只有兩個卷積層 | 2021論文
Create a database and use
MySQL中符号@的作用
Markdown syntax
3.3 one of the fixed number of cycles
New method of cross domain image measurement style relevance: paper interpretation and code practice
事件监听机制
substrate 技术每周速览 20220411
Openssf security plan: SBOM will drive software supply chain security
Realize simple three-D cube automatic rotation
域名绑定动态IP最佳实践
List转Table
LeetCode每日一练(杨辉三角)
一场分销裂变活动,不止是发发朋友圈这么简单!
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
[170] the PostgreSQL 10 field type is changed from string to integer, and the error column cannot be cast automatically to type integer is reported
Design of FIR digital filter
Design of digital video signal processor based on FPGA (with main code)