Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 執行 .sh 腳本檔完整指南

編輯:Linux 教學

方法一:取得 root 權限後執行(Ubuntu 常用)

  1. 開啟終端機。
  2. sudo su 切換 root,輸入密碼(不顯示字元)。
  3. cd 到腳本目錄。
  4. ./腳本名.sh 執行。
$ sudo su
# cd /tmp
# ./1.sh

方法二:直接用 sh 呼叫

sh 腳本名.sh

補充

  • .sh 類似 Windows 批次檔,執行過程可能需互動輸入資訊。
  • 執行前確認腳本有執行權限(chmod +x 腳本名.sh)。
  • 查看詳細用法:man sh。
Copyright © Windows教程網 All Rights Reserved