当前位置:网站首页>树莓派初步使用
树莓派初步使用
2022-06-26 22:01:00 【weixin_47300459】
文章目录
一、创建新用户
一、创建新用户
创建用户:
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程序练习
1.创建一个c程序
vi 程序名.c
2.进入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);
}
3.按Esc退出编辑模式,输入:wq(表示保存并退出)
4.编译程序gcc 程序名.c -o 程序名
三、assert()理解
简介
C 标准库的 assert.h头文件提供了一个名为 assert 的宏,它可用于验证程序做出的假设,并在假设为假时输出诊断消息。
库宏
assert.h头文件定义了唯一的函数:assert()
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);
}
如果输入的整数大于等于10,输入的字符串不为空,程序会继续运行;如果条件不满足程序终止
四、不同Linux系统之间文件传输
如在Ubuntu系统与树莓派系统之间文件传输
scp命令介绍
Linux scp 命令用于 Linux 之间复制文件和目录。
scp 是 secure copy 的缩写, scp 是 linux 系统下基于 ssh 登陆进行安全的远程文件拷贝命令。
scp 是加密的,rcp 是不加密的,scp 是 rcp 的加强版。
语法
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[[email protected]]host1:]file1 [...] [[[email protected]]host2:]file2
实例
从本地复制到远程:
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个指定了文件名;
应用(将树莓派刚才创建的.c文件传输到Ubuntu下)
:sudo scp assert.c [email protected]:/home/xjc/ 

五、参考文献
边栏推荐
- leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]
- fastadmin极光推送发送消息的时候registration_id多个用逗号分割后无效
- 网络爬虫2:抓取网易云音乐评论用户ID及主页地址
- [bug feedback] the problem of message sending time of webim online chat system
- DAST black box vulnerability scanner part 5: vulnerability scanning engine and service capability
- 基于启发式搜索的一字棋
- MATLAB与Mysql数据库连接并数据交换(基于ODBC)
- VB. Net class library (Advanced - 2 overload)
- vulnhub之DC9
- numpy中mgrid的用法
猜你喜欢

Netease Yunxin officially joined the smart hospital branch of China Medical Equipment Association to accelerate the construction of smart hospitals across the country

MATLAB与Mysql数据库连接并数据交换(基于ODBC)

leetcode:152. 乘积最大子数组【考虑两个维度的dp】
![[fundamentals of image processing] GUI image histogram equalization system based on MATLAB [including Matlab source code 1924]](/img/8a/f5847eef7318f3db54aa2d4405b06a.jpg)
[fundamentals of image processing] GUI image histogram equalization system based on MATLAB [including Matlab source code 1924]

Implementation of collaborative filtering evolution version neuralcf and tensorflow2

Kdd2022 𞓜 unified session recommendation system based on knowledge enhancement prompt learning

VB. Net class library (Advanced - 2 overload)

Using C to operate SQLSERVER database through SQL statement tutorial
![Flower shop window layout [dynamic planning]](/img/d9/6b8f9cd0f74e70b313d2571c2ded30.png)
Flower shop window layout [dynamic planning]

【数学建模】基于matlab GUI随机节点的生成树【含Matlab源码 1919期】
随机推荐
数据治理啥都干
Yolov6: the fast and accurate target detection framework is open source
网络连接断开请刷新重试
聊聊我的远程工作体验 | 社区征文
Release of dolphin scheduler video tutorial in Shangsi Valley
[fundamentals of image processing] GUI image histogram equalization system based on MATLAB [including Matlab source code 1924]
同花顺注册开户有没有什么风险?安全吗?
买股票通过中金证券经理的开户二维码开户资金是否安全?想开户炒股
SAP commerce cloud project Spartacus getting started
Word chess based on heuristic search
如何用 SAP BTP 平台上的图形建模器创建一个 OData 服务
VB. Net class library (advanced version - 1)
【题解】剑指 Offer 15. 二进制中1的个数(C语言)
简析攻防演练中蓝队的自查内容
YOLOv6:又快又准的目标检测框架开源啦
Y48. Chapter III kubernetes from introduction to mastery -- pod status and probe (21)
中金证券经理给的开户二维码办理股票开户安全吗?我想开个户
Unity: 脚本缺失 “The referenced script (Unknown) on this Behaviour is missing!“
CVPR 2022 - Interpretation of selected papers of meituan technical team
LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)