{"id":224,"date":"2024-08-13T02:42:16","date_gmt":"2024-08-13T01:42:16","guid":{"rendered":"https:\/\/unchaincode.com\/?page_id=224"},"modified":"2024-08-13T20:46:35","modified_gmt":"2024-08-13T19:46:35","slug":"linux-cheat-sheet","status":"publish","type":"page","link":"https:\/\/unchaincode.com\/index.php\/linux-cheat-sheet\/","title":{"rendered":"Linux Cheat Sheet"},"content":{"rendered":"\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-af949038bdff5766e61740d1e9973a12\"><strong>which<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-cd1a95ed569424c03268e70a523aaa90\" style=\"color:#5ee543\">which &lt;command&gt;<br><br>Describes the location of an application in the computer\u2019s file system. If an application is not installed on the computer<br>and its parent directory is not part of the system\u2019s $PATH, which will report an error.<br><br>Example:<br>$ which clear<br>\/usr\/bin\/clear<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-7551a9ffe6fc6713907222dc62848407\"><strong>cat<\/strong> &#8211; Concatenate and Display Files<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-93adf201e0237981c78c580f99530b91\" style=\"color:#5ee543\">cat &lt;path\/to\/filename&gt;<br><br>Displays the contents of &lt;path\/to\/filename&gt; to standard out. &lt;path\/to\/filename&gt;<br><br>Example:<br>$ cat \/root\/text.txt<br>Unchain Code is awesome!<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-1c2cd57e37797332b77ddeded199ddfc\"><strong>cd<\/strong> &#8211; Change Directory<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-7e05bad6ded772a24d7983e79f5c8d84\" style=\"color:#5ee543\">Change to another current directory.<br><br>Example:<br>$ cd \/home\/username\/Documents<br><br>cd .. : Moves up one directory level.<br>cd ~ : Moves to the home directory.<br>cd \/ : Moves to the root directory.<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-58b39b2d2ae80806d967b1e380f6df2d\"><strong>pwd<\/strong> &#8211; Print Working Directory<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-9ebb9fa5e68f380fc649ae5825a8abbe\" style=\"color:#5ee543\">Displays the full path of the current working directory.<br><br>Example:<br>$ pwd<br>\/home\/username<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-25d13cb9e74392adfd36324939aa5f8f\"><strong>ls<\/strong> &#8211; List Directory Contents<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-32ca11fc96857d14ce42e50995ff8471\" style=\"color:#5ee543\">Lists files and directories in the current directory.<br><br>Example:<br>$ ls<br>Documents  Downloads  Music  Pictures  Videos<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-befd6e9e35e0327221ab52f489d57292\"><strong>touch<\/strong> &#8211; Create an Empty File<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-e6d7b714c33271d0ec070dec86aad8ae\" style=\"color:#5ee543\">Creates an empty file or updates the timestamp of an existing file.<br><br>Example:<br>$ touch myfile.txt<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-152ac0dadec9c6d596f8b7267f8b41a9\"><strong>mkdir<\/strong> &#8211; Make Directory<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-c1b2fffc7f9fc03e7cdc97351126c13a\" style=\"color:#5ee543\">Creates a new directory.<br><br>Example:<br>$ mkdir new_directory<br><br>Creates parent directories as needed.<br><br>Example:<br>$ mkdir -p projects\/2024\/linux_guide<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-45eae86f728e7c05a5528c0506d821fb\"><strong>rm<\/strong> &#8211; Remove Files or Directories<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-8edf7b4fb3ded7d3abe18d007efe908e\" style=\"color:#5ee543\">Deletes files or directories.<br><br>Example:<br>$ rm myfile.txt<br><br>rm -r directory_name : Recursively removes a directory and its contents.<br>rm -i : Asks for confirmation before each file deletion.<br>rm -rf directory_name : Forcefully removes a directory and its contents without asking for confirmation.<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-4dde05550a21d3623b7f264e93b3a9f5\"><strong>cp<\/strong> &#8211; Copy Files or Directories<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-2e651135953ae7d6db7bef9ef59f3e3e\" style=\"color:#5ee543\">Copies files or directories from one location to another.<br><br>Example:<br>$ cp file1.txt \/home\/username\/Documents\/<br><br>Recursively copies a directory and its contents.<br>$ cp -r \/home\/username\/Documents \/home\/username\/Backup\/<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-2c3d7e6073b7e162f5352e3f24d8d479\"><strong> mv<\/strong> &#8211; Move or Rename Files or Directories<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-c6ecafbbe128741dc8bff9cacefcb59d\" style=\"color:#5ee543\">Moves or renames files or directories.<br><br>Example:<br>$ mv file1.txt file2.txt : This renames file1.txt to file2.txt.<br><br>$ mv file1.txt \/home\/username\/Documents\/<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-b45656519818fc7a24adeb2b72c6d100\"><strong>chmod<\/strong> &#8211; Change File Permissions<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-c9cf4bb5eb0a1830ecd517f822b180da\" style=\"color:#5ee543\">Changes the permissions of a file or directory.<br><br>Example:<br>$ chmod 755 script.sh<br><br>7 (rwx): Full permissions (read, write, execute).<br>5 (r-x): Read and execute permissions.<br>0 (---): No permissions.<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-58a10555b6847477827a44c055cd3d20\"><strong>nano<\/strong> &#8211; Text Editor<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-74fcef041f0271b60b91805e4fe2c3b4\" style=\"color:#5ee543\">Opens the nano text editor to create or edit files.<br><br>Example:<br>$ nano myfile.txt<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-ad34594813df2c4e8502de7a82d87af0\"><strong>grep<\/strong> &#8211; Search Text in Files<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-cb429162d69cdaa4ffff81bb59529ade\" style=\"color:#5ee543\">Searches for a specific pattern or text in files.<br><br>Example:<br>$ grep \"search_term\" file.txt<br><br>$ grep -r \"search_term\" \/path\/to\/directory\/<\/pre>\n\n\n\n<p class=\"has-orange-color has-text-color has-link-color wp-elements-7c42f8ba57cdb876286d1123a62c574f\"><strong>man<\/strong> &#8211; Manual Pages<\/p>\n\n\n\n<pre class=\"wp-block-verse has-text-color has-link-color wp-elements-b209df74cc4bc5b87587f6f7e147f8e9\" style=\"color:#5ee543\">Displays the manual page for a command, which contains detailed information about how to use it.<br><br>Example: <br>$ man ls<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>which which &lt;command&gt;Describes the location of an application in the computer\u2019s file system. If an application is not installed on the computerand its parent directory<span class=\"more-button\"><a href=\"https:\/\/unchaincode.com\/index.php\/linux-cheat-sheet\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Linux Cheat Sheet<\/span><\/a><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-224","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/pages\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/comments?post=224"}],"version-history":[{"count":10,"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/pages\/224\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/pages\/224\/revisions\/248"}],"wp:attachment":[{"href":"https:\/\/unchaincode.com\/index.php\/wp-json\/wp\/v2\/media?parent=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}