当前位置:网站首页>树莓派初步使用
树莓派初步使用
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/ 

五、参考文献
边栏推荐
- curl: (35) LibreSSL SSL_ connect: SSL_ ERROR_ SYSCALL in connection
- leetcode:1567. Length of the longest subarray whose product is a positive number [dp[i] indicates the maximum length ending with I]
- VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)
- 矩阵求导及其链式法则
- 打新债注册开户有没有什么风险?安全吗?
- Matrix derivation and its chain rule
- 【图像处理基础】基于matlab GUI图像曲线调整系统【含Matlab源码 1923期】
- 【BUG反馈】WebIM在线聊天系统发消息时间问题
- 请问CMS里UniAPP版本中的&ldquo;自定义表单列表如何去掉?
- random_normal_initializer 使用
猜你喜欢

Pass note 【 dynamic planning 】

【数学建模】基于matlab GUI随机节点的生成树【含Matlab源码 1919期】

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

Matrix derivation and its chain rule

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

vulnhub之DC9

Icml2022 | neurotoxin: a lasting back door to federal learning

VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)

The importance of using fonts correctly in DataWindow
![leetcode:710. Random numbers in the blacklist [mapping thinking]](/img/ec/a3faeae6636bc3d0d9536962fdd9af.png)
leetcode:710. Random numbers in the blacklist [mapping thinking]
随机推荐
Is it safe to open a stock account with the QR code given by the CICC securities manager? I want to open an account
同花顺注册开户有没有什么风险?安全吗?
Test comparison of linear model LN, single neural network SNN, deep neural network DNN and CNN
Configure redis master-slave and sentinel sentinel in the centos7 environment (solve the problem that the sentinel does not switch when the master hangs up in the ECS)
2022年,中轻度游戏出海路在何方?
MATLAB and MySQL database connection and data exchange (based on ODBC)
YOLOv6:又快又准的目標檢測框架開源啦
Is there any risk in opening a new bond registration account? Is it safe?
在哪个平台买股票开户最安全?求分享
[bug feedback] the problem of message sending time of webim online chat system
Pass note 【 dynamic planning 】
Convolutional neural network (CNN) explanation and tensorflow2 code implementation
尚硅谷DolphinScheduler视频教程发布
Is there any risk in registering and opening an account for stock speculation? Is it safe?
AI intelligent matting tool - hair can be seen
简析攻防演练中蓝队的自查内容
这个算BUG吗?乱填的字母是否可以关闭
Matrix derivation and its chain rule
DLA model (classification model + improved segmentation model) + deformable convolution
CVPR 2022 - Interpretation of selected papers of meituan technical team