Linux commands: Difference between revisions

Jump to navigation Jump to search
m
Line 159: Line 159:


== system operation ==
== system operation ==
show current time<ref>[https://en.wikipedia.org/wiki/DATE_(command) DATE (command) - Wikipedia, the free encyclopedia]</ref>
=== show current time ===
* {{kbd | key= date}} ({{Linux}}) output: Thu Oct 25 15:05:10 CST 2012 <ref>[http://linux.vbird.org/linux_server/0440ntp.php 鳥哥的 Linux 私房菜 -- NTP 時間伺服器]</ref>
* {{kbd | key= date}} ({{Linux}}) output: Thu Oct 25 15:05:10 CST 2012 <ref>[http://linux.vbird.org/linux_server/0440ntp.php 鳥哥的 Linux 私房菜 -- NTP 時間伺服器]</ref><ref>[https://en.wikipedia.org/wiki/DATE_(command) DATE (command) - Wikipedia, the free encyclopedia]</ref>
* {{kbd | key= date/t}} ({{Win}}) (parameter: /t will not ask you to change the current date)
* {{kbd | key= date/t}} ({{Win}}) (parameter: /t will not ask you to change the current date)
<pre>output:
<pre>output:
Line 169: Line 169:
* related: [[PHP_and_MySQL_syntax#timestamp | timestamp in PHP and MySQL syntax]]
* related: [[PHP_and_MySQL_syntax#timestamp | timestamp in PHP and MySQL syntax]]


specify the location where Linux or MS-DOS looks when using a command
=== specify the location where Linux or MS-DOS looks when using a command ===
* {{kbd | key= echo $PATH}} ({{Linux}})<ref>[http://linux.vbird.org/linux_basic/0220filemanager.php#dir_path 鳥哥的 Linux 私房菜 -- 檔案與目錄管理 -- 關於執行檔路徑的變數: $PATH]</ref>
* {{kbd | key= echo $PATH}} ({{Linux}})<ref>[http://linux.vbird.org/linux_basic/0220filemanager.php#dir_path 鳥哥的 Linux 私房菜 -- 檔案與目錄管理 -- 關於執行檔路徑的變數: $PATH]</ref>
* {{kbd | key= echo %PATH%}} ({{Win}}) more on [[How to setup my system path]]
* {{kbd | key= echo %PATH%}} ({{Win}}) more on [[How to setup my system path]]


reboot the system/server
=== reboot the system/server ===
* {{kbd | key=reboot}} ({{Linux}})<ref>[http://linux.about.com/od/commands/l/blcmdl8_reboot.htm reboot - Linux Command - Unix Command]</ref>
* {{kbd | key=reboot}} ({{Linux}})<ref>[http://linux.about.com/od/commands/l/blcmdl8_reboot.htm reboot - Linux Command - Unix Command]</ref>
* {{kbd | key=shutdown -r}} ({{Win}})<ref>[http://blog.soft.idv.tw/?p=216 Windows原來也有內建好用的關機軟體(Shutdown.exe) | ㊣軟體玩家]</ref>
* {{kbd | key=shutdown -r}} ({{Win}})<ref>[http://blog.soft.idv.tw/?p=216 Windows原來也有內建好用的關機軟體(Shutdown.exe) | ㊣軟體玩家]</ref>


{{OS}} version
=== {{OS}} version ===
* {{kbd | key=lsb_release -a}} ({{Linux}})<ref>[http://blog.miniasp.com/post/2009/02/25/How-to-query-Linux-distribution-and-version-information.aspx The Will Will Web | 如何查詢 Linux 的種類與版本 ( Linux Standard Base )]</ref>
* {{kbd | key=lsb_release -a}} ({{Linux}})<ref>[http://blog.miniasp.com/post/2009/02/25/How-to-query-Linux-distribution-and-version-information.aspx The Will Will Web | 如何查詢 Linux 的種類與版本 ( Linux Standard Base )]</ref>
* {{kbd | key=ver}} ({{Win}})<ref>[http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.html Find windows OS version from command line]</ref>
* {{kbd | key=ver}} ({{Win}})<ref>[http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.html Find windows OS version from command line]</ref>




Show the process list & kill the process<ref>[http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html How do I Find Out Linux CPU Utilization? - nixCraft]</ref><ref>[http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/ Show All Running Processes in Linux]</ref>
=== Show the process list & kill the process ===
<ref>[http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html How do I Find Out Linux CPU Utilization? - nixCraft]</ref><ref>[http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/ Show All Running Processes in Linux]</ref>
# {{kbd | key=top }} "display Linux tasks" for {{Linux}} or {{kbd | key=<nowiki>top -a</nowiki> }} "Sort by memory usage" for {{Linux}}
# {{kbd | key=top }} "display Linux tasks" for {{Linux}} or {{kbd | key=<nowiki>top -a</nowiki> }} "Sort by memory usage" for {{Linux}}
# keyin {{kbd | key=q}} to leave the process list
# keyin {{kbd | key=q}} to leave the process list
Line 188: Line 189:




Search text of command output
=== Search matched text of command output ===
* {{kbd | key=''linux command'' <nowiki>|</nowiki> awk '/''string''/'}} ({{Linux}}) ex:  
* {{kbd | key=''linux command'' <nowiki>|</nowiki> awk '/''string''/'}} ({{Linux}}) ex:  
** keyin {{kbd | key=<nowiki>dpkg --get-selections | awk '/tar/'</nowiki>}} to search the installed package naming ''tar'' for Ubuntu.<ref>[http://www.linuxquestions.org/questions/linux-newbie-8/logical-operators-in-grep-775595/ logical operators in grep]</ref>
** keyin {{kbd | key=<nowiki>dpkg --get-selections | awk '/tar/'</nowiki>}} to search the installed package naming ''tar'' for Ubuntu.<ref>[http://www.linuxquestions.org/questions/linux-newbie-8/logical-operators-in-grep-775595/ logical operators in grep]</ref>
Line 196: Line 197:




Scan the disk
=== Scan the disk ===
* GUI: [http://support.microsoft.com/kb/156571/en-us How to Perform Scandisk in Windows] {{Win}}
* GUI: [http://support.microsoft.com/kb/156571/en-us How to Perform Scandisk in Windows] {{Win}}
* Command: {{kbd | key=shutdown -rF now}} Force fsck when rebooting a Linux server ({{Linux}})<ref>[http://www.limestonenetworks.com/support/kc/7/67/how_do_i_schedule_fsck_to_run_automatically.html Cloud Provider and Dedicated Server Hosting in Dallas, TX]</ref>
* Command: {{kbd | key=shutdown -rF now}} Force fsck when rebooting a Linux server ({{Linux}})<ref>[http://www.limestonenetworks.com/support/kc/7/67/how_do_i_schedule_fsck_to_run_automatically.html Cloud Provider and Dedicated Server Hosting in Dallas, TX]</ref>

Navigation menu