{"id":2375,"date":"2015-05-07T10:24:00","date_gmt":"2015-05-07T07:24:00","guid":{"rendered":"http:\/\/dima.fi\/blog\/?p=2375"},"modified":"2020-03-05T23:28:09","modified_gmt":"2020-03-05T21:28:09","slug":"linux-cheat-sheet","status":"publish","type":"post","link":"https:\/\/dima.fi\/blog\/linux-cheat-sheet\/","title":{"rendered":"My linux cheat sheet"},"content":{"rendered":"\n<p>Search files containing string<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">grep -rnw .\/ -e \"string\"<\/code><\/pre>\n\n\n\n<p>Totally override destination with source<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">rsync -avh --delete (--dry-run) \/path\/to\/source\/ \/path\/to\/destination\/<\/code><\/pre>\n\n\n\n<p>Find services that uses specific file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">#Quick way, process id list\nfuser \/path\/to\/file\n\n#Versatile way, more info list\nlsof \/path\/to\/file<\/code><\/pre>\n\n\n\n<p>What files does specific process id uses<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">lsof -p 12345 <\/code><\/pre>\n\n\n\n<p>What files does process name(s) use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">lsof -c apache2 -c mysqld<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Random linux CLI codes I use occasionally and never remember them.<\/p>\n","protected":false},"author":1,"featured_media":2433,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[133],"tags":[151,139,159,152,160],"class_list":["post-2375","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-devs","tag-cheat-sheet","tag-dev","tag-grep","tag-linux","tag-rsync","has-thumbnail"],"_links":{"self":[{"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/posts\/2375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/comments?post=2375"}],"version-history":[{"count":3,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/posts\/2375\/revisions"}],"predecessor-version":[{"id":2383,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/posts\/2375\/revisions\/2383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/media\/2433"}],"wp:attachment":[{"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/media?parent=2375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/categories?post=2375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dima.fi\/blog\/wp-json\/wp\/v2\/tags?post=2375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}