linux命令杂记

色温调节软件
https://blog.csdn.net/DreamHome_S/article/details/78439098
https://blog.csdn.net/touch_dream/article/details/80499900


文件过多时报错arguments list too long

find . -name "*.xml" -print0 | xargs -0 rm

find ./00012524 -type f -name "*.PDF" -exec cp {} ./dummy01/ ; -print

find -type f -name '*.txt' | wc -l
image.png

统计目录下文件个数

ls -l | grep "^-" | wc -l

http://noahsnail.com/2017/02/07/2017-02-07-Linux%E7%BB%9F%E8%AE%A1%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%8B%E7%9A%84%E6%96%87%E4%BB%B6%E6%95%B0%E7%9B%AE/

时间相关

设置时间
date +%Y%m%d -s "20190618"
date +%T -s "14:29:00"

更改硬件时钟
sudo hwclock --set --date "mm/dd/yyyy hh:mm:ss"
sudo hwclock -s
具体查看sudo hwclock --help

ubuntu 18.04 开启ntp同步
timedatectl set-ntp yes

查看目录大小

du -hs /path/to/directory

  • -h is to get the numbers "human readable", e.g. get 140M instead of 143260 (size in KBytes)
  • -s is for summary (otherwise you'll get not only the size of the folder but also for everything in the folder separately)
  • -d, --max-depth=N print the total for a directory (or file, with --all)
    only if it is N or fewer levels below the command
    line argument; --max-depth=0 is the same as
    --summarize

判断opencv版本

It worked for me like that in C++ : cout<<"OpenCV Version used:"<

Makefile中输出信息

https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile

$(info $$var is [${var}])

查看pip把包安装到哪里去了

pip show [package name]

查看某个package安装在什么位置

You can import the module and check the module.__file__ string. It contains the path to the associated source file.
Alternatively, you can read the File tag in the the module documentation, which can be accessed using help(module), or module? in IPython.

查看新接入的usb设备名称

ls -1 /dev > ~/before.txt
插上设备
ls -1 /dev > ~/after.txt
diff ~/before.txt ~/after.txt

tty设备

http://www.voidcn.com/article/p-tkkjtere-vo.html
/dev/tty*设备open 失败
1.由于tty属于“dialout”组别,比如用户名是joeuser,先命令查看下用户隶属的组别

groups joeuser

2.如果没有隶属“dialout”,那么把用户加入进去

sudo gpasswd --add joeuser dialout

3.logout 再登录系统激活功能

shell 替换字符串

sed -i 's/old-text/new-text/g' input.txt

sed -i 's//home/sc/work_codes/yolo/320_320_yolov3_红绿灯//home/train/disk/data/g' input_autotune.txt

创建软链接

ln -s file filesoft //前面是目标文件名 后面是快捷方式名

ldconfig命令

ldconfig命令的用途主要是在默认搜寻目录/lib和/usr/lib以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态链接库(格式如lib.so),进而创建出动态装入程序(ld.so)所需的连接和缓存文件。缓存文件默认为/etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表,为了让动态链接库为系统所共享,需运行动态链接库的管理命令ldconfig,此执行程序存放在/sbin目录下。

ldconfig通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。

检测某个函数是否存在于一个动态库中

nm xxx.so | grep "funcname"

protobuf多版本问题

PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^
.build_release/src/caffe/proto/caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.

The problem is that the installed headers on your system (in /usr/include/google/protobuf or /usr/local/include/google/protobuf) are from a newer version of Protocol Buffers than your protoc. It may be the case that you have both versions installed in different locations, and the wrong one is being used.

系统内的header file位于/usr/include/google/protobuf or /usr/local/include/google/protobuf
查看头文件版本
look at google/protobuf/stubs/common.h and look for the GOOGLE_PROTOBUF_VERSION macro around 100 lines in



  • 虚拟环境创建
    conda create --name env2.7 python=2.7

  • opencv安装
    conda install -c menpo opencv

  • 为jupyter-notebook创建conda虚拟环境的kernal
    https://blog.csdn.net/u014665013/article/details/81084604
    • conda install ipykernel
    • conda activate env3.6
    • (env3.6)python -m ipykernel install --user --name env3.6 --display-name "env3.6"
  • 强制重新安装某个包
    https://stackoverflow.com/questions/19548957/can-i-force-pip-to-reinstall-the-current-version
    pip install --upgrade --force-reinstall numpy

循环执行某个命令

watch -n 5 ls backup_commonobj/

根据名字杀掉某个进程

ps aux | grep -ie 进程名字 | awk '{print $2}' | xargs kill -9

你可能感兴趣的:(linux命令杂记)