当前位置:网站首页>树莓派初步使用
树莓派初步使用
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/
五、参考文献
边栏推荐
- Y48. Chapter III kubernetes from introduction to mastery -- pod status and probe (21)
- 【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
- How to enable Hana cloud service on SAP BTP platform
- SAP Spartacus 默认路由配置的工作原理
- 请问CMS里UniAPP版本中的&ldquo;自定义表单列表如何去掉?
- Web crawler 2: crawl the user ID and home page address of Netease cloud music reviews
- leetcode:6107. 不同骰子序列的数目【dp六个状态 + dfs记忆化】
- 【题解】剑指 Offer 15. 二进制中1的个数(C语言)
- 尚硅谷DolphinScheduler视频教程发布
- Can compass open an account for stock trading? Is it safe?
猜你喜欢
Netease Yunxin officially joined the smart hospital branch of China Medical Equipment Association to accelerate the construction of smart hospitals across the country
Yolov6: un cadre de détection de cibles rapide et précis est Open Source
VB. Net class library (advanced version - 1)
Word chess based on heuristic search
VB. Net class library (Advanced - 2 overload)
线性模型LN、单神经网络SNN、深度神经网络DNN与CNN测试对比
Some ways out for older programmers
Application and Optimization Practice of 100 million level monthly live national karaoke feed service in Tencent cloud mongodb
How to analyze financial expenses
【图像处理基础】基于matlab GUI图像直方图均衡化系统【含Matlab源码 1924期】
随机推荐
Using C to operate SQLSERVER database through SQL statement tutorial
【数学建模】基于matlab GUI随机节点的生成树【含Matlab源码 1919期】
Unity3d plug-in anyportrait 2D bone animation
The sharp sword of API management -- eolink
基于启发式搜索的一字棋
Hands on deep learning pytorch version 3 - Data Preprocessing
[solution] sword finger offer 15 Number of 1 in binary (C language)
The latest 2022 research review of "continuous learning, CL"
leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]
Module 5 operation
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)
Application and Optimization Practice of 100 million level monthly live national karaoke feed service in Tencent cloud mongodb
Final part of web crawler: send directional messages to 100000 Netease cloud users
MacOS環境下使用HomeBrew安裝[email protected]
协同过滤进化版本NeuralCF及tensorflow2实现
About appium trample pit: encountered internal error running command: error: cannot verify the signature of (solved)
Usage of MGrid in numpy
AI intelligent matting tool - hair can be seen
leetcode:710. 黑名单中的随机数【映射思维】
在哪个平台买股票开户最安全?求分享