当前位置:网站首页>树莓派初步使用
树莓派初步使用
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
边栏推荐
- Condom giants' sales have fallen by 40% in the past two years. What are the reasons for the decline?
- Eolink launched a support program for small and medium-sized enterprises and start-ups to empower enterprises!
- [kotlin] the next day
- 正则匹配以什么开头、以什么结尾,以非什么开头,以非什么结尾
- QT5 之信号与槽机制(信号与槽的基本介绍)
- 关于快速幂
- 【170】PostgreSQL 10字段类型从字符串修改成整型,报错column cannot be cast automatically to type integer
- 面试半年,上个月成功拿到阿里P7offer,全靠我啃烂了这份2020最新面试题!
- Expert: those who let you go to a good school with a low score are all Scams
- List转Table
猜你喜欢
The role of the symbol @ in MySQL

PSS:你距離NMS-free+提點只有兩個卷積層 | 2021論文

守护雪山之王:这些AI研究者找到了技术的新「用武之地」

Eolink launched a support program for small and medium-sized enterprises and start-ups to empower enterprises!

开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事

LeetCode每日一练(无重复字符的最长子串)
![Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp](/img/80/4edf21e0ac316fe3dd727159621acb.png)
Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp

Distributed session solution

The interview lasted for half a year. Last month, I successfully got Alibaba p7offer. It was all because I chewed the latest interview questions in 2020!

米哈游起诉五矿信托,后者曾被曝产品暴雷
随机推荐
The latest development course of grain college in 2022: 8 - foreground login function
VS编译遇到的问题
Google Earth Engine(GEE)——Export. image. The difference and mixing of toasset/todrive, correctly export classification sample data to asset assets and references
ORM表关系及操作
PSS:你距离NMS-free+提点只有两个卷积层 | 2021论文
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
SQL parsing practice of Pisa proxy
2022年最新《谷粒学院开发教程》:8 - 前台登录功能
A distribution fission activity is more than just a circle of friends!
If you want to use DMS to handle database permissions, can you only use Alibaba cloud ram accounts (Alibaba cloud RDS)
Scrapy framework (I): basic use
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
Weekly snapshot of substrate technology 20220411
In the Alibaba cloud experiment, if the k8s forwards to port 3306 and the MySQL client is turned on, it will terminate abnormally. What is the reason?
Expert: those who let you go to a good school with a low score are all Scams
Design of digital video signal processor based on FPGA (with main code)
3.4 fixed number of cycles II
Beginner level Luogu 2 [branch structure] problem list solution
New method of cross domain image measurement style relevance: paper interpretation and code practice
What is the level 3 password complexity of ISO? How often is it replaced?