{"id":247,"date":"2020-07-09T19:39:48","date_gmt":"2020-07-09T19:39:48","guid":{"rendered":"http:\/\/sumitjangid.com\/?p=247"},"modified":"2020-07-09T19:45:32","modified_gmt":"2020-07-09T19:45:32","slug":"linux-unix-commands","status":"publish","type":"post","link":"http:\/\/sumitjangid.com\/index.php\/2020\/07\/09\/linux-unix-commands\/","title":{"rendered":"Linux\/Unix commands"},"content":{"rendered":"\n<p>File Commands<\/p>\n\n\n\n<ol><li>ls Directory listing <\/li><li>ls -al Formatted listing with hidden files <\/li><li>ls  -lt Sorting the Formatted listing by time modification <\/li><li>cd dir Change directory to dir <\/li><li>cd Change to home directory <\/li><li>pwd Show current working directory <\/li><li>mkdir dir Creating a directory dir <\/li><li>cat &gt;file Places the standard input into the file <\/li><li>more file Output the contents of the file <\/li><li>head file Output the first 10 lines of the file <\/li><li>tail file Output the last 10 lines of the file <\/li><li>tail -f file Output the contents of file as it grows,starting with the last 10 lines <\/li><li>touch file Create or update file <\/li><li>rm file Deleting the file <\/li><li>rm -r dir Deleting the directory <\/li><li>rm -f file Force to remove the file <\/li><li>rm -rf dir Force to remove the directory dir <\/li><li>cp file1 file2 Copy the contents of file1 to file2 <\/li><li>cp -r dir1 dir2 Copy dir1 to dir2;create dir2 if not present <\/li><li>mv file1 file2 Rename or move file1 to file2,if file2 is an existing directory <\/li><li>ln -s file link Create symbolic link link to file<\/li><\/ol>\n\n\n\n<p>Process management <\/p>\n\n\n\n<ol><li>ps To display the currently working processes <\/li><li>top Display all running process<br>\nUnix\/Linux&nbsp;Command&nbsp;Reference&nbsp;<\/li><li>kill pid Kill the process with given pid <\/li><li>killall proc Kill all the process named proc <\/li><li>pkill pattern Will kill all processes matching the pattern <\/li><li>bg List stopped or background jobs,resume a stopped job in the background <\/li><li>fg Brings the most recent job to foreground <\/li><li>fg n Brings job n to the foreground<\/li><\/ol>\n\n\n\n<p>File permission <\/p>\n\n\n\n<ol><li>chmod octal file Change the permission of file to octal,which can be found separately for user,group,world by adding, \u2022 4-read(r) \u2022 2-write(w) \u2022 1-execute(x)<br>\nSearching 1. grep pattern file Search for  pattern in file <\/li><li>grep -r pattern dir Search recursively for pattern in dir <\/li><li>command | grep pattern Search pattern in the output of a command <\/li><li>locate file Find all instances of file <\/li><li>find . -name filename Searches in the current directory (represented by a period) and below it, for files and directories with names starting with filename 6. pgrep pattern Searches for all the named processes , that matches with the pattern and, by default, returns their ID<\/li><\/ol>\n\n\n\n<p>System Info <\/p>\n\n\n\n<ol><li>date Show the current date and time <\/li><li>cal Show this month&#8217;s calender <\/li><li>uptime Show current uptime <\/li><li>w Display who is on line <\/li><li>whoami Who you are logged in as Unix\/Linux&nbsp;Command&nbsp;Reference&nbsp;<\/li><li>finger user Display information about user <\/li><li>uname -a Show kernel information <\/li><li>cat \/proc\/cpuinfo Cpu information <\/li><li>cat proc\/meminfo Memory information <\/li><li>man command Show the manual for command <\/li><li>df Show the disk usage <\/li><li>du Show directory space usage <\/li><li>free Show memory and swap usage <\/li><li>whereis app Show possible locations of app <\/li><li>which app Show which applications will be run by default<\/li><\/ol>\n\n\n\n<p>Compression <\/p>\n\n\n\n<ol><li>tar cf file.tar file Create tar named file.tar containing file <\/li><li>tar xf file.tar Extract the files from file.tar <\/li><li>tar czf file.tar.gz files Create a tar with Gzip compression <\/li><li>tar xzf file.tar.gz Extract a tar using Gzip <\/li><li>tar cjf file.tar.bz2 Create tar with Bzip2 compression <\/li><li>tar xjf file.tar.bz2 Extract a tar using Bzip2 <\/li><li>gzip file Compresses file and renames it to file.gz <\/li><li>gzip -d file.gz Decompresses file.gz back to file<\/li><\/ol>\n\n\n\n<p>Network <\/p>\n\n\n\n<ol><li>ping host Ping host and output results <\/li><li>whois domain Get whois information for domains <\/li><li>dig domain Get DNS information for domain <\/li><li>dig -x host Reverse lookup host <\/li><li>wget file Download file <\/li><li>wget -c file Continue a stopped download<\/li><\/ol>\n\n\n\n<p>Shortcuts <\/p>\n\n\n\n<ol><li>ctrl+c Halts the current command <\/li><li>ctrl+z Stops the current command, resume with fg in the foreground or bg in the background <\/li><li>ctrl+d Logout the current session, similar to exit <\/li><li>ctrl+w Erases one word in the current line <\/li><li>ctrl+u Erases the whole line <\/li><li>ctrl+r Type to bring up a recent command <\/li><li>!! Repeats the last command <\/li><li>exit Logout the current session<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>File Commands ls Directory listing ls -al Formatted listing with hidden files ls -lt Sorting the Formatted listing by time modification cd dir Change directory to dir cd Change to home directory pwd Show current&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,1],"tags":[],"_links":{"self":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/247"}],"collection":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/comments?post=247"}],"version-history":[{"count":2,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/247\/revisions"}],"predecessor-version":[{"id":250,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/posts\/247\/revisions\/250"}],"wp:attachment":[{"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/media?parent=247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/categories?post=247"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sumitjangid.com\/index.php\/wp-json\/wp\/v2\/tags?post=247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}