iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 29
1
自我挑戰組

30天學python系列 第 29

[Day29] Linux 作業系統 - 基礎命令

  • 分享至 

  • xImage
  •  

基礎命令

Linux 系統的命令通常都是如下所示的格式:

命令名稱[命名參數] [命令對象]

因為手邊沒有 linux 系統,所以我到線上使用這些命令,不過有些命令是無法呈現的,就直接貼範例。
1.獲取登錄信息 - w / who / last / lastb。

[root ~ ] # w
 23:31:16 up 12:16, 2 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 182.139.66.250 23:03 4.00s 0.02s 0.00sw
jackfrue pts/1 182.139.66.250 23:26 3:56 0.00s 0.00s -bash
[root ~ ] # who
root pts/0 2018-04-12 23:03 (182.139.66.250)
jackfrued pts/1 2018-04-12 23:26 (182.139.66.250)
[root ~ ] # who am i
root pts/0 2018-04-12 23:03 (182.139.66.250)
[root ~ ] # who mom likes
root pts/0 2018-04-12 23:03 (182.139.66.250)
[root ~ ] # last 
root pts/0 117.136.63.184 Sun May 26 18:57 still logged in   
reboot system boot 3.10.0-957.10.1. Mon May 27 02:52 - 19:10 (-7:-42)   
root pts/4 117.136.63.184 Sun May 26 18:51 - crash (08:01)    
root pts/4 117.136.63.184 Sun May 26 18:49 - 18:49 (00:00)    
root pts/3 117.136.63.183 Sun May 26 18:35 - crash (08:17)    
root pts/2 117.136.63.183 Sun May 26 18:34 - crash (08:17)    
root pts/0 117.136.63.183 Sun May 26 18:10 - crash (08:42)    

2.查看自己使用的 Shell - ps。
Shell 被稱為 '殼層' 或 '殼程序'。它是用戶與作業系統內核交流的翻譯官,ㄊ就是人與計算機交互的界面和接口。目前很多 Linux 系統默認的 Shell 都是 bash (Bourne Again SHell),因為它可以使用 tab 鍵進行命令和路徑補全、可以保存歷史命令、可以方便的配置環境變量以及執行批處理操作。

[root@izwz97tbgo9lkabnat2lo8z ~ ] # ps
  PID TTY TIME CMD
 3531 pts/0 00:00:00 bash
 3553 pts/0 00:00:00 ps

https://ithelp.ithome.com.tw/upload/images/20191007/20121116LhhCjx5sxD.png
3.查看命令的說明和位置 - whatis / which / whereis。
如果找不到命令的時候可以在前面加 $ 看有沒有改變。
https://ithelp.ithome.com.tw/upload/images/20191007/20121116FRPrhIctGC.png
4.清除螢幕上顯示的內容 - clear。
5.查看幫助文檔 - man / info / help / apropos。

[root@izwz97tbgo9lkabnat2lo8z ~ ] # ps --help
Usage:
 ps [options]
 Try ' ps --help <simple|list|output|threads|misc|all> ' 
  or ' ps --help <s|l|o|t|m|a> '
  for additional help text.
For more details see ps(1).
[root@izwz97tbgo9lkabnat2lo8z ~ ] # man ps
PS(1) User Commands PS(1)
NAME
       ps - report a snapshot of the current processes.
SYNOPSIS
       ps [options]
DESCRIPTION
...

https://ithelp.ithome.com.tw/upload/images/20191007/20121116aet3ghsl6R.png
6.查看系統和主機名 - uname / hostname。
https://ithelp.ithome.com.tw/upload/images/20191007/20121116USasJh40ak.png
7.時間和日期 - date / cal。
https://ithelp.ithome.com.tw/upload/images/20191007/20121116oz6c5Vc1yK.png
8.重啟和關機 - reboot / shutdown。

[root ~ ] # shutdown -h +5 
Shutdown scheduled for Sun 2019-05-26 19:34:27 CST, use ' shutdown -c ' to cancel.
[root ~ ] # 
Broadcast message from root (Sun 2019-05-26 19:29:27 CST):

The system is going down for power-off at Sun 2019-05-26 19:34:27 CST ! 
[root ~ ] # shutdown -c

Broadcast message from root (Sun 2019-05-26 19:30:22 CST):

The system shutdown has been cancelled at Sun 2019-05-26 19:31:22 CST ! 
[root ~ ] # shutdown -r 23:58 
Shutdown scheduled for Sun 2019-05-26 23:58:00 CST, use ' shutdown -c ' to cancel.
[root ~ ] # shutdown -c

Broadcast message from root (Sun 2019-05-26 19:31:06 CST):

The system shutdown has been cancelled at Sun 2019-05-26 19:32:06 CST !

9.退出登錄 - exit / logout。
10.查看歷史命令 - history。
https://ithelp.ithome.com.tw/upload/images/20191007/20121116GuhdJpCNt2.png


上一篇
[Day28] Linux 作業系統 - 發展史和概述
下一篇
[Day30] Linux 作業系統 - 實用程序
系列文
30天學python30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言