-
docker install:https://docs.docker.com/install/linux/docker-ce/ubuntu/
-
在docker中使用gdb,遇到“warning: Error disabling address space randomization: Operation not permitted
”
Solution:need the --security-opt seccomp=unconfined option(docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined)
Reference:https://stackoverflow.com/questions/35860527/warning-error-disabling-address-space-randomization-operation-not-permitted -
运行docker ps -a 出现 ”connect: permission denied“
usermod -aG docker [userid]
or
#将登陆用户加入到docker用户组中 sudo gpasswd -a $USER docker #更新用户组, 如果没有docker用户组,使用sudo groupadd docker 创建 newgrp docker
reference:
https://blog.csdn.net/jiangjiang_jian/article/details/89452631
https://www.digitalocean.com/community/questions/how-to-fix-docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket -
自己编写docker 启动脚本,判断docker是否存在
docker ps -a | grep $DOCKER_NAME &> /dev/null if [ $? -eq 0 ]; then echo "$DOCKER_NAME already exist, remove first" docker stop $DOCKER_NAME docker rm $DOCKER_NAME fi
-
shell特殊变量
变量 | 含义 |
---|---|
$0 | 当前脚本的文件名 |
$n | 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是$1,第二个参数是$2。 |
$# | 传递给脚本或函数的参数个数。 |
$* | 传递给脚本或函数的所有参数。 |
$@ | 传递给脚本或函数的所有参数。被双引号(" ")包含时,与 $* 稍有不同,下面将会讲到。 |
$? | 上个命令的退出状态,或函数的返回值。一般成功返回0,失败1 |
$$ | 当前Shell进程ID。对于 Shell 脚本,就是这些脚本所在的进程ID。 |
$* 和 $@ 的区别
相同
$* 和 $@ 都表示传递给函数或脚本的所有参数,不被双引号(" “)包含时,都以”$1" “ 2 " … " 2" … " 2"…"n” 的形式输出所有参数。
不同
但是当它们被双引号(" “)包含时,”$*" 会将所有的参数作为一个整体,以"$1 $2 … n " 的形式输出所有参数; " n"的形式输出所有参数;" n"的形式输出所有参数;"@" 会将各个参数分开,以"$1" “ 2 " … " 2" … " 2"…"n” 的形式输出所有参数。
-
shell中的条件表达式
#文件表达式 if [ -f file ] 如果文件存在 if [ -d ... ] 如果目录存在 if [ -s file ] 如果文件存在且非空 if [ -r file ] 如果文件存在且可读 if [ -w file ] 如果文件存在且可写 if [ -x file ] 如果文件存在且可执行
#整数变量表达式 if [ int1 -eq int2 ] 如果int1等于int2 if [ int1 -ne int2 ] 如果不等于 if [ int1 -ge int2 ] 如果>= if [ int1 -gt int2 ] 如果> if [ int1 -le int2 ] 如果<= if [ int1 -lt int2 ] 如果<
#字符串变量表达式 If [ $a = $b ] 如果string1等于string2 字符串允许使用赋值号做等号 if [ $string1 != $string2 ] 如果string1不等于string2 if [ -n $string ] 如果string 非空(非0),返回0(true) if [ -z $string ] 如果string 为空 if [ $sting ] 如果string 非空,返回0 (和-n类似)
reference :https://www.cnblogs.com/myitm/archive/2012/07/05/2577416.html
-
shell中简单的getopts使用
usage() { echo "Usage:" echo "./dockerrun.sh <-n docker_name> <-d DISPLAY>" exit -1 } while getopts 'n:d:' OPT; do case $OPT in n) DOCKER_NAME="$OPTARG";; d) DISPLAY="$OPTARG";; ?) usage;; esac done [ -z "$DOCKER_NAME" ] && usage [ -z "$DISPLAY" ] && usage
-
linux shell command一起执行
1) 用;
分隔:各个命令都会执行,但不保证每个命令都执行成功。cd /home; ./cmd.sh
2) 用
&&
分隔:若前面的命令执行成功,才会去执行后面的命令cd /home && ./cmd.sh
3)用
||
或|
分隔:只有前面的命令执行失败后才去执行下一条命令,直到执行成功cd /home || echo "something went wrong"
-
sudo :xxx is not in the sudoers file. This incident will be reported.
在/etc/sudoers文件里给该用户添加权限:
https://blog.csdn.net/sinat_36118270/article/details/62899093 -
cp命令直接覆盖不提示按Y/N的方法
cp -rf a.log dic/
如果依然提示是否覆盖,可能是系统增加了别名,用
alias
查询,显示alias cp=’cp -i‘,说明使用的别名
方法1:修改~/.bashrc文件注释掉cp的alias,修改后需要重新登陆#alias cp=’cp -i‘
方法2:在cp前增加’\’
\cp -rf a.log dic/
-
root密码提示错误以及修改root密码
先解除root锁定,为root用户设置密码 打开终端输入:sudo passwd Password: <— 输入你当前用户的密码
Enter new UNIX password: <— 新的Root用户密码
Retype new UNIX password: <— 重复新的Root用户密码 passwd:已成功更新密码reference:https://blog.csdn.net/damotiansheng/article/details/44886093
-
vim
- 显示不可见字符
:set invlist
, 例如,会以^I
表示一个tab符,$
表示一个回车符等, 取消显示:set nolist
- 空格和tab互换:将tab变成空格
:set expandtab
;取消:set noexpandtab
- 替换:
:%s/foo/bar/gcI
g
表示全局,c
表示需要确认,I
表示大小写敏感(https://harttle.land/2016/08/08/vim-search-in-file.html)
- 显示不可见字符
-
difference between “sudo apt-get” and “sudo -E apt-get”
Answer: If you run sudo , the command will be executed in its
own environment as root. If you add the -E option to sudo, the command
will be executed as root, but with most of your environment copied
over.Reference: https://askubuntu.com/questions/752801/difference-between-sudo-apt-get-and-sudo-e-apt-get
-
v4l2相关
- 在ubuntu上安装
v4l2-ctrl
:sudo apt install v4l-utils
- 查看v4l2设备:
v4l2-ctrl --list-devices
- 查看v4l2设备信息:
v4l2-ctrl -d /dev/video33 --all
udevadm info /dev/video33
- 在ubuntu上安装
-
cxxflags , cppflags和cflags的区别:
link: https://stackoverflow.com/questions/495598/difference-between-cppflags-and-cxxflags-in-gnu-makeCPPFLAGS is supposed to be for flags for the C PreProcessor; CXXFLAGS is for flags for the C++ compiler.
The default rules in make (on my machine, at any rate) pass CPPFLAGS to just about everything, CFLAGS is only passed when compiling and linking C, and CXXFLAGS is only passed when compiling and linking C++. -
在vnc中安装vs code后,运行code --verbose遇到Xlib: extension “XInputExtension” missing on display “:1.0”.
reference:https://stackoverflow.com/questions/55802252/visual-studio-code-wont-open-on-ubuntu-16-04-via-vnc
solution:#make a copy of the relevant library mkdir ~/lib cp
/usr/lib/x86_64-linux-gnu/libxcb.so.1 ~/lib sed -i
‘s/BIG-REQUESTS/_IG-REQUESTS/’ ~/lib/libxcb.so.1 #set the dynamic
loader path to put your library first before executing VS Code
LD_LIBRARY_PATH=$HOME/lib code -
vnc untuntu sudo apt-get install wireshark后,执行wireshark遇到:
> Qt: XKEYBOARD extension not present on the X server
> The X11 connection broke: Maximum allowed requested length exceeded(code 4)
Solution:
```
sudo apt-get remove --autoremove wireshark wireshark-*
sudo apt-get install wireshark-gtk
```
-
vundle安装vim插件:
reference:
https://blog.csdn.net/lu_embedded/article/details/76732965
https://blog.csdn.net/zhangpower1993/article/details/52184581 -
下载adb tool 地址
https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
https://dl.google.com/android/repository/platform-tools-latest-windows.zip -
adb devices 设备找不到: http://gityuan.com/2015/09/18/adb-1/
-
qt环境配置:https://blog.csdn.net/czhzasui/article/details/81171752(或者qmake could not find a qt installation of ‘’)
-
qt creator 安装后,创建项目时出现“No valid kits found”
按照提示点击“options”,然后在Qt Versions中,选择Qt的版本;
reference:https://blog.csdn.net/a6625138/article/details/47296283 -
qt执行的时候遇到:could not start process make -f qmake_all
sudo apt-get install build-essential
reference:https://stackoverflow.com/questions/47810466/could-not-start-process-make-qmake-all -
安装intellij-idea-community
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install snapd
sudo snap install intellij-idea-community --classic -
搭建本地git server:https://www.linux.com/tutorials/how-run-your-own-git-server/
-
googletest doc:
https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md
https://github.com/google/googletest/blob/master/googlemock/test/gmock-matchers_test.cc
https://github.com/google/googletest/blob/master/googletest/docs/faq.md -
vim显示^M:
:set ff=unix
-
ifconfig: command not found
sudo apt-get install net-tools
-
ping: command not found
sudo apt-get install iputils-ping
-
grep: -n 显示行号 grep -nr apple*
-
tail -f <file> 实时读取file末尾的内容
eg:tail -f /var/log/syslog &
之后, 如果有log输入到syslog中,屏幕就会自动打印这些log -
ps命令
ps -eT -o pid -o tid -o pri -o rtprio -o policy -o comm | grep \`pidof mediad\`
-o: 格式化输出
reference: http://blog.itpub.net/29270124/viewspace-2564950/ -
ldd命令
eg:ldd libxxx.so 查看库依赖
;ldd -r libxxx.so 查看so中有哪些符号未定义
查找发现makefile编译动态库时,找不到链接符号也是允许编译通过的,那最好是加上限制条件,在makefile加上 -Xlinker --unresolved-symbols=ignore-in-shared-libs ,让其报错,把未定义的符号给报错出来。 -
ulimit命令
ulimit -a
查看core file/stack/data seg size的配置情况 -
xargs带复杂参数
find . -name "*.so" | xargs -I % -t scp % yubm@ip_address:/home/ftp/
:把找到的*.so文件scp到 yubm@ip_address:/home/ftp/目录
xargs -I 参数指定了%作为占位符。它将指代ls命令返回的字符串作为参数。然后在后面的命令中,使用%代替了参数值;
xargs -t 参数作用是打印命令行 -
systemd命令
systemctl list-units #显示当前内存中的units systemctl list-units --all --type=service #列出系统所有服务 systemctl start/stop httpd.service
reference:
http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
https://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html
https://wizardforcel.gitbooks.io/vbird-linux-basic-4e/content/150.html
https://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/index.html -
sort
-
dns server
更改dns serversudo systemd-resolve --interface wlp2s0 --set-dns 8.8.8.8
查看dns serversystemd-resolve --status | grep ‘DNS’
查看dns cachesystemd-resolve --statistics
清空dns cachesudo systemd-resolve --flush-caches
-
undefined reference to错误的解决方法:https://blog.csdn.net/cserchen/article/details/5503556
-
key input event
- /proc/bus/input/devices
各个字段解释:https://unix.stackexchange.com/questions/74903/explain-ev-in-proc-bus-input-devices-data
http://www.jollen.org/blog/2009/04/linux_input_device_apis.html - xev/showkey
- qt virtual keyboard : https://www.kdab.com/qt-input-method-virtual-keyboard/
- /proc/bus/input/devices
-
stream socket和datagrams socket的区别
A datagram socket is like passing a note in class. Consider the case where you are not directly next to the person you are passing the note to; the note will travel from person to person. It may not reach its destination, and it may be modified by the time it gets there. If you pass two notes to the same person, they may arrive in an order you didn’t intend, since the route the notes take through the classroom may not be the same, one person might not pass a note as fast as another, etc.
So you use a stream socket when having information in order and intact is important. File transfer protocols are a good example here. You don’t want to download some file with its contents randomly shuffled around and damaged!
You’d use a datagram socket when order is less important than timely delivery (think VoIP or game protocols), when you don’t want the higher overhead of a stream (this is why DNS is primarily a datagram protocol, so that servers can respond to many, many requests at once very quickly), or when you don’t care too much if the data ever reaches its destination.
To expand on the VoIP/game case, such protocols include their own data-ordering mechanism. But if one packet is damaged or lost, you don’t want to wait on the stream protocol (usually TCP) to issue a re-send request – you need to recover quickly. TCP can take up to some number of minutes to recover, and for realtime protocols like gaming or VoIP even three seconds may be unacceptable! Using a datagram protocol like UDP allows the software to recover from such an event extremely quickly, by simply ignoring the lost data or re-requesting it sooner than TCP would.
VoIP is a good candidate for simply ignoring the lost data – one party would just hear a short gap, similar to what happens when talking to someone on a cell phone when they have poor reception. Gaming protocols are often a little more complex, but the actions taken will usually be to either ignore the missing data (if subsequently-received data supercedes the data that was lost), re-request the missing data, or request a complete state update to ensure that the client’s state is in sync with the server’s.
source:https://stackoverflow.com/questions/4688855/whats-the-difference-between-streams-and-datagrams-in-network-programming