{"id":222,"date":"2016-01-08T01:21:25","date_gmt":"2016-01-07T19:51:25","guid":{"rendered":"http:\/\/www.middlewareprimer.com\/blog\/?p=222"},"modified":"2016-01-08T01:21:25","modified_gmt":"2016-01-07T19:51:25","slug":"linux-basic-commands","status":"publish","type":"post","link":"http:\/\/www.middlewareprimer.com\/blog\/2016\/01\/08\/linux-basic-commands\/","title":{"rendered":"Linux basic commands"},"content":{"rendered":"<p>Linux basic commands :<\/p>\n<p>$ who am I\u00a0\u00a0 &#8211;&gt;To see from which user you have logged in<\/p>\n<p>$ who\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;To see all who is logged in yet this point of time from which IP<\/p>\n<p>$ w\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;More details about user related info<\/p>\n<p>$ date \u00a0\u00a0\u00a0 &#8211;&gt; To display the date of the system<\/p>\n<p>$ cal\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To display the current month calendar<\/p>\n<p>$ time\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Calculate response time of the activity \/ command<\/p>\n<p>$ hwclock\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To see detailed date and time with time zone<\/p>\n<p>$ ls -l\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; List files,directories with properties<\/p>\n<p>$ ls\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; List files and directories<\/p>\n<p>$ ls \u2013a\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; List all hidden files and directories<\/p>\n<p>$ ls \u2013d\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To list only directories<\/p>\n<p>$ pwd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Print working directory<\/p>\n<p>$ cd &lt;Path of the directory&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Change directory<\/p>\n<p>$ clear\u00a0 \u00a0 &#8211;&gt; To clear the screen<\/p>\n<p>$ uptime\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;To see the server up time, boot time, users and load<\/p>\n<p>$ uname \u2013a\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To verify Operating system version, kernel version and architecture<\/p>\n<p>$ touch &lt;File Name&gt;\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;Create an empty file \/ Multiple empty files yet a time<\/p>\n<p>$ touch \u2013am\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; It will change a file time to current time<\/p>\n<p>$ touch \u2013r file1 \u2013B 30 file2\u00a0 &#8211;&gt;it will create two files with 30 seconds time difference<\/p>\n<p>$ cat \/dev\/null &gt; file\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;To empty the data file<\/p>\n<p>$ cat &gt; &lt;File Name&gt; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;Create an single file with text<\/p>\n<p>$ rm \u2013rf &lt;File \/ Directory Name&gt;\u00a0 &#8211;&gt; Delete files\/directories forcefully<\/p>\n<p>$rmdir &lt;directory&gt;\u00a0\u00a0\u00a0 &#8211;&gt;Delete directories only<\/p>\n<p>$ mkdir &lt;Directory Name&gt;\u00a0\u00a0 &#8211;&gt;Create an empty directory \/ directories<\/p>\n<p>$ mkdir \u2013p &lt;directory\/directory\/directory&gt;\u00a0 &#8211;&gt;To create parent directories<\/p>\n<p>$ cat &lt;File Name&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; View content of file<\/p>\n<p>$ cp &lt;Source path&gt; &lt;Destination path&gt;\u00a0\u00a0 &#8211;&gt; Copy the files from one path to another path<\/p>\n<p>$ cp \u2013Rv &lt;source&gt; &lt;destination&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; copy directories from source to destination<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Options:<\/strong><\/span><\/p>\n<p>-R, -r,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #copy directories recursively<\/p>\n<p>-v\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #verbose to see progress of copy job<\/p>\n<p>-p\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #preserve<\/p>\n<p>-f\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #forcefully<\/p>\n<p>-I\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #interactive: Ask before overwriting file<\/p>\n<p>$ mv &lt;source&gt; &lt;destination&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Move files\/directories<\/p>\n<p>$ mv &lt;old name&gt; &lt;new name&gt;\u00a0\u00a0\u00a0 &#8211;&gt; Rename the file and directory<\/p>\n<p>$ last\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Check who logged in and when logged in duration<\/p>\n<p>$ arch\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To know architecture<\/p>\n<p>$ reboot \/ init 6\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Restart server<\/p>\n<p>$ poweroff \/ init 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To shut down the server<\/p>\n<p>$ dmesg\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Check boot process logs<\/p>\n<p>$ nsloookup &lt;Server Address&gt;\u00a0\u00a0\u00a0 &#8211;&gt; check dns resolution<\/p>\n<p>$ dig &lt;server address&gt; \u00a0\u00a0\u00a0\u00a0 &#8211;&gt; check dns resolution to debug<\/p>\n<p>$ tree &lt;directory&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; It will show the tree of parent directory<\/p>\n<p>$ stat &lt;file name&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; detailed information about file<\/p>\n<p>$ wc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; word count, character count and line count<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Options:<\/strong><\/span><\/p>\n<p>-l \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Check line count<\/p>\n<p>-c\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Character Count<\/p>\n<p>-w\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #Word Count<\/p>\n<p><strong><u>Help relate commands:<\/u><\/strong><\/p>\n<p>$ whatis &lt;Command Name&gt;\u00a0 &#8211;&gt; It will display single line description about command<\/p>\n<p>$ whereis &lt;Command Name&gt;\u00a0 &#8211;&gt; It will provide you path of the command<\/p>\n<p>$ man &lt;command&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; manual page of the command<\/p>\n<p>$ info &lt;command&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Information about the command<\/p>\n<p>$ &lt;command&gt; &#8211;help\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; It will gives a command options and there usage<\/p>\n<p>$ apropos &lt;keyword&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; To know about the command use<\/p>\n<p>&nbsp;<\/p>\n<p><strong>NOTE:<\/strong> All commands must be small case letters<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux basic commands : $ who am I\u00a0\u00a0 &#8211;&gt;To see from which user you have logged in $ who\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;To see all who is logged in yet this point of time from which IP $ w\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt;More details about user related info $ date \u00a0\u00a0\u00a0 &#8211;&gt; To display the date of the system $ cal\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux"],"_links":{"self":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/comments?post=222"}],"version-history":[{"count":6,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":228,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/222\/revisions\/228"}],"wp:attachment":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}