{"id":1,"date":"2017-01-18T17:09:44","date_gmt":"2017-01-18T17:09:44","guid":{"rendered":"http:\/\/107.155.120.56\/?p=1"},"modified":"2022-01-10T14:48:33","modified_gmt":"2022-01-10T14:48:33","slug":"ubuntu-useful-tips","status":"publish","type":"post","link":"https:\/\/simplecode.com.vn\/?p=1","title":{"rendered":"Ubuntu Useful Tips"},"content":{"rendered":"<p><b>1.\u00a0 Create alias<\/b><br \/>\nAdding alias line at the end of the file: ~\/.bashrc<\/p>\n<pre><code>alias [alias_name]='[something_you_want]'<\/code><\/pre>\n<p>Ex:<\/p>\n<pre><code>alias elasticsearch='~\/Downloads\/elasticsearch\/bin\/elasticsearch'<\/code><\/pre>\n<\/p>\n<p><b>2. Tmux control terminator&#8217;s sessions<\/b><br \/>\n<a href=\"https:\/\/gist.github.com\/MohamedAlaa\/2961058\" target=\"_blank\" rel=\"noopener\">https:\/\/gist.github.com\/MohamedAlaa\/2961058<\/a>\n<\/p>\n<p><b>3. Terminator cheat sheet<\/b><br \/>\n<a href=\"http:\/\/www.knuckleheadtech.com\/terminator-cheat-sheet\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.knuckleheadtech.com\/terminator-cheat-sheet\/<\/a>\n<\/p>\n<p><b>4.\u00a0 Check memory (RAM)<\/b><\/p>\n<pre><code>$ free -m<\/code><\/pre>\n<p># To monitor memory usage with updates every five seconds.<\/p>\n<pre><code>$ watch -n 5 free<\/code><\/pre>\n<\/p>\n<p><b>5.\u00a0 Check disk size<\/b><\/p>\n<pre><code>$ df -h<\/code><\/pre>\n<\/p>\n<p><b>6.\u00a0 Remove an none-empty directory<\/b><\/p>\n<pre><code>$ rm -rf mydirectory<\/code><\/pre>\n<\/p>\n<p><b>7.\u00a0 Remove sudo prompts password for current user<\/b><\/p>\n<pre><code>$ echo \"$USER ALL=(ALL:ALL) NOPASSWD: ALL\" | sudo env EDITOR=\"tee -a\" visudo<\/code><\/pre>\n<\/p>\n<p><b>8.\u00a0 Disable ipv6<\/b><br \/>\n+ Add these lines to \/etc\/sysctl.conf<\/p>\n<pre><code>\r\n#disable ipv6\r\nnet.ipv6.conf.all.disable_ipv6 = 1\r\nnet.ipv6.conf.default.disable_ipv6 = 1\r\nnet.ipv6.conf.lo.disable_ipv6 = 1\r\n<\/code><\/pre>\n<p>+ Apply sysctl.conf<\/p>\n<pre><code>$ sudo sysctl -p<\/code><\/pre>\n<\/p>\n<p><b>9.\u00a0 To create symlink<\/b> \/opt\/foo &#8211;&gt; \/usr\/bin\/bar, (i.e., create symlink at \/opt\/foo which references to file \/usr\/bin\/bar) do (See man ln):<\/p>\n<pre><code>$ ln -s \/usr\/bin\/bar \/opt\/foo<\/code><\/pre>\n<\/p>\n<p><b>10.\u00a0 To order to add additional keys to pre-existing droplets, you can paste in the keys using SSH:<\/b><\/p>\n<pre><code>$ cat ~\/.ssh\/id_rsa.pub | ssh root@[your.ip.address.here] \"cat &gt;&gt; ~\/.ssh\/authorized_keys\"<\/code><\/pre>\n<\/p>\n<p><b>11.\u00a0 To copy the files from the src location to des loacation:<\/b><\/p>\n<pre><code>$ sudo rsync -avP src_dir_path\/ des_dir_path\/<\/code><\/pre>\n<\/p>\n<p><b>12.\u00a0 To switch user postgres<\/b><\/p>\n<pre><code>$ sudo -i -u postgres<\/code><\/pre>\n<\/p>\n<p><b>13.\u00a0 To unfold a gzip file<\/b><\/p>\n<pre><code>$ tar xzvf latest.tar.gz<\/code><\/pre>\n<\/p>\n<p><b>14.\u00a0 To install a .deb file in the usual Ubuntu way with dpkg.<\/b><\/p>\n<pre><code>$ sudo dpkg -i your_file_here.deb<\/code><\/pre>\n<p>This results in your-package being installed in \/usr\/share\/your-package\/<\/p>\n<p>With its configuration files placed in \/etc\/your-package<\/p>\n<p>And its init script added in \/etc\/init.d\/your-package.<\/p>\n<\/p>\n<p><b>15. Check processes of a specific port example 9001<\/b><\/p>\n<pre><code>$ sudo lsof -i :9001<\/code><\/pre>\n<\/p>\n<p><b>16. Kill applications<\/b><\/p>\n<p><pre><code>$ kill pid_number<\/code><\/pre>\n<p>Example: kill application that has PID 1234.<\/p>\n<pre><code>$ kill 1234<\/code><\/pre>\n<\/p>\n<p><pre><code>$ kill -9 pid_number<\/code><\/pre>\n<p>Example: kill application that has PID 1234 but more extreme and forceful.<\/p>\n<pre><code>$ kill -9 1234<\/code><\/pre>\n<\/p>\n<p><pre><code>$ killall application_name<\/code><\/pre>\n<p>Example: kill application or application instance that has name firefox.<\/p>\n<pre><code>$ killall firefox<\/code><\/pre>\n<\/p>\n<p><b>17. Copy a file from remote server<\/b><\/p>\n<pre><code>scp username@source:\/location\/to\/file \/where\/to\/put<\/code><\/pre>\n<p>General syntax of <code> scp <\/code> :<\/p>\n<pre><code>scp username@source:\/location\/to\/file username@destination:\/where\/to\/put<\/code><\/pre>\n<p>See more: <code> man scp <\/code> .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u00a0 Create alias Adding alias line at the end of the file: ~\/.bashrc alias [alias_name]='[something_you_want]&#8217; Ex: alias elasticsearch=&#8217;~\/Downloads\/elasticsearch\/bin\/elasticsearch&#8217; 2. Tmux control terminator&#8217;s sessions https:\/\/gist.github.com\/MohamedAlaa\/2961058 3. Terminator cheat sheet http:\/\/www.knuckleheadtech.com\/terminator-cheat-sheet\/ 4.\u00a0 Check memory (RAM) $ free -m # To monitor memory usage with updates every five seconds. $ watch -n 5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[5],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ubuntu Useful Tips - SimpleCode<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/simplecode.com.vn\/?p=1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ubuntu Useful Tips - SimpleCode\" \/>\n<meta property=\"og:description\" content=\"1.\u00a0 Create alias Adding alias line at the end of the file: ~\/.bashrc alias [alias_name]=&#039;[something_you_want]&#039; Ex: alias elasticsearch=&#039;~\/Downloads\/elasticsearch\/bin\/elasticsearch&#039; 2. Tmux control terminator&#8217;s sessions https:\/\/gist.github.com\/MohamedAlaa\/2961058 3. Terminator cheat sheet http:\/\/www.knuckleheadtech.com\/terminator-cheat-sheet\/ 4.\u00a0 Check memory (RAM) $ free -m # To monitor memory usage with updates every five seconds. $ watch -n 5 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/simplecode.com.vn\/?p=1\" \/>\n<meta property=\"og:site_name\" content=\"SimpleCode\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-18T17:09:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-10T14:48:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"simplecode\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/simplecode.com.vn\/#website\",\"url\":\"https:\/\/simplecode.com.vn\/\",\"name\":\"SimpleCode\",\"description\":\"Simple Code\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/simplecode.com.vn\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/simplecode.com.vn\/?p=1#webpage\",\"url\":\"https:\/\/simplecode.com.vn\/?p=1\",\"name\":\"Ubuntu Useful Tips - SimpleCode\",\"isPartOf\":{\"@id\":\"https:\/\/simplecode.com.vn\/#website\"},\"datePublished\":\"2017-01-18T17:09:44+00:00\",\"dateModified\":\"2022-01-10T14:48:33+00:00\",\"author\":{\"@id\":\"https:\/\/simplecode.com.vn\/#\/schema\/person\/b110785905231d29553717dd14b766dc\"},\"breadcrumb\":{\"@id\":\"https:\/\/simplecode.com.vn\/?p=1#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/simplecode.com.vn\/?p=1\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/simplecode.com.vn\/?p=1#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/simplecode.com.vn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ubuntu Useful Tips\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/simplecode.com.vn\/#\/schema\/person\/b110785905231d29553717dd14b766dc\",\"name\":\"simplecode\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/simplecode.com.vn\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/22e0b2cc28939e5aecc166195d629442?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/22e0b2cc28939e5aecc166195d629442?s=96&d=mm&r=g\",\"caption\":\"simplecode\"},\"url\":\"https:\/\/simplecode.com.vn\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ubuntu Useful Tips - SimpleCode","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/simplecode.com.vn\/?p=1","og_locale":"en_US","og_type":"article","og_title":"Ubuntu Useful Tips - SimpleCode","og_description":"1.\u00a0 Create alias Adding alias line at the end of the file: ~\/.bashrc alias [alias_name]='[something_you_want]' Ex: alias elasticsearch='~\/Downloads\/elasticsearch\/bin\/elasticsearch' 2. Tmux control terminator&#8217;s sessions https:\/\/gist.github.com\/MohamedAlaa\/2961058 3. Terminator cheat sheet http:\/\/www.knuckleheadtech.com\/terminator-cheat-sheet\/ 4.\u00a0 Check memory (RAM) $ free -m # To monitor memory usage with updates every five seconds. $ watch -n 5 [&hellip;]","og_url":"https:\/\/simplecode.com.vn\/?p=1","og_site_name":"SimpleCode","article_published_time":"2017-01-18T17:09:44+00:00","article_modified_time":"2022-01-10T14:48:33+00:00","twitter_card":"summary","twitter_misc":{"Written by":"simplecode","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/simplecode.com.vn\/#website","url":"https:\/\/simplecode.com.vn\/","name":"SimpleCode","description":"Simple Code","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simplecode.com.vn\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/simplecode.com.vn\/?p=1#webpage","url":"https:\/\/simplecode.com.vn\/?p=1","name":"Ubuntu Useful Tips - SimpleCode","isPartOf":{"@id":"https:\/\/simplecode.com.vn\/#website"},"datePublished":"2017-01-18T17:09:44+00:00","dateModified":"2022-01-10T14:48:33+00:00","author":{"@id":"https:\/\/simplecode.com.vn\/#\/schema\/person\/b110785905231d29553717dd14b766dc"},"breadcrumb":{"@id":"https:\/\/simplecode.com.vn\/?p=1#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simplecode.com.vn\/?p=1"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/simplecode.com.vn\/?p=1#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simplecode.com.vn\/"},{"@type":"ListItem","position":2,"name":"Ubuntu Useful Tips"}]},{"@type":"Person","@id":"https:\/\/simplecode.com.vn\/#\/schema\/person\/b110785905231d29553717dd14b766dc","name":"simplecode","image":{"@type":"ImageObject","@id":"https:\/\/simplecode.com.vn\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/22e0b2cc28939e5aecc166195d629442?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/22e0b2cc28939e5aecc166195d629442?s=96&d=mm&r=g","caption":"simplecode"},"url":"https:\/\/simplecode.com.vn\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1"}],"collection":[{"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1"}],"version-history":[{"count":24,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":268,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions\/268"}],"wp:attachment":[{"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simplecode.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}