Skip to content

Instantly share code, notes, and snippets.

@jvmvik
Last active May 11, 2021 18:48
Show Gist options
  • Select an option

  • Save jvmvik/a17fea79ad087b1b8069c6efeb41e2b9 to your computer and use it in GitHub Desktop.

Select an option

Save jvmvik/a17fea79ad087b1b8069c6efeb41e2b9 to your computer and use it in GitHub Desktop.
Linux cool command tricks

Linux Trick

List files and md5 associated

md5sum * */* 2>/dev/null > md5sum.md5

Remove log files passed

grep -lr "PASSED" $WORK_DIR/*/logs/*log | xargs rm

Inline ruby execution with standard library inclusion

ruby -rfileutils -e "Dir.glob('**/*~').each { |path| FileUtils.rm(path) }"

Diff recursive with ignore line

diff -r -I "^\s+#" -I "^\s+\/\/" root1/ root2

List file type present in a directory

find . | xargs file > /tmp/filetype.txt
cat /tmp/filetype.txt | cut -d':' -f2 | tr -d "[:blank:]" | sort -u

System monitoring

Show temperature, fan cpu etc...

# install
 sudo apt-get install lm-sensors
 # setup
 sudo sensors-detect
 # show sensors state
 sensors

source: https://www.ostechnix.com/view-cpu-temperature-linux/

Analyze process utilization with csysdig

This tool enables to dig into CPU, Memory, Thread, File descriptor and more. The drawback is that you to patch the linux kernel and add low level module during installation. link: https://sysdig.com/opensource/

csysdig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment