List some useful Linux commands here.
Last active
September 5, 2023 03:52
-
-
Save Hansimov/cab44ae4bc3a6d3c9b5447d258fbbd07 to your computer and use it in GitHub Desktop.
Collection of useful Linux commands in daily work
List file structure by tree:
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
also contain files:
find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
Add alias to ~./.bashrc
:
alias lr=ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
# use `lr` instead of `lt` to avoid default settings `alias lt='ls -lt'`
alias lf=find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
References:
- Linux command to print directory structure in the form of a tree - Stack Overflow
nvidia-smi -q -x | grep pid | sed -e 's/<pid>//g' -e 's/<\/pid>//g' -e 's/^[[:space:]]*//'`
References:
- cuda - How do I customize nvidia-smi 's output to show PID username? - Stack Overflow
List process run on port 28888
:
lsof -i:28888
Kill a process run on port 28888
:
kill $(lsof -i:28888 | awk 'NR>1 {print $2}')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find text or string in all files:
-r
or-R
: recursive-n
: show line number-w
: match the whole word-l
(lower-case L): just show the file name of matching files-e
: pattern used during the searchExample:
References: