
ls (エルエス)はPOSIXおよびSingle UNIX Specificationで規定されているコマンドである。 ls (Eruesu) is a POSIX and Single UNIX Specification is a command has been stated. lsは「list segments」の略であり、 ファイルの一覧を表示するコマンドである。 ls is a "list segments" which stands for the command to display a list of files.
目次 Contents |
lsはAT&T UNIXの最初のバージョンから存在していた。 ls is AT & T UNIX had existed since the first version. その名称は、 Multicsに存在した類似のコマンドから継承された。 Its name, Multics was inherited from a similar command exists. 現在使われている主な実装には、 フリーソフトウェア財団によるものとFreeBSD 、 OpenBSD 、 NetBSD 、 DarwinなどのBSD系システムで用いられているものの2つがある。 The main implementation is currently used, and by the Foundation for Free Software FreeBSD, OpenBSD, NetBSD, Darwin and BSD systems, but are used in one of two. どちらもフリーソフトウェアであり、 オープンソースである。 And software-free and either the source is open.
UNIX系のシステムには、現在ユーザが作業を行っているファイルシステム上の場所を表す「 カレントディレクトリ 」という概念がある。 UNIX-like systems, which represents the location of system files that are working on the users current directory "current" in the concept. lsは引数を伴わずに起動された場合、カレントディレクトリのファイルの一覧を表示する。 If ls is invoked without arguments, to display a list of files in current directory. 引数にカレントディレクトリ以外のディレクトリを指定した場合、そのディレクトリのファイル一覧を表示する。 If you specify a directory other than the directory to the current argument, to display a list of files in that directory. また、ディレクトリやファイルのリストを引数として指定することもでき、その場合はすべての指定されたファイルと、ディレクトリ内のファイルの一覧を表示する。 It can also be specified as an argument a list of directories and files, in which case all the specified files and to view a list of files in the directory.
「 . 」で始まるファイル名をもつファイル(ドットファイル)は標準では表示されず、表示するには明示的に-aオプションを指定する必要がある。 "." File with the file name starts with (dot files) are the standard will not be displayed, to show the need to explicitly specify the-a option.
オプションが指定されなかった場合、 lsはファイル名のみを表示する。 If no option is specified, ls will display only the file name. しかし、この形式ではファイルの種別、 パーミッション 、サイズなどの情報がわからない。 However, this type of format files, mission par, do not know the size and other information. lsには表示形式を変更するオプションが多く存在するが、もっとも一般的なものは次に挙げたものである。 ls has many options exist to change the display format is the most common ones are listed below.
ls -R /とするとシステムに存在するすべてのファイルを表示する。 Therefore, ls -R / to show all files that exist in the system. 一部の環境では、 --color ( GNU ls )または-G ( FreeBSD ls )オプションを指定するとファイルの種別によって異なる色で表示される。 In some environments, - Color (GNU ls) or-G (FreeBSD ls) will be displayed in different colors depending on file type and options. 表示する色を決定する際、FreeBSDのlsではファイル種別とパーミッションのみで決定されるが、GNUのlsではそれに加え拡張子によっても色を変えることができる。 Determining the color display, FreeBSD for ls is determined only in the file type and permissions, GNU's ls can also change the color in addition to that extension.
このようなオプションを指定した場合、 lsの出力は次のようになる。 If you specify these options, ls will output the following.
brw-r--r-- 1 unixguy staff 64, 64 Jan 27 05:52 block brw-r - r - 1 unixguy staff 64, 64 Jan 27 05:52 block crw-r--r-- 1 unixguy staff 64, 255 Jan 26 13:57 character crw-r - r - 1 unixguy staff 64, 255 Jan 26 13:57 character -rw-r--r-- 1 unixguy staff 290 Jan 26 14:08 compressed.gz -rw-r - r - 1 unixguy staff 290 Jan 26 14:08 compressed.gz -rw-r--r-- 1 unixguy staff 331836 Jan 26 14:06 data.ppm -rw-r - r - 1 unixguy staff 331836 Jan 26 14:06 data.ppm drwxrwx--x 2 unixguy staff 48 Jan 26 11:28 dir drwxrwx - x 2 unixguy staff 48 Jan 26 11:28 dir -rwxrwx--x 1 unixguy staff 29 Jan 26 14:03 executable -rwxrwx - x 1 unixguy staff 29 Jan 26 14:03 executable prw-r--r-- 1 unixguy staff 0 Jan 26 11:50 fifo prw-r - r - 1 unixguy staff 0 Jan 26 11:50 fifo lrwxrwxrwx 1 unixguy staff 3 Jan 26 11:44 link -> dir lrwxrwxrwx 1 unixguy staff 3 Jan 26 11:44 link -> dir -rw-rw---- 1 unixguy staff 217 Jan 26 14:08 regularfile -rw-rw ---- 1 unixguy staff 217 Jan 26 14:08 regularfile
lsには他にも多くのオプションが存在し、それらはmanpageで調べることができる。 the ls has many other options exist, they manpage can look at.
次の例は2つの異なる引数を与えられた時のlsコマンドの出力の違いを示している。 The following example was given two different arguments showing that the difference between the ls command output.
$ pwd $ Pwd /home/fred / home / fred $ ls -l $ Ls-l drwxr--r-- 1 fred editors 4096 drafts drwxr - r - 1 fred editors 4096 drafts -rw-r--r-- 1 fred editors 30405 edition-32 -rw-r - r - 1 fred editors 30405 edition-32 -r-xr-xr-x 1 fred fred 8460 edit -r-xr-xr-x 1 fred fred 8460 edit $ ls -F $ Ls-F drafts/ drafts / edition-32 edition-32 edit* edit *
ここでユーザfredのホームディレクトリにはdraftsというディレクトリ、 edition-32という通常のファイル 、 editという実行可能ファイルが存在することがわかる。 Where the user fred's home directory is a directory called drafts, edition-32 file called normal, edit to know that there is an executable file. lsはユーザ、グループ、世界(それ以外)がファイルに対しどのようなパーミッション(権限)を持っているかを表現するために特別な記法を使っている。 ls is a user, group, world (otherwise) for any file permissions (rights) is a special notation to express what you have.
パーミッション部分の最初の文字はファイルの種別を表す。 The first character represents the type section of the file permissions.
| 文字 Character | 意味 Meaning |
|---|---|
| - -- | 通常のファイル Regular file |
| b b | ブロックデバイス Block device |
| c c | キャラクタデバイス Character device |
| d d | ディレクトリ Directory |
| l l | シンボリックリンク Symlink |
| pまたは= or p = | 名前つきパイプまたはFIFO Named pipe or FIFO |
| s s | ソケット Socket |
残りの部分は3文字ごとのブロックに分けられ、 r 、 w 、 xはそれぞれ書き込み、読み込み、実行の権限が存在することを意味する。 The rest is divided into three blocks of each character, r, w, x will write each read, which means that there are rights of execution. 最初のブロックはユーザの、2つめのブロックはグループの、3つめのブロックは世界のパーミッションを表す。 The first block of the user, the second block of the two groups, the first three blocks represent the permissions of the world. 上の例では、ユーザfredはedition-32を読み書きできるが、実行はできない。 In the above example, the user is fred edition-32 that can read and write, can not run. editorsグループのメンバーはそれ以外のユーザと同様、 edition-32を読めるが、書き込んだり実行したりすることはできない。 editors as well as members of other user groups, edition-32 is read, you can not write or perform.
| ||||||||||||||||||||||||||
