当前位置:网站首页>树莓派初步使用
树莓派初步使用
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
边栏推荐
- PolarDB-X现在版本的开源兼容什么?mysql8?
- 3.3 one of the fixed number of cycles
- 手机号码的格式
- 华为云DevCloud重磅发布四大新能力,创下国内两项第一
- 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!
- Hongmeng makes efforts! HDD Hangzhou station · offline salon invites you to build ecology
- 华为云首次解读云原生2.0十大典型架构,加速构建现代化应用
- Leetcode daily practice (Yanghui triangle)
- The array of C language is a parameter to pass a pointer
- 关于快速幂
猜你喜欢

3.3 one of the fixed number of cycles

express

Bit. Store: long bear market, stable stacking products may become the main theme

一场分销裂变活动,不止是发发朋友圈这么简单!

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

事务的四大特性

#28对象方法扩展
![Beginner level Luogu 1 [sequence structure] problem list solution](/img/60/5e151ba31eb00374c73be52e3bfa7e.png)
Beginner level Luogu 1 [sequence structure] problem list solution

ICML 2022 | 阿⾥达摩院最新FEDformer,⻓程时序预测全⾯超越SOTA

Centos8 PostgreSQL initialization error: initdb: error: invalid locale settings; check LANG and LC_* environment
随机推荐
LeetCode每日一练(杨辉三角)
3.1 simple condition judgment
Condom giants' sales have fallen by 40% in the past two years. What are the reasons for the decline?
SQL injection principle
SQL parsing practice of Pisa proxy
P.A.R.A 方法在思源的简易应用(亲测好用)
机械硬盘和ssd固态硬盘的原理对比分析
Leetcode daily practice (longest substring without repeated characters)
Relation and operation of ORM table
QT audio playback upgrade (7)
PolarDB-X现在版本的开源兼容什么?mysql8?
3.3 one of the fixed number of cycles
Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp
List转Table
域名绑定动态IP最佳实践
Domain name binding dynamic IP best practices
PSS:你距离NMS-free+提点只有两个卷积层 | 2021论文
【Pygame小游戏】这款“吃掉一切”游戏简直奇葩了?通通都吃掉嘛?(附源码免费领)
[pyGame games] this "eat everything" game is really wonderful? Eat them all? (with source code for free)
锚文本大量丢失的问题