linux command ref

linux command ref

Guide

ln

ln -s src dest

ln -s $(pwd)/yolo /home/kezunlin/program/darknet/kzl-yolo

tips: use absolute path to link folder

sed

case1

sed -i "s/old/new/g" 1.txt

replace “old” with “new”

case2

sed -i "s/http:\/\/kezunlin.me/https:\/\/kezunlin.me/g" posts/post1.md

replace “http://kezunlin.me" with “https://kezunlin.me"

grep

case1

grep UpsampleParameter . -r --include *.h 

grep UpsampleParameter . -r --include *.proto
./src/caffe/proto/caffe.proto:  optional UpsampleParameter upsample_param = 150;
./src/caffe/proto/caffe.proto:message UpsampleParameter {

case2

grep -r "http://kezunlin.me" posts/ 
posts/post1.md:[here](http://kezunlin.me/post/book)
posts/post2.md:-[here](http://kezunlin.me/post/book)
posts/post2.md:- [img](http://kezunlin.me/post/book)

case3

grep -rl "http://kezunlin.me" posts 
posts/post1.md
posts/post2.md

case4

sed -i "s/http:\/\/kezunlin.me/https:\/\/kezunlin.me/g" `grep -rl "http://kezunlin.me" posts`  

replace http://kezunlin.me with https://kezunlin.me in all posts files.

case5

sed -i "s/comments\: false/comments\: true/g" _posts/*

replace comments: false with comments: true in all posts files.

ldd

for so

ldd test_opencv | awk '/ => / { print $3 }'
(0x00007fff309d4000)
/usr/local/lib/libopencv_imgcodecs.so.3.1
/usr/local/lib/libopencv_core.so.3.1
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/lib/x86_64-linux-gnu/libgcc_s.so.1
/lib/x86_64-linux-gnu/libc.so.6
/usr/local/lib/libopencv_imgproc.so.3.1
/usr/local/lib/libjpeg.so.8
/lib/x86_64-linux-gnu/libpng12.so.0
/usr/lib/x86_64-linux-gnu/libtiff.so.5
/usr/lib/x86_64-linux-gnu/libjasper.so.1
/lib/x86_64-linux-gnu/libz.so.1
/lib/x86_64-linux-gnu/libm.so.6
/lib/x86_64-linux-gnu/libpthread.so.0
/lib/x86_64-linux-gnu/libdl.so.2
/lib/x86_64-linux-gnu/librt.so.1
/lib/x86_64-linux-gnu/liblzma.so.5
/usr/lib/x86_64-linux-gnu/libjbig.so.0

for not found

ldd test_opencv | awk 'NF==1 {file=$1} /not found/ { print file, $1 }'

useful

ldd example_opencv | awk  '{if (match($3,"/")){ printf("%s \n"),$3 } }'
/usr/local/lib/libopencv_imgcodecs.so.3.1 
/usr/local/lib/libopencv_core.so.3.1 
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 
/lib/x86_64-linux-gnu/libgcc_s.so.1 
/lib/x86_64-linux-gnu/libc.so.6 
/usr/local/lib/libopencv_imgproc.so.3.1 
/usr/local/lib/libjpeg.so.8 
/lib/x86_64-linux-gnu/libpng12.so.0 
/usr/lib/x86_64-linux-gnu/libtiff.so.5 
/usr/lib/x86_64-linux-gnu/libjasper.so.1 
/lib/x86_64-linux-gnu/libz.so.1 
/lib/x86_64-linux-gnu/libm.so.6 
/lib/x86_64-linux-gnu/libpthread.so.0 
/lib/x86_64-linux-gnu/libdl.so.2 
/lib/x86_64-linux-gnu/librt.so.1 
/lib/x86_64-linux-gnu/liblzma.so.5 
/usr/lib/x86_64-linux-gnu/libjbig.so.0 

curl

login website with json data

curl -X POST \
  -H "Accept: application/json" -H "Content-type: application/json" \
  --data '{"name":"admin","password":"21232f297a57a5a743894a0e4a801fc3"}' \
  http://192.168.0.12:8888/api/login 

md5(admin) = 21232f297a57a5a743894a0e4a801fc3

output

{"rtn":0,"message":"OK","session_id":"[email protected]"}

query results with session_id

curl -X GET \
    -H "session_id: [email protected]" \
    http://192.168.0.12:8888/api/book

download file

curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Tips

check cpu

cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 
      8  Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz


cat /proc/cpuinfo | grep physical | uniq -c 
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual
      1 physical id    : 0
      1 address sizes    : 39 bits physical, 48 bits virtual

check gpu

lspci | grep -i vga
  00:02.0 VGA compatible controller: Intel Corporation Device 591b (rev 04)
  01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c20 (rev a1)


lspci -v -s 01:00.0
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c20 (rev a1) (prog-if 00 [VGA controller])
    Subsystem: CLEVO/KAPOK Computer Device 65a1
    Flags: bus master, fast devsel, latency 0, IRQ 130
    Memory at db000000 (32-bit, non-prefetchable) [size=16M]
    Memory at 90000000 (64-bit, prefetchable) [size=256M]
    Memory at a0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at e000 [size=128]
    [virtual] Expansion ROM at dc000000 [disabled] [size=512K]
    Capabilities: <access denied>
    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_396, nvidia_396_drm

nvidia-smi
Tue Feb 12 10:09:14 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.54                 Driver Version: 396.54                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1060    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   56C    P8     8W /  N/A |    601MiB /  6078MiB |      3%      Default |
+-------------------------------+----------------------+----------------------+


watch -n 1 nvidia-smi

pip install gpustat
watch --color -n1 gpustat -cpu 

Reference

History

  • 20181130: created.
坚持技术分享,您的支持将鼓励我继续创作!