以后知道一个写一个
valgrind
可用来检验内存泄漏出处
valgrind --tool=memcheck --leak-check=full ./test
adl@adl:~/桌面/json-tutorial/tutorial03/images$ valgrind ./leptjson_test --leak-check=full
==7458== Memcheck, a memory error detector
==7458== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7458== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==7458== Command: ./leptjson_test --leak-check=full
==7458==
160/160 (100.00%) passed
==7458==
==7458== HEAP SUMMARY:
==7458== in use at exit: 6 bytes in 1 blocks
==7458== total heap usage: 12 allocs, 11 frees, 2,092 bytes allocated
==7458==
==7458== LEAK SUMMARY:
==7458== definitely lost: 6 bytes in 1 blocks
==7458== indirectly lost: 0 bytes in 0 blocks
==7458== possibly lost: 0 bytes in 0 blocks
==7458== still reachable: 0 bytes in 0 blocks
==7458== suppressed: 0 bytes in 0 blocks
==7458== Rerun with --leak-check=full to see details of leaked memory
==7458==
==7458== For counts of detected and suppressed errors, rerun with: -v
==7458== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
adl@adl:~/桌面/json-tutorial/tutorial03/images$ valgrind --tool=memcheck --leak-check=full ./
CMakeFiles/ leptjson_test
adl@adl:~/桌面/json-tutorial/tutorial03/images$ valgrind --tool=memcheck --leak-check=full ./leptjson_test
==7516== Memcheck, a memory error detector
==7516== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7516== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==7516== Command: ./leptjson_test
==7516==
160/160 (100.00%) passed
==7516==
==7516== HEAP SUMMARY:
==7516== in use at exit: 6 bytes in 1 blocks
==7516== total heap usage: 12 allocs, 11 frees, 2,092 bytes allocated
==7516==
==7516== 6 bytes in 1 blocks are definitely lost in loss record 1 of 1
==7516== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7516== by 0x10F532: lept_set_string (in /home/adl/桌面/json-tutorial/tutorial03/images/leptjson_test)
==7516== by 0x10E83F: test_access_string (in /home/adl/桌面/json-tutorial/tutorial03/images/leptjson_test)
==7516== by 0x10E9AC: test_parse (in /home/adl/桌面/json-tutorial/tutorial03/images/leptjson_test)
==7516== by 0x10E9BD: main (in /home/adl/桌面/json-tutorial/tutorial03/images/leptjson_test)
==7516==
==7516== LEAK SUMMARY:
==7516== definitely lost: 6 bytes in 1 blocks
==7516== indirectly lost: 0 bytes in 0 blocks
==7516== possibly lost: 0 bytes in 0 blocks
==7516== still reachable: 0 bytes in 0 blocks
==7516== suppressed: 0 bytes in 0 blocks
==7516==
==7516== For counts of detected and suppressed errors, rerun with: -v
==7516== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
telnet
可当客户端
telnet 127.0.0.1 12345
(会有\r\n)
nc
nc可以当成客户或者服务器
tcpdump
抓包
sudo tcpdump -i lo tcp port 12345 and host 127.0.0.1
[.]ACK, [R]RST,[F]FIN,[S]SYN [S.]SYN+ACK
top -d 查看cpu占用情况!
find(这个记下是因为老是忘)
find . -maxdepth 5 -name “cJSON.*” 指定查找的深度为5
ranger
一个可以通过上下左右就可以快速访问各级目录的命令
awk 配合 ps grep 杀死你想结束的进程
ps -ef | grep vim | awk ‘{print $2}’| xargs kill -9
rm 想含有’-'文件名的文件
解决方法:在文件名之前加”–“来删除文件
g++ 指定编译版本
g++ -std=c++17 stdAnyTest.cpp
将一个文件下所有的后缀为.cgi --->.py
rename 's/.py/.cgi/' *
遇到程序游离的奇怪字符导致不能编译,
可以用od -c
找出如302 240的奇奇怪怪玩意儿
解决方案:
使用sed做下全文替换,命令如下:
sed -i 's/\o240\|\o302//g' testaio.cpp
\o指定用8进制编码,中间的|是指要同时替换多个,这样就OK了。
c/c++最强语法检查:double free ,no free都可以发现
g++ 140.cpp -fsanitize=address
linux下生成随机密码:
cat /dev/urandom|tr -dc "a-zA-Z0-9-_\$\?\*\%\$\@\(\)\_\+"|fold -w 13|head
linux下让一个脚本跑完继续跑(可以每次停任意时间)(可以放在后台监控):
#!/bin/bash
while [ true ]; do
ls -R /
sleep 1
done
line下让一个脚本定时运行:在/etc/crontab下添加任务
*/1 * * * * root /home/adl/test.sh >> /home/adl/test.txt
让 test.sh每分钟跑一次并将输入写入到test.txt中。(还可以调整为每小时/每天/每月…)
❯
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * root /home/adl/test.sh >> /home/adl/test.txt
#
linux下交换俩文件名称
swap.sh
#!/bin/bash
if [ ! -n "$1" ];then
echo "Exchange Error:缺少参数1"
exit 0
elif [ ! -n "$2" ];then
echo "Exchange Error:缺少参数2"
exit 0
fi
dm01=$1
dm02=$2
mv $1 backup
mv $2 $dm01
mv backup $dm02
echo "Change Success!"
chmod a+x swap.sh
后将这个脚本放到/usr/bin/
下
效果:
桌面/dockerlib/mynginx
❯ swap.sh ../a.txt b.txt
Change Success!
linux下tab补全咋实现的:
tab实现