{"id":167,"date":"2017-05-01T02:27:11","date_gmt":"2017-05-01T02:27:11","guid":{"rendered":"http:\/\/blog.staginginstance.com\/?p=167"},"modified":"2018-04-30T22:11:18","modified_gmt":"2018-04-30T22:11:18","slug":"important-linux-ubuntu-commands","status":"publish","type":"post","link":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/","title":{"rendered":"Important Linux + ubuntu + centos commands"},"content":{"rendered":"<p>We daily come across in need of various Linux + ubuntu + centos commands while updating our server and it becomes hard to remember each and every command by tips. So i thought of adding all commands at one place.<\/p>\n<ol>\n<li>Linux version :\u00a0<strong><code>cat \/etc\/*elease<\/code><\/strong><\/li>\n<li>Check if linux is 32 Bit or 64 Bit :\u00a0<strong><code>cat \/etc\/*elease<\/code><\/strong><\/li>\n<li>Connect to mysql using command line :\u00a0<strong><code>mysql -u username -pPassword<code><\/code><\/code><\/strong><\/li>\n<li>Backup mysql table in a file on server:\u00a0<strong><code>mysql -u username\u00a0-p --database=your_dbname\u00a0--host=your_hostname --port=3306 --batch -e \"select * from table_name\" | sed 's\/\\t\/\",\"\/g;s\/^\/\"\/;s\/$\/\"\/;s\/\\n\/\/g' &gt;\u00a0your_backup_filename<\/code><\/strong><\/li>\n<li>Current disk usage: \u00a0<strong><code>df -h<\/code><\/strong><\/li>\n<li>Memory usage: <strong><code>free -m<\/code><\/strong><\/li>\n<li>Delete folder and files in it: \u00a0<strong><code>rm -rf folder-name<\/code><\/strong><\/li>\n<li>Check log activity:<strong><code> tail -f *path-to-log*. Eg: tail -f \/var\/log\/apache2\/error.log<\/code><\/strong><\/li>\n<li>Enable any module: <strong><code>sudo a2enmod *module-name*. Eg:\u00a0sudo a2enmod rewrite<code><\/code><\/code><\/strong><\/li>\n<li>Zip file: <strong><code>sudo zip -r file.zip folder\/<\/code><\/strong><\/li>\n<li>To list the largest directories from the current directory in human readable format:\u00a0<strong><code>du -sh * | sort -hr | head -n10<\/code><\/strong><\/li>\n<li>To Recursively list all files in a directory including files in symlink directories: <strong><code>find -follow<\/code><\/strong><\/li>\n<li>List all users in linux:\u00a0<strong><code>cat \/etc\/passwd<\/code><\/strong><\/li>\n<li>Add a linux user:\u00a0<strong class=\"userinput\"><code class=\"\"><span class=\"\">sudo<\/span> adduser <em class=\"replaceable\"><code>newuser<\/code><\/em><\/code><\/strong><\/li>\n<li>Delete a linux user:\u00a0<strong class=\"userinput\"><code class=\"\"><span class=\"\">sudo<\/span> userdel -r <em class=\"replaceable\"><code>olduser<\/code><\/em><\/code><\/strong><\/li>\n<li>Create Swap memory in linux:\n<ol>\n<li>Command 1<strong>:<\/strong> <strong><code>sudo dd if=\/dev\/zero of=\/swapfile bs=1G count=4<\/code><\/strong><\/li>\n<li>Command 2:\u00a0<strong><code>sudo chmod 600 \/swapfile<\/code><\/strong><\/li>\n<li>Command 3: <strong><code>sudo mkswap \/swapfile<\/code><\/strong><\/li>\n<\/ol>\n<\/li>\n<li>Unzip file:If the <code>unzip<\/code> command isn&#8217;t already installed on your system, then run:\n<ol>\n<li>Install unzip<strong>:\u00a0<code>sudo apt-get install unzip<\/code><\/strong><\/li>\n<li>After installing the unzip utility, if you want to extract to a particular destination folder, you can use<strong>:\u00a0<code>unzip file.zip -d destination_folder<\/code><\/strong><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>We daily come across in need of various Linux + ubuntu + centos commands while updating our server and it becomes hard to remember each and every command by tips. So i thought of adding all commands at one place. Linux version :\u00a0cat \/etc\/*elease Check if linux is 32 Bit or 64 Bit :\u00a0cat \/etc\/*elease&hellip; <a class=\"more-link\" href=\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\">Continue reading <span class=\"screen-reader-text\">Important Linux + ubuntu + centos commands<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[10,9,11],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Important Linux + ubuntu + centos commands - Learner at life<\/title>\n<meta name=\"description\" content=\"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Important Linux + ubuntu + centos commands - Learner at life\" \/>\n<meta property=\"og:description\" content=\"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips\" \/>\n<meta property=\"og:url\" content=\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"Learner at life\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/abhij89\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-01T02:27:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-30T22:11:18+00:00\" \/>\n<meta name=\"author\" content=\"Abhishek Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@abhij89\" \/>\n<meta name=\"twitter:site\" content=\"@abhij89\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\",\"url\":\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\",\"name\":\"Important Linux + ubuntu + centos commands - Learner at life\",\"isPartOf\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/#website\"},\"datePublished\":\"2017-05-01T02:27:11+00:00\",\"dateModified\":\"2018-04-30T22:11:18+00:00\",\"author\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e\"},\"description\":\"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips\",\"breadcrumb\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/geekabhi.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Important Linux + ubuntu + centos commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#website\",\"url\":\"https:\/\/geekabhi.com\/blog\/\",\"name\":\"Learner at life\",\"description\":\"Blog to help you learn stuff\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/geekabhi.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e\",\"name\":\"Abhishek Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g\",\"caption\":\"Abhishek Jain\"},\"description\":\"Techie with 10+ years of experience and counting.\",\"sameAs\":[\"http:\/\/www.geekabhi.com\",\"https:\/\/twitter.com\/abhij89\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Important Linux + ubuntu + centos commands - Learner at life","description":"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips","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:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/","og_locale":"en_US","og_type":"article","og_title":"Important Linux + ubuntu + centos commands - Learner at life","og_description":"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips","og_url":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/","og_site_name":"Learner at life","article_publisher":"http:\/\/abhij89","article_published_time":"2017-05-01T02:27:11+00:00","article_modified_time":"2018-04-30T22:11:18+00:00","author":"Abhishek Jain","twitter_card":"summary_large_image","twitter_creator":"@abhij89","twitter_site":"@abhij89","twitter_misc":{"Written by":"Abhishek Jain","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/","url":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/","name":"Important Linux + ubuntu + centos commands - Learner at life","isPartOf":{"@id":"https:\/\/geekabhi.com\/blog\/#website"},"datePublished":"2017-05-01T02:27:11+00:00","dateModified":"2018-04-30T22:11:18+00:00","author":{"@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e"},"description":"We daily come across in need of various Linux + ubuntu commands while updating our server and it becomes hard to remember each and every command by tips","breadcrumb":{"@id":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/geekabhi.com\/blog\/important-linux-ubuntu-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/geekabhi.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Important Linux + ubuntu + centos commands"}]},{"@type":"WebSite","@id":"https:\/\/geekabhi.com\/blog\/#website","url":"https:\/\/geekabhi.com\/blog\/","name":"Learner at life","description":"Blog to help you learn stuff","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/geekabhi.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e","name":"Abhishek Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g","caption":"Abhishek Jain"},"description":"Techie with 10+ years of experience and counting.","sameAs":["http:\/\/www.geekabhi.com","https:\/\/twitter.com\/abhij89"]}]}},"_links":{"self":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/167"}],"collection":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":17,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":229,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions\/229"}],"wp:attachment":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}