作业常用操作

1. shell命令

文件命令:

Ls            查看

Ls-al       查看全部文件

Rm         删除文件

Pwd        显示当前文件

Mkdir     新建一个新目录

Diff          可以用于比较两个文件

                -b忽略空白行;-i 忽略大小写

Shell命令:

Chown   改变所有者

Chgrp    改变用户组

Chmod   改变用户权限

Echo       显示

Echo ${path#/*[删除至的位置]}  从变量内容的最前面开始向右删除且仅删除最短的那个,如果为##则删除最长的那个,如果为%是从最后面开始向前删除.

Echo ${path /[原本的变量]/[替换后的变量]

Export    使某数值成为环境变量

Unset      解除环境变量

Env          显示所有环境变量

Read      键盘读取,-p可以接提示,-t接时间

Declare   -a数组变量 –i 整数 –x 环境变量 –r设置为不可更改

                *declare可以用于计算算式,declare –I ($a+$b)

                *还有一种,双括号计算:sum=$(($a+$b))

Grep        正则表达式查找,grep ‘[查找的内容]’ [从何处查找],以行为单位处理字符串-n显示行号;-vn除查找的内容之外的;-in不分大小写

                ‘[Tt]he’可以查询the和The

Sh            sh –n查询语法错误,-x全部显示

其他重要命令

Find         查找,find [查找范围] –type [类型] –name “[查找内容]”

Test          查询文件是否存在test –e $filename &&echo “no such file”&&exit 0

Cat          抓取文件内容

Md5sum  计算md5的值,md5 filename >[存入的文件]

Xargs       传递函数,把前面的结果作为后面的输入xargs -0处理特殊字符

Sed         var = ${grep ‘[关键词]’ [查找范围]}

2. 脚本格式

#!/bin/bash

#Program

#This program shows “hello world” in your screen

#History

#[time] [name] [History]

BATH=/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

Export PATH

Exit 0

 3. fastboot命令

升级系统

Sudo fastboot flash bootloader u-boot.bin

Sudo fastboot flash bootloader uImage

Sudo fastboot flash system system.img

Sudo fastboot flash userdata userdata.img

Sudo fastboot flash ramdisk ramdisk-uboot.img

Sudo fastboot erase cache

Fastboot flash {分区}  {mg} 比如fastboot flash boot boot.img

Fastboot flashall 在当前目录中查找所有img文件,将这些img文件烧写到所有对应的分区中并重新启动手机

烧写开机界面

Fastboot flash splash1

重启系统

Sudo fastboot reboot

不烧写仅调试

Sudo fastboot boot uImage或者u-boot.bin

复位到bootloader

Sudo fastboot reboot-booter

清空分区

Fastboot erase {分区}

Fastboot erase system –w 清空全部分区

4. 字符设备驱动程序框架

#include <linux/fs.h>  

#include <linux/init.h>

/* 定义一个open函数 */

static int first_drv_open(struct inode *inodep, struct file *filep)

{

    return 0;

}

/* 定义一个write函数 */

static ssize_t first_drv_write(struct file *filep, const char __user * buf, size_t len, loff_t *ppos)

{

    return 0;

}

/* 把自己定义的函数接口集合起来,方便系统使用 */

static const struct file_operations first_drv_file_operation = {

    .open  = first_drv_open,

    .write = first_drv_write,

};

/* 把集合起来的函数接口告诉系统,同时使用111作为该设备的字符设备号 */

static int __init first_drv_init(void)

{

    register_chrdev(111,"first_drv",&first_drv_file_operation);

    return 0;

}

/* 从系统中卸载掉字符设备号为111的设备 */

static void __exit first_drv_exit(void)

{

    unregister_chrdev(111,"first_drv");

}

/* 声明段属性 */

module_init(first_drv_init);

module_exit(first_drv_exit);

MODULE_LICENSE("GPL");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值