当前位置:网站首页>树莓派初步使用
树莓派初步使用
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
边栏推荐
- SQL parsing practice of Pisa proxy
- ICML 2022 ぷ the latest fedformer of the Dharma Institute of Afghanistan ⻓ surpasses SOTA in the whole process of time series prediction
- Use redis to automatically cancel orders within 30 minutes
- Mobile terminal click penetration
- Design of CAN bus controller based on FPGA (with main codes)
- 开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
- Keep valid digits; Keep n digits after the decimal point;
- 设计原则和思想:设计原则
- FPGA based analog I ² C protocol system design (with main code)
- The role of the symbol @ in MySQL
猜你喜欢

Jialichuang EDA professional edition all offline client release

Luogu_ P1007 single log bridge_ thinking

3.4 fixed number of cycles II

Hung - Mung! HDD Hangzhou station · salon hors ligne vous invite à construire l'écologie

Leetcode daily practice (main elements)

Distributed session solution
![Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp](/img/80/4edf21e0ac316fe3dd727159621acb.png)
Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp

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

Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing

LeetCode每日一练(无重复字符的最长子串)
随机推荐
Design principles and ideas: design principles
开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
Format of mobile number
PolarDB-X现在版本的开源兼容什么?mysql8?
#28对象方法扩展
Cesium uses mediastreamrecorder or mediarecorder to record screen and download video, as well as turn on camera recording. [transfer]
28 object method extension
QT audio playback upgrade (7)
Distributed session solution
【kotlin】第二天
3.3 one of the fixed number of cycles
Taishan Office Technology Lecture: the first difficulty is vertical positioning
PolarDB-X开源版有没有支持 mysql5.7 的版本?
[pygame Games] ce jeu "eat Everything" est fantastique? Tu manges tout? (avec code source gratuit)
可变参数模板 Variadic Templates
特殊函数计算器
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?
ICML 2022 ぷ the latest fedformer of the Dharma Institute of Afghanistan ⻓ surpasses SOTA in the whole process of time series prediction
16 -- remove invalid parentheses
【Pygame小游戏】这款“吃掉一切”游戏简直奇葩了?通通都吃掉嘛?(附源码免费领)