
linux-shell
天麓
很懒的码农
展开
-
meld的使用 Ubuntu入门之六
$ sudo apt install meld正在读取软件包列表... 完成正在分析软件包的依赖关系树 正在读取状态信息... 完成 下列软件包是自动安装的并且现在不需要了: libm17n-0 libotf0 m17n-db xaw3dg使用'sudo apt autoremove'来卸载它(它们)。将会同时安装下列软件: gir1.2-gtksource-3.0 libgtksourceview-3.0-1 libgtksourceview-3.0-commo...原创 2021-09-16 11:03:07 · 1623 阅读 · 0 评论 -
linux timerfd系列函数学习笔记2 获取超时次数
基于笔记1的代码#include <stdlib.h>#include <math.h>#include <stdio.h>#include <errno.h>#include <error.h>#include <unistd.h>#include <sys/timerfd.h>#define ONE_BILLION 1000000000 // 1slong long period_ns = 100原创 2021-09-13 17:31:08 · 194 阅读 · 0 评论 -
linux timerfd系列函数学习笔记1 获取电脑从启动到当前的运行时间
C码获取电脑从启动到当前的运行时间#include <stdlib.h>#include <math.h>#include <stdio.h>#include <errno.h>#include <error.h>#include <sys/timerfd.h>int main(int argc, char *argv[]){ int err; struct timespec expected; int原创 2021-09-13 15:00:40 · 150 阅读 · 0 评论 -
锁屏方法 ubuntu入门之四
$ sudo apt install xtrlock正在读取软件包列表... 完成正在分析软件包的依赖关系树 正在读取状态信息... 完成 下列软件包是自动安装的并且现在不需要了: gsfonts imagemagick-6-common libfftw3-double3 liblqr-1-0 libm17n-0 libmagickcore-6.q16-6 libmagickwand-6.q16-6 libotf0 m17n-db xaw3dg使用'sudo apt a...原创 2021-09-08 18:57:02 · 1476 阅读 · 0 评论 -
网络配置 Ubuntu入门之二
ifconfig -a 可以查看Ubuntu查看IP信息的两种方式https://blog.youkuaiyun.com/sqhren626232/article/details/87707190原创 2021-09-06 22:48:07 · 331 阅读 · 0 评论 -
shell位运算
Linux - Shell - 算数表达式 - 位运算https://www.cnblogs.com/xy14/p/12090859.html原创 2021-07-04 22:57:22 · 309 阅读 · 0 评论 -
busybox 添加删除路由
busybox 添加/删除 路由条目(转)https://www.cnblogs.com/rohens-hbg/articles/5515055.html原创 2020-11-29 08:14:45 · 595 阅读 · 0 评论 -
慢慢欣赏linux kbuild的一些技巧
host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) <=__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) <=hostprogs-y := fixdep docproc hash所以 host-csingle 的值为 fixdep docproc hashif_changed_dep = $(if $(strip $(any-prereq.原创 2020-08-29 22:35:51 · 219 阅读 · 0 评论 -
创建特定文件
yes | awk '{printf "\xff"}' | dd of=ff.img count=1024创建一个为全ff的文件的方法。原创 2020-03-29 11:24:03 · 141 阅读 · 0 评论 -
微视linux bash返回值
linux shell返回function test(){ return 257}写程序测试,发现返回1,也就是 257 mod 256 == 1下面是原因什么是Linux中/ bash程序返回值的有效范围?(What is the valid range for program return value in Linux/bash?)http://www.it1352....原创 2020-03-07 11:08:55 · 214 阅读 · 0 评论 -
慢慢欣赏linux CPU占用率和负载
CPU使用率如何计算,可以参考busybox的实现其原理是每隔5s读一次/proc/stat,两次的值相减作为CPU占用率。/proc/stat的含义详见附件。int top_main(int argc UNUSED_PARAM, char **argv) cpu_jif = &cur_jif; cpu_prev_jif = &prev_jif; ...原创 2018-12-23 07:22:17 · 417 阅读 · 0 评论 -
微视linux 进程的当前目录
先做一个实验创建一个死循环小程序[zl@localhost test]$ pwd/home/zl/test[zl@localhost test]$ vi test.c#include <stdio.h>int main(int argc, char *argv[]){ while (1){ sleep(1); } return 0;}[zl...原创 2020-01-12 12:03:10 · 294 阅读 · 0 评论 -
慢慢欣赏linux shell命令需要用户手动输入Y/N信息,如何通过脚本自动选择
例如脚本里面执行mkfs.ext3,会回显提示信息Y/N。需要用户手工确认。但是我们想自动化自动执行。可以用如下方法:echo y | mkfs.ext3 /dev/sda3原创 2018-10-13 21:29:17 · 13456 阅读 · 1 评论 -
慢慢欣赏linux 语言字符集
LINUX终端乱码解决方法https://blog.youkuaiyun.com/mergerly/article/details/42433539原创 2018-09-22 20:01:12 · 172 阅读 · 0 评论 -
好用的工具
winscp554:ssh可以windows和linux方便拷贝smartmontools :ATA磁盘检测工具原创 2017-07-04 22:06:26 · 176 阅读 · 0 评论 -
linux的进程文件句柄查找
ls -l /proc/*/fd | grep home原创 2017-11-15 07:35:24 · 489 阅读 · 0 评论 -
sed的用法
sed -i命令详解 https://www.cnblogs.com/ev-zhk/p/4277023.html原创 2017-11-15 07:38:00 · 189 阅读 · 0 评论 -
慢慢欣赏linux 进程和线程(一)
进程是具有独立地址空间的;线程没有独立地址空间,内核里面只有线程,因为内核的地址空间是共享的原创 2017-05-25 20:04:02 · 467 阅读 · 0 评论 -
linux用户态程序定位方法总结1 打印调用栈
用户态调用栈可以用backtrace_symbols追踪函数调用栈原创 2018-01-19 07:26:44 · 2519 阅读 · 0 评论 -
shell脚本判断一个目录是否为空的方法
#获取目录大小,格式为 4 /home/testtest_size=`du -s /home/test`#将第一个/以及后面的字符去掉,只留下大小数字test_size_real=${test_size%%/*}if [ $test_size_real ne 0 ];then echo "not empty"else echo "empty"fiShell脚本8...原创 2018-03-11 07:45:12 · 6329 阅读 · 2 评论 -
linux shell通过dd命令去掉文件头部
uboot加载Initrd时需要将intrd加0x40个字节;如果想解压的话需要把这些字节去掉。这时可以用dd命令dd if=src of=des skip=1 bs=64其中skip表示跳过if的多少个块开始拷贝;bs=BYTES,即一个块有多少个字节。man dd里面讲得很清楚。可以参考...原创 2018-12-09 22:10:18 · 4169 阅读 · 0 评论 -
linux shell获取环境变量运算
很多shell运算需要获取环境变量,例如a+b,其中a或者b可能都来自于环境变量。但是环境变量可能出现不存在的情况,这时运算就会出错。 所以在计算前需要判断其是否存在[ -z $test ]更复杂的 input=$1test_mode=$2if [ -z $test_mode ]; then ret=1elif [ $test_mode -eq 1234 ] ...原创 2018-12-09 22:11:23 · 6173 阅读 · 0 评论 -
shell算术和逻辑运算
$(( expression )) 注意前面有$,另外是双括号,缺一不可test=$((5&7))shell基本计算、逻辑运算、位运算详解http://blog.chinaunix.net/uid-24404943-id-3919964.html原创 2018-03-14 07:17:54 · 253 阅读 · 0 评论 -
linux shell运用16进制计算
((test=0x1234))echo $testif [ $test -eq 4660 ]; then echo helloelse echo not hellofilinux-shell 脚本转换 十六进制 十进制 八进制 二进制-zt http://www.51testing.com/html/00/130600-867618.html...原创 2018-12-15 20:36:17 · 14407 阅读 · 0 评论 -
慢慢欣赏linux makefile学习
https://www.cnblogs.com/sky-heaven/p/6272408.html原创 2018-04-18 07:40:11 · 411 阅读 · 0 评论 -
linux bshell 学习
读取一个文件的第一行放到一个变量里面a=`sed -n 1p /root/a.txt`查找一个字符串是否包含在一个变量里面result=`echo $a | grep "hello"`if [$result != ""]; then echo "find the substr"fi或者result=$(echo $a | grep "hello")原创 2017-06-17 19:22:04 · 367 阅读 · 0 评论