Linux 效法的對象是 Unix 作業系統這個 1969 年就有的老祖宗, 直到今天都還有人持續在使用和發展。 Unix "背後累積多年的設計規則當然也體現在 Linux 裡頭。要初探本作業系統,這些規則將是您不可不知的基本概念。
太始之初,Unix 是個文字指令介面導向的系統,我們的 Linux也承襲了這項特色。即使今天所看到的圖型介面有那些視窗、圖示、選單的東西,其實還是以文字指令介面為基礎發展而來的。更進一步地說, Linux 檔案系統的架構本質上是為了能夠方便地以文字指令介面來存取與管理才如此設計的。
Linux 與 Unix 的檔案系統結構是垂直取向,樹狀分支的結構。 檔案系統最上層的目錄名稱是 /
或稱作根目錄. 依照 Unix 與 Linux 的設計理念。系統裡什麼東西都被視為檔案,這也包含了您的硬碟、分割區,以及隨身碟之類的硬體。這也表示其他的檔案和目錄(包含硬碟與分割區)全部必須置於根目錄底下。
我們舉個例子來看︰ /home/jebediah/cheeses.odt
這串字 顯示 cheeses.odt
這個檔案的位置。 往前看 jebediah
這個目錄位於 home
目錄底下。層層往上推,就是 (/
) 這個目錄了。
在根目錄(/
) 底下,有一群很重要的系統資料夾,市面上執牛耳的 Linux 套件一定都看得到。我們接下來列出來的這串資料夾名稱都是「根」(/
)·目錄底下常見的資料夾:
/bin
- 重要的程式編譯檔(binary)
/boot
- 開機( boot )所需的相關檔案
/dev
- 裝置檔( device )
/etc
- 程式設定檔, 啟動的指令稿, ( etc )就是諸如此類。
/home
-本地使用者的 家 目錄
/lib
- 系統函式庫(library)
/lost+found
- 提供您一個「根」目錄 (/
)·底下相關檔案的浪子回頭 (lost+found) 備援系統。
/media
- 便於隨時載入與卸下的隨身媒體( media ),像是 光碟、數位相機這類的玩意。
/mnt
- 已掛載( mount )的檔案系統
/opt
- 提供您一個可選擇的(optional) 本地程式安裝目錄
/proc
- 特殊的虛擬目錄,包含 系統狀態的各種資訊,主要就是執行中的程式進度( process )
/root
- 是( root )這個使用者的家目錄, 是神級的帳號。
/sbin
- 重要的系統( system )程式( binary )
/sys
- 系統(system)檔案
/tmp
- 暫存(temporary)檔案
/usr
- 裡頭所包含的程式大部份都可為所有使用者 (user) 所存取。
/var
- 變動不居 (variable) 的檔案,像是紀錄檔或資料庫檔。
All of the files on a Linux system have permissions that allow or prevent others from viewing, modifying or executing. The super user "root" has the ability to access any file on the system. Each file has access restrictions, user restrictions and have an owner/group association.
Every file is secured by the following three sets of permissions, in order of importance:
user
applies to the user who is the owner of the file
group
applies to the group that is associated with the file
other
applies to all other users
Inside each of the three sets of permissions are the actual permissons. The permissions, along with the way they apply differently to files and directories, are outlined below:
read
files can be displayed/opened
directory contents can be displayed
write
files can be edited or deleted
directory contents can be modified
execute
executable files can be run as a program
directories can be entered
To view and edit the permissions on files and directories, open the and right-click on a file or directory. Then select -> -> . The permissions exist under the Permissions tab and allow for the editing of all permission levels, if you are the owner of the file.
To learn more about file permissions in Linux, read the file permissions page in the Ubuntu Wiki.
Working at the command line is not as daunting a task as you would think. There is no special knowledge needed to know how to use the command line, it is a program like everything else. Most things in Linux can be done using the command line, although there are graphical tools for most programs, sometimes they are just not enough. This is where the command line comes in handy.
The Terminal is located in -> . The terminal is often called the command prompt or the shell. In days gone by, this was the way the user interacted with the computer, however Linux users have found that the use of the shell can be quicker than a graphical method and still holds some merit today. Here you will learn how to use the terminal.
The original use of the terminal was a file browser and indeed it is still used as a file browser, in the event of the graphical environment failing. You can use the terminal as a file browser to navigate your files and undo the changes that have been made.
The ls (LiSt) lists files in different colors with full formatted text
The mkdir (MaKeDIRectory) command will create a directory.
The cd (ChangeDirectory) command will change from your current directory to any directory you specify.
The cp (CoPy) command will copy any files you specify. The cp -r command will copy any directories you specify.
The rm (ReMove) command will delete any filename you specify. The rm -rf command will remove any directory you specify.
The mv (MoVe) command will rename/move any file or directory you specify.
The locate command will search your computer for any filename you specify. It uses an index of the files on your system to work quickly: to update this index run the command updatedb. This command is run automatically each day, if you leave your computer on. It needs to be run with administrative privileges (see "Root And Sudo").
You can also use wildcards to match one or more files, such as "*" (for all files) or "?" (to match one character).
For a more thorough introduction to the Linux command line, please read the command line introduction on the Ubuntu wiki.
All of the configurations and settings in Linux are saved in text files. Even though you most often can edit configurations through the graphical interface, you may occasionally have to edit them by hand. Mousepad is the default Xubuntu text editor, which you can launch by clicking -> -> on the desktop menu system.
At times in this guide, Mousepad is run from the command line using gksudo, which runs Mousepad with administrative privileges, in order to modify configuration files.
If you need to use a text editor from the command line, you can use nano, which is a simple to use text editor. When running it from the command line, always use the following command, which ensures that the editor will not introduce line breaks:
nano -w
For more information about how to use nano, refer to the guide on the wiki.
There are also quite a few other terminal-based editors available in Ubuntu, popular ones include VIM and Emacs (the pros and cons of each are cause for much friendly debate within the Linux community). These are often more complex to use than nano, but are also more powerful.
The root user in GNU/Linux is the user which has administrative access to your system. Normal users do not have this access for security reasons. However, Ubuntu does not include the root user. Instead, administrative access is given to individual users, who may use the "sudo" application to perform administrative tasks. The first user account you created on your system during installation will, by default, have access to sudo. You can restrict and enable sudo access to users with the Users and Groups application (see "Managing Users and Groups" for more information).
When you run an application that requires root privileges, sudo will ask you to input your normal user password. This ensures that rogue applications cannot damage your system, and serves as a reminder that you are about to perform administrative actions which require you to be careful!
To use sudo when using the command line, simply type "sudo" before the command you wish to run. Sudo will then prompt you for your password.
Sudo will remember your password for a set amount of time. This feature was designed to allow users to perform multiple administrative tasks without being asked for a password each time.
![]() |
|
Be careful when doing administrative tasks, you might damage your system! |
Some other tips to using sudo include:
To use a "root" terminal, type "sudo -i" at the command line.
The entire group of default graphical configuration tools in Ubuntu already use sudo, so they will prompt you for your password if needed.
When starting graphical tools with "sudo", run it with "gksudo" instead. This will open a small graphical window that prompts the user for his password. "gksudo" is convenient if you want to set up a launcher for Synaptic on your panel, or something similar, where you would normaly not have the possiblity to enter your password.
For more information on the sudo program and the absence of a root user in Ubuntu, read the sudo page on the Ubuntu wiki.
An incredible amount of information about Linux is available on the Internet. To get started, I recommend the excellent and comprehensive tutorial Getting Started with Linux.
For people who already know the basics, the tutorial Intermediate Level User Linux Course is a good read.