Debian Reference - Chapter 1. GNU/Linux tutorials

1.2. Unix-like filesystem

Please also note that there is no concept for drive such as "A:" on any Unix system. There is one filesystem, and everything is included. This is a huge advantage compared to Windows.

1.2.1. Unix file basics

Filenames are case sensitive. That is, "MYFILE" and "MyFile" are different files.
The root directory means root of the filesystem referred as simply "/". Don't confuse this with the home directory for the root user: "/root".
Every directory has a name which can contain any letters or symbols except "/". The root directory is an exception; its name is "/" (pronounced "slash" or "the root directory") and it cannot be renamed.
All fully-qualified filenames begin with the "/" directory, and there's a "/" between each directory or file in the filename. The first "/" is the top level directory, and the other "/"'s separate successive subdirectories, until we reach the last entry which is the name of the actual file. The words used here can be confusing. Take the following fully-qualified filename as an example: "/usr/share/keytables/us.map.gz".
There are also relative paths that begin somewhere other than the root directory. You should remember that the directory "../" refers to the parent directory. This terminology also applies to other directory like structures, such as hierarchical data structures.

While you can use almost any letters or symbols in a file name, in practice it is a bad idea to do so. It is better to avoid any characters that often have special meanings on the command line, including spaces, tabs, newlines, and other special characters: { } ( ) [ ] ' ` " \ / > < | ; ! # & ^ * % @ $ . If you want to separate words in a name, good choices are the period, hyphen, and underscore. You could also capitalize each word, "LikeThis". Experienced Linux users tend to avoid spaces in filenames.
The word "root" can mean either "root user" or "root directory". The context of their usage should make it clear.
The word path is used not only for fully-qualified filename as above but also for the command search path. The intended meaning is usually clear from the context.

The detailed best practices for the file hierarchy are described in the Filesystem Hierarchy Standard ("/usr/share/doc/debian-policy/fhs/fhs-2.3.txt.gz" and hier(7)). You should remember the following facts as the starter.

Table 1.3. List of usage of key directories

/etc/ system wide configuration files
/var/log/ system log files
/home/ all the home directories for all non-privileged users

1.2.2. Filesystem internals

Following the Unix tradition, the Debian GNU/Linux system provides the filesystem under which physical data on hard disks and other storage devices reside, and the interaction with the hardware devices such as console screens and remote serial consoles are represented in an unified manner under "/dev/".

ちょっとようわからんけどいいか、外部のメディア・デバイスが必要になってマウントコマンド使うときにわかるだろう。

1.2.3. Filesystem permissions

For the file, each corresponding permission allows following actions.
The execute (x) permission allows owner to run the file as a command.
For the directory, each corresponding permission allows following actions.
The read (r) permission allows owner to list contents of the directory.
The write (w) permission allows owner to add or remove files in the directory.
The execute (x) permission allows owner to access files in the directory.
Here, the execute permission on a directory means not only to allow reading of files in that directory but also to allow viewing their attributes, such as the size and the modification time.

ls(1) is used to display permission information (and more) for files and directories. When it is invoked with the "-l" option, it displays the following information in the order given.

Type of file (firstcharacter)

これdってなってるのはディレクトリの略なのか。初めて知った。Access permission of the file ってあるから10文字あるじゃんと思ってたら先頭の一文字がそれなのか。へー
次の項目にそのことが書いてあった。

Table 1.4. List of the first character of "ls -l" output

  • normal file

d directory
l symlink
c character device node
b block device node
p named pipe
s socket

さっきhard linkとか書いてあるからなにそれと思っていたけど、こっちもわからないのが山盛りw

chown(1) is used from the root account to change the owner of the file. chgrp(1) is used from the file's owner or root account to change the group of the file. chmod(1) is used from the file's owner or root account to change file and directory access permissions. Basic syntax to manipulate a foo file is the following.

今日はこの辺にしておくかー。
とりあえずchownやchmodの適当な動作確認をした後は、さらさら読んでいる。実行も堅実な理解もせずに、まぁ、さらさらと。そして次にたどり着く。
1.3. Midnight Commander (MC)
もほとんど読んで終わってしまった。Linuxをはじめたばかりの僕にとって今のところベストなファイルマネージャはこれなのでまぁ、後でまた学んでいきたい。著者もどこだったか階層化されてDebian内にあるDocumentを読むときにMCを使ったりしてるみたいだし。

1.4. The basic Unix-like work environment
Scriptなんてコマンドがあるのか、へー。実行し終わったらtypescriptっていうファイルを生成してその中にログが入ってるのね。
というか本当にこれ網羅的なリファレンスで役に立つなぁ。

関係ないけどmanやinfoから抜け出すにはqとタイプすれば抜けられる。今までCtrl+CとかZで逃げてたw、CだかZだかどっちだか忘れたけど、この今読んでるリファレンスのちょっと前にプロセスは殺さずにバックグラウンドに隠してるだけだよみたいに書いてあった。exitを一回やっても終わらずに、何度かやるときとか、きっとあいつらを殺していたんじゃないかと予想。

今気づいたけど、infoって素で打つと面白いHelpページに飛ぶなぁ。これは読んでいきたいかも。

manがUNIXスタイルでinfoがGNUスタイルか、よーしパパinfo使いまくっちゃうぞー。

treeとかいうコマンドが入ってなかったんで、sudo aptitude install treeしてみた。インスコされた。tree使えるようになった。ちょっといい。

change directory to the directory "" in the current directory or in the directory listed in the variable "$CDPATH"

これもしかして環境変数?とやらに"$CDPATH"で適当ないつもよくもぐるようなディレクトリ記述しておけばどのディレクトリからでもそこ指定していけるのかなぁ。だとしたら超便利なんだが。

後はなんか一気に読んじまった。ふーんこういうことをやっていくのかという感じ。最後の方なんかawkとか正規表現使ってたぜw

Chapter 2も適当に読んじまった。Debianでのパッケージマネジメント。Debianerなら当然読むべきものだな。いつか読もうおいw

3. The system initializationもかなり適当に読んだ。まぁ、ここは仮想OS(Sun VirtualBox)使ってるからなぁ。Debian GNU/Hurdを使いたい身としては読むべきかもしれんが、時が来た後でいいだろう。

4. Authenticationも割と適当に読んだ。sudoを使いこなしている俺には関係ないぜ。ってこたないだろうが。

5. Network setupも超適当に読んだ。これから自鯖っていうかサーバー系で開発やると知っておいたほうがいいのかなぁ。Debianインスコしたら有線だったけど勝手に繋がってたので。

6. Network applications
Linksっていうブラウザ試してみたいなぁ。

7. The X Window System アプリケーションの項目があって、ページのフォーマットを作るソフトdesktop publishingってののScribusってのと、GNU Cashが面白そうだった。GNU Cashはいつか使いたいなぁ。てかこれでお金の管理していきたい。

8. I18N and L10Nの項目に色々と日本語関係の項目が書いてあるから使えるかもしれないなぁ。なんてったって僕のDebianにはまだ日本語環境入れてませんからね。

9. System tips最初にGNU Screenの説明があるなぁ。これもいつか使いたいやつ。9.2. Data recording and presentationは割と役に立ちそう。

10. Data management
Backupの項目とCVS特にGitの項目は読んでおきたい。Gitは後々手にすることになるだろう。

Chapter 11. Data conversion
XMLTexや印刷関係あたりが面白そう。つうか日本人の人が書いてるから日本特有のことが結構書いてあって凄いいいな。英語もわかりやすい気がするし。

12. Programmingこれはしっかり読んでいく必要があるな。次の宿題にしてもいいぐらいだ。ワンダフル。

A. Appendix
ありがとうございました。

これ終わったらとりあえずまたPythonの勉強を再開していこうかなぁ。今度はドキュメンテーションや実用的なやつ読み読みしていって力をつけて。ついでにFlaskも。Debianさんは必要ならいつでもDebianの勉強に戻ってきておkって環境を揃えてそういうことに全力で励めという感じのたたずまいなのでもうそれは感謝している。