# Linux ### Definition of an Operating System (OS): ![](https://hackmd.io/_uploads/H1qgVKvjn.png) An OS is a system software that ==manages computer hardware== and software resources. It provides various services for computer programs, acting as an intermediary between users and the computer hardware. ### Different Types of OSes and Their Applications: - Single-User OS: Designed for one user at a time (e.g., MS-DOS). - Multi-User OS: Allows multiple users to access the system simultaneously (e.g., Linux, Unix). - Real-Time OS: Used in embedded systems for immediate response (e.g., RTLinux). - Mobile OS: Designed for smartphones and tablets (e.g., Android, iOS). ### Back to Linux OS: - Linux is an open-source, Unix-like OS. - It is known for its flexibility, security, and wide community support. - Different distributions cater to different needs, such as "Ubuntu" for beginners, CentOS for servers, etc. > Ubuntu 只是一種linux的發行版,我們用的樹梅pi上的Raspian也是一樣。 --- ### Role of OS: in managing hardware and software An OS plays a critical role in controlling and coordinating the use of the hardware among the various types of application software. ![](https://hackmd.io/_uploads/Bk2q7nQ2h.png) ## 2: Understanding Kernel & Linux Introduction Structure of an OS: Kernel, Shell, File System Introduction to Linux as a Kernel Difference between Kernel and OS ## Linux Kernal The core part of the OS, managing CPU, memory, and devices. ### **Linux Commands List Pdf – Basic Commands** | Command | Description | | ------- | :----------------------------------------------------------- | | pwd | prints the current working directory | | cd | allows one to change directory | | ls | lists the contents of a directory | | alias | create a shortcut to another command or name to execute a long string. | | mkdir | create a directory | | cp | copy a file or directory | | rm | removes or deletes a file or directory | | mv | moves or renames a file or directory | Linux GUI: X11 是利用網路架構來進行圖形介面的執行與繪製 ![](https://hackmd.io/_uploads/HJp5FqX2n.png) ![](https://hackmd.io/_uploads/r10KY6ST3.png) 延伸: SSH X11 Forwarding --- ![](https://hackmd.io/_uploads/B1QZY6Han.png) ![](https://hackmd.io/_uploads/SJ1fKaSTh.png) ![](https://hackmd.io/_uploads/H12ftTST3.png) ![](https://hackmd.io/_uploads/SJ37tpB6h.png) ![](https://hackmd.io/_uploads/rJKVYaHp3.png) BASH(Bourne Again SHell)- Shell BASH 之所以會被各大 Linux 套件採用為預設的 shell﹐除了它本身是 open source 程式之外﹐它的強大功能應該是吸引大家目光的重要因素之一。BASH 的功能很多﹐下面只列舉其中一少部份而已﹕ 命令補全功能﹕ 當您輸入命令的時候﹐您可以輸入目錄或檔案的開首字面﹐然後按‘tab’鍵將您的命令路徑補全。 例子: 您要 ls 一下 /etc/sysconfig 這個目錄的內容(假設您已經在 /etc 目錄下了)﹐您可以只輸入 ls sy 然後接連按兩下 tab 鍵﹐然後就會將 /etc/ 目錄下所有以 sy 開頭的檔案和目錄顯示出來﹐您或許可以看到 sysconfig﹑sysctl.conf ﹑syslog.conf 這三個結果﹔如果您只輸入 ls sys 再按兩下 tab 的話﹐結果是是一樣的﹐因為在 /etc/ 目錄下面﹐所有以 sy 開頭的檔案﹐第 3 個字面都是 s 而沒有其它字面了﹔如果您輸入 ls sysc 再重複這個動作﹐那麼顯示結果就剩下 sysconfig 和 sysctl.conf 而已﹐因為以 sysc 開頭的只有這兩個檔﹐如果您再按 ls sysco 接一個 tab﹐那就會幫您將 sysconfig 這個唯一以 sysco 開頭的檔案補全。 同樣的﹐這個功能也可以用在輸入命令的時候﹐比方說﹐您要輸入 Xconfigurator 命令﹐那您只需輸入 Xc 然後按一下 tab 就可以了﹗   命令記錄表﹕ 每次您輸入一個命令﹐並按 Enter 執行之後﹐這個命令就被存放在命令記錄表(command history)中﹐而每個命令都有一個記錄號碼﹐您可以用 history命令來看看當前的命令歷史表。這樣﹐您只要用向上方向鍵﹐就可以依次呼叫出您最近所輸入的命令﹐按下方向鍵則退回最新的命令﹐找到您想要重新輸入的命令﹐然後再按 Enter 即可。 Bash 會將您登錄之後的所有命記錄在記 cache 裡面﹐然後﹐只要您成功退出這個 shell 之後﹐那這些記錄就會存放到家目錄的 ~/.bash_history 這個檔裡面(它是以 . 開頭的檔案哦﹐也就是隱藏檔是也﹐您要用 ls -a 才看得到。) 不過﹐這個檔只保持一定數量的命令記錄而已﹐您可以透過 $HISTFILESIZE 這個變數﹐來獲得或改變檔案的記錄數量。 ![](https://hackmd.io/_uploads/r1VDKTr63.png) ![](https://hackmd.io/_uploads/Bye_Y6Ban.png) ![](https://hackmd.io/_uploads/By_OKaHa2.png) ![](https://hackmd.io/_uploads/BJ05F6HTn.png) ![](https://hackmd.io/_uploads/ByV3K6rT3.png)