Last active
July 12, 2022 10:10
-
-
Save relyky/f84b6f7514b89dc08c9d245f7bb7dedc to your computer and use it in GitHub Desktop.
Ubuntu/Linux 常用指令
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
§§ crontab 設定排程 ================================================================ | |
附上crontab 設定資訊的網頁以供參考:https://blog.gtwang.org/linux/linux-crontab-cron-job-tutorial-and-examples/ | |
其中要注意『工作目錄』的問題。 | |
> crontab -l | |
查看自己的 crontab | |
> crontab -e | |
進入 crontab 設定檔編輯介面。 | |
編輯完存檔新的排程就立即生效。 | |
> crontab -r | |
刪除 crontab 內容 | |
> systemctl status cron | |
查看 crontab 排程啟動狀態。 | |
> systemctl start cron | |
啟動 crontab 排程。 | |
> systemctl stop cron | |
停止 crontab 排程。 | |
------------ crontab 排程內容檔範例: ------------ | |
# 分 時 日 月 星期 指令1 參數[;指令2 參數][;指令3 參數] | |
# 也支援多個指令以";"分號分隔。 | |
*/2 * * * * date >> ~/time.log | |
## 每2分鐘執行一次,並用 pipeline 把結果倒到家目錄的time.log檔。 | |
## 用來測試 crontab 是否有在運作。 | |
1 * * * * cd ~/app; ./cttool-app | |
## 每小時的第1分鐘執行一次, | |
## 執行2個指令,第一個"cd"指令變更工作目錄 | |
## 第二個指令才是真正要執行的排程工作。 | |
2 * * * * ~/Desktop/linux-x64/Net6FileIo ~/Desktop/linux-x64/Input1.csv | |
## 每小時的第2分鐘執行一次, | |
## 以絕對路徑指明指令與參數。 | |
###################################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 列出及查詢已安裝的套件 | |
$ sudo dpkg -l | |
$ sudo dpkg -l | grep <name> | |
$ sudo apt ist -- installed | |
$ sudo apt ist -- installed | grep <name> | |
## 計算 Ubuntu 系統中已安裝軟體包的數量 | |
$sudo dpkg-query -f '${binary:Package}\n' -W | wc -l | |
## 更新 Update your Ubuntu box | |
$ sudo apt update | |
$ sudo apt upgrade | |
## install curl command | |
$ sudo apt install curl | |
$ curl --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
查看 Ubuntu 的版本: | |
$ lsb_release -a | |
$ cat /etc/issue | |
列出 Linux Kernel 的版本: | |
$ uname ------ 作業系統名稱 | |
$ uname -a ------ 作業系統全部型號資訊 | |
檢查記憶體狀態 | |
$ free | |
$ free -m ------ 以 MB 的方式顯示 | |
列出 CPU 資訊的工具 | |
$ lscpu | |
列出電腦中所有的硬體資訊 | |
$ lshw | |
$ lspci ------ 列出 PCI bus 上的硬體資訊,包含顯示卡的資訊 | |
$ lspci | grep VGA ------ 列出顯示卡的資訊 | |
$ lsusb ------ 列出 USB 裝置 | |
$ lsmod ------ 列出被系統載入的模組 | |
$ dmidecode ------ BIOS 中的資訊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 工作管理員 GUI | |
$ gnome-system-monitor 系統監控 | |
## 當用cmd | |
$ cmd 終端機 | |
## 當用bash指令: | |
$ ps 列出正在執行指令 | |
$ kill [pid] 結束單個程序。 | |
$ kill -9 [pid] 強制中止單個程序。 | |
$ pkill <程序名> 結束整個程序族。 | |
$ killall <程序名> 結束整個程序族。 | |
$ xkill 在圖形介面中點殺程序。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
§§ Ubuntu/Linux 常用指令 | |
## su | |
切換成 super user。 | |
## sudo | |
## ls: 列出檔案清單 | |
ls -l | |
列出現在目錄的檔案清單與授權授權狀況。 | |
ls -la | |
列出現在目錄的檔案與子目錄清單授權狀況。 | |
## chgrp: 改變檔案所屬群組 | |
## chown: 改變檔案擁有者 | |
## chmod: 改變檔案的權限, SUID, SGID, SBIT等等的特性 | |
+ ------------------ 0400 所有者讀出 | |
| + ---------------- 0200 所有者寫入 | |
| | + -------------- 0100 所有者執行 (在目錄中搜尋) | |
| | | + ------------ 0040 群成員讀出 | |
| | | | + ---------- 0020 群成員寫入 | |
| | | | | + -------- 0010 群成員執行或搜尋 | |
| | | | | | + ------ 0004 其他人讀出 | |
| | | | | | | + ---- 0002 其他人寫入 | |
| | | | | | | | + -- 0001 其他人執行或搜尋 | |
| | | | | | | | | | |
r w x r w x r w x | |
chmod o-w file | |
不允許其他人寫入。 | |
chmod +x file | |
充允檔案為可執行。 | |
chmod 4555 file | |
允許每個人讀出和執行, 以及設定 set-user-ID 位元。 | |
chmod 644 file | |
允許所有者讀出和寫入, 並允許其他人讀出: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment