{"id":955,"date":"2012-04-18T23:51:25","date_gmt":"2012-04-19T03:51:25","guid":{"rendered":"http:\/\/www.eyoungwon.com\/journal\/?p=955"},"modified":"2012-04-18T23:51:25","modified_gmt":"2012-04-19T03:51:25","slug":"common-unixlinux-commands","status":"publish","type":"post","link":"https:\/\/eyoungwon.com\/journal\/common-unixlinux-commands\/","title":{"rendered":"Common Unix\/Linux Commands"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Common Unix\/Linux Commands<\/strong><\/p>\n<p>System Information<br \/>\n<strong>who<\/strong><br \/>\nList the users logged in on the machine. &#8212;<\/p>\n<p><strong>rwho -a<\/strong><br \/>\nList all users logged in on your network. The rwho service must be enabled for this command to work.<\/p>\n<p><strong>finger user_name<\/strong><br \/>\nSystem info about a user. Try: finger root last. This lists the users last logged-in on your system.<\/p>\n<p><strong>history | more<\/strong><br \/>\nShow the last (1000 or so) commands executed from the command line on the current account. The | more causes the display to stop after each screen fill.<\/p>\n<p><strong>pwd<\/strong><br \/>\nPrint working directory, i.e. display the name of your current directory on the screen.<\/p>\n<p><strong>hostname<\/strong><br \/>\nPrint the name of the local host (the machine on which you are working).<\/p>\n<p><strong>whoami<\/strong><br \/>\nPrint your login name.<\/p>\n<p><strong>id username<\/strong><br \/>\nPrint user id (uid) and his\/her group id (gid), effective id (if different than the real id) and the supplementary groups.<\/p>\n<p><strong>date<\/strong><br \/>\nPrint or change the operating system date and time. E.g., change the date and time to 2000-12-31 23:57 using this command<\/p>\n<p><strong>date 12<a>3123572000<\/a><\/strong><br \/>\nTo set the hardware clock from the system clock, use the command (as root)<br \/>\nsetclock<\/p>\n<p><strong>time<\/strong><br \/>\nDetermine the amount of time that it takes for a process to complete+ other info. Don\u2019t confuse it with date command. For e.g. we can find out how long it takes to display a directory content using time ls<\/p>\n<p><strong>uptime<\/strong><br \/>\nAmount of time since the last reboot<\/p>\n<p><strong>ps<\/strong><br \/>\nList the processes that are have been run by the current user.<\/p>\n<p><strong>ps aux | more<\/strong><br \/>\nList all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.<\/p>\n<p><strong>top<\/strong><br \/>\nKeep listing the currently running processes, sorted by cpu usage (top users first).<\/p>\n<p><strong>uname -a<\/strong><br \/>\nInfo on your server.<\/p>\n<p><strong>free<\/strong><br \/>\nMemory info (in kilobytes).<\/p>\n<p><strong>df -h<\/strong><br \/>\nPrint disk info about all the file systems in a human-readable form.<\/p>\n<p><strong>du \/ -bh | more<\/strong><br \/>\nPrint detailed disk usage for each subdirectory starting at root (in a human readable form).<\/p>\n<p><strong>lsmod<\/strong><br \/>\n(as root. Use \/sbin\/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.<\/p>\n<p><strong>set|more<\/strong><br \/>\nShow the current user environment.<\/p>\n<p><strong>echo $PATH<\/strong><br \/>\nShow the content of the environment variable PATH. This command can be used to show other environment variables as well. Use set to see the full environment.<\/p>\n<p><strong>dmesg | less<\/strong><br \/>\nPrint kernel messages (the current content of the so-called kernel ring buffer). Press q to quit less. Use less \/var\/log\/dmesg to see what dmesg dumped into the file right after bootup. &#8211; only works on dedciated systems<\/p>\n<h1 style=\"text-align: center;\">\n<strong>Commands for Process control<\/strong><\/h1>\n<p><strong> ps<\/strong><br \/>\nDisplay the list of currently running processes with their process IDs (PID) numbers. Use ps aux to see all processes currently running on your system (also those of other users or without a controlling terminal),<br \/>\neach with the name of the owner. Use top to keep listing the processes currently running.<\/p>\n<p><strong>fg<\/strong><br \/>\nPID Bring a background or stopped process to the foreground.<\/p>\n<p><strong>bg<\/strong><br \/>\nPID Send the process to the background. This is the opposite of fg. The same can be accomplished with Ctrl z<\/p>\n<p><strong>any_command &amp;<\/strong><br \/>\nRun any command in the background (the symbol \u2018&amp;\u2019 means run the command in the background?).<\/p>\n<p><strong>kill PID<\/strong><br \/>\nForce a process shutdown. First determine the PID of the process to kill using ps.<\/p>\n<p><strong>killall<\/strong> -9 program_name<br \/>\nKill program(s) by name.<\/p>\n<p><strong>xkill<\/strong><br \/>\n(in an xwindow terminal) Kill a GUI-based program with mouse. (Point with your mouse cursor at the window of the process you want to kill and click.)<\/p>\n<p><strong>lpc<\/strong><br \/>\n(as root) Check and control the printer(s). Type ??? to see the list of available commands.<\/p>\n<p><strong>lpq<\/strong><br \/>\nShow the content of the printer queue.<\/p>\n<p><strong>lprm job_number<\/strong><br \/>\nRemove a printing job job_number from the queue.<\/p>\n<p><strong>nice program_name<\/strong><br \/>\nRun program_name adjusting its priority. Since the priority is not specified in this example, it will be adjusted by 10 (the process will run slower), from the default value (usually 0). The lower the number (of niceness to other users on the system), the higher the priority. The priority value may be in the range -20 to 19. Only root may specify negative values. Use top to display the priorities of the running processes.<\/p>\n<p><strong>renice -1 PID<\/strong><br \/>\n(as root) Change the priority of a running process to -1. Normal users can only adjust processes they own, and only up from the current value (make them run slower).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Command Line Commands on a Unix\/Linux System, VPS&#8217;s too<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114],"tags":[393,810],"class_list":["post-955","post","type-post","status-publish","format-standard","hentry","category-linuxunix","tag-common-unixlinux-commands","tag-vps"],"_links":{"self":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/comments?post=955"}],"version-history":[{"count":2,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/955\/revisions"}],"predecessor-version":[{"id":957,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/posts\/955\/revisions\/957"}],"wp:attachment":[{"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/media?parent=955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/categories?post=955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eyoungwon.com\/journal\/wp-json\/wp\/v2\/tags?post=955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}