サンプルセッション (参考: Vine Linux 上での実行例です)
ロケールを C (POSIX) にする。
[ohsaki@vine ~]$ LANG=C
カレントディレクトリのファイル一覧を表示する。C ロケールなので日本語は ?? と表示される。
[ohsaki@vine ~]$ ls
rpm/ ??????????????????/ ?????????/
??????????????????/ ??????????????????/ ???????????????/
??????????????????/ ???????????????/ ??????????????????/
カレントディレクトリのファイル一覧を表示する。-l で詳細表示。
[ohsaki@vine ~]$ ls -l
total 36
drwxr-xr-x 7 ohsaki ohsaki 4096 Sep 13 17:30 rpm/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ???????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ?????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ???????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
カレントディレクトリのファイル一覧を表示する。-l で詳細表示。-a ですべてのファイル。
[ohsaki@vine ~]$ ls -al
total 252
drwx------ 37 ohsaki ohsaki 4096 Sep 21 19:47 ./
drwxr-xr-x 3 root root 4096 Sep 13 18:05 ../
-rw------- 1 ohsaki ohsaki 3100 Sep 21 19:42 .ICEauthority
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 17:30 .Wnn7/
-rw------- 1 ohsaki ohsaki 150 Sep 21 19:45 .Xauthority
-rw-r--r-- 1 ohsaki ohsaki 193 Jun 5 2011 .Xresources
drwx------ 3 ohsaki ohsaki 4096 Sep 14 02:51 .adobe/
-rw------- 1 ohsaki ohsaki 729 Sep 21 16:58 .bash_history
-rw-r--r-- 1 ohsaki ohsaki 24 Jun 5 2011 .bash_logout
-rw-r--r-- 1 ohsaki ohsaki 238 Jun 5 2011 .bash_profile
-rw-r--r-- 1 ohsaki ohsaki 389 Jun 5 2011 .bashrc
drwxr-xr-x 5 ohsaki ohsaki 4096 Sep 14 02:52 .cache/
drwx------ 6 ohsaki ohsaki 4096 Sep 14 12:37 .config/
-rw-r--r-- 1 ohsaki ohsaki 595 Jun 5 2011 .cshrc
drwx------ 3 ohsaki ohsaki 4096 Sep 13 18:14 .dbus/
-rw-r--r-- 1 ohsaki ohsaki 41 Sep 21 19:42 .dmrc
drwxr-xr-x 3 ohsaki ohsaki 4096 Sep 13 18:24 .emacs.d/
-rw------- 1 ohsaki ohsaki 16 Sep 13 18:14 .esd_auth
drwx------ 4 ohsaki ohsaki 4096 Sep 21 19:42 .gconf/
drwx------ 2 ohsaki ohsaki 4096 Sep 21 19:43 .gconfd/
-rw-r----- 1 ohsaki ohsaki 0 Sep 13 20:15 .gksu.lock
drwxr-xr-x 6 ohsaki ohsaki 4096 Sep 21 16:55 .gnome2/
drwx------ 2 ohsaki ohsaki 4096 Sep 13 18:14 .gnome2_private/
drwx------ 2 ohsaki ohsaki 4096 Jun 5 2011 .gnupg/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 .gstreamer-0.10/
-rw-r--r-- 1 ohsaki ohsaki 339 Sep 21 19:42 .gtk-bookmarks
dr-x------ 2 ohsaki ohsaki 0 Sep 21 19:42 .gvfs/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:31 .icons/
drwxr-xr-x 3 ohsaki ohsaki 4096 Sep 13 18:14 .local/
drwx------ 2 ohsaki ohsaki 4096 Sep 13 18:49 .mozc/
drwxr-xr-x 4 ohsaki ohsaki 4096 Sep 14 02:52 .mozilla/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 .nautilus/
drwx------ 2 ohsaki ohsaki 4096 Sep 13 18:14 .pulse/
-rw------- 1 ohsaki ohsaki 256 Sep 13 18:14 .pulse-cookie
-rw-r--r-- 1 ohsaki ohsaki 212 Jun 5 2011 .rpmmacros
drwx------ 2 ohsaki ohsaki 4096 Sep 21 19:45 .ssh/
drwx------ 8 ohsaki ohsaki 4096 Sep 14 02:52 .sylpheed-2.0/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:31 .themes/
drwx------ 3 ohsaki ohsaki 4096 Sep 13 18:31 .thumbnails/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:33 .vim/
-rw------- 1 ohsaki ohsaki 4084 Sep 13 18:33 .viminfo
drwxr-xr-x 3 ohsaki ohsaki 4096 Sep 13 18:14 .vine/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 17:30 .vje/
-rw------- 1 ohsaki ohsaki 1804 Sep 21 19:43 .xsession-errors
-rw------- 1 ohsaki ohsaki 1683 Sep 21 15:06 .xsession-errors.old
-rw-r--r-- 1 ohsaki ohsaki 500 Sep 21 19:42 .xwm.msgs
-rw-rw-r-- 1 ohsaki ohsaki 32179 Sep 14 12:18 .zcompdump
-rw------- 1 ohsaki ohsaki 3 Sep 14 12:18 .zsh_history
-rw-r--r-- 1 ohsaki ohsaki 2774 Jun 5 2011 .zshrc
drwxr-xr-x 7 ohsaki ohsaki 4096 Sep 13 17:30 rpm/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ???????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ?????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ???????????????/
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 13 18:14 ??????????????????/
ls のコマンドラインオプションを確認する。
[ohsaki@vine work]$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort.
Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--block-size=SIZE scale sizes by SIZE before printing them. E.g.,
`--block-size=M' prints sizes in units of
1,048,576 bytes. See SIZE format below.
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information)
with -l: show ctime and sort by name
otherwise: sort by ctime
-C list entries by columns
--color[=WHEN] colorize the output. WHEN defaults to `always'
or can be `never' or `auto'. More info below
-d, --directory list directory entries instead of contents,
and do not dereference symbolic links
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append `*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files.
augment with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group in a long listing, don't print group names
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k like --block-size=1K
-l use a long listing format
-L, --dereference when showing file information for a symbolic
link, show information for the file the link
references rather than for the link itself
-m fill width with a comma separated list of entries
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars print ? instead of non graphic characters
--show-control-chars show non graphic characters as-is (default
unless program is `ls' and output is a terminal)
-Q, --quote-name enclose entry names in double quotes
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse reverse order while sorting
-R, --recursive list subdirectories recursively
-s, --size print the allocated size of each file, in blocks
-S sort by file size
--sort=WORD sort by WORD instead of name: none -U,
extension -X, size -S, time -t, version -v
--time=WORD with -l, show time as WORD instead of modification
time: atime -u, access -u, use -u, ctime -c,
or status -c; use specified time as sort key
if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, +FORMAT.
FORMAT is interpreted like `date'; if FORMAT is
FORMAT1<newline>FORMAT2, FORMAT1 applies to
non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with `posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time
with -l: show access time and sort by name
otherwise: sort by access time
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS assume screen width instead of current value
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-Z, --context print any SELinux security context of each file
-1 list one file per line
--help display this help and exit
--version output version information and exit
SIZE may be (or may be an integer optionally followed by) one of following:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
Using color to distinguish file types is disabled both by default and
with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors command to set it.
Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).
Report ls bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report ls translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'ls invocation'
カレントディレクトリ名を表示する。
[ohsaki@vine ~]$ pwd
/home/ohsaki
作業用ディレクトリ (work) を作成する。
[ohsaki@vine ~]$ mkdir work
work ディレクトリに移動
[ohsaki@vine ~]$ cd work
カレントディレクトリ名を表示する。
[ohsaki@vine work]$ pwd
/home/ohsaki/work
カレントディレクトリのファイル一覧を表示する。新しいディレクトリなので当然空。
[ohsaki@vine work]$ ls -al
total 8
drwxr-xr-x 2 ohsaki ohsaki 4096 Sep 21 19:47 ./
drwx------ 38 ohsaki ohsaki 4096 Sep 21 19:47 ../
エディタ (gedit) が実行できるか (存在するか) 確認する。
[ohsaki@vine work]$ which gedit
/usr/bin/gedit
gedit のコマンドラインオプションを確認する。
[ohsaki@vine ~]$ gedit --help
Usage:
gedit [OPTION...] [FILE...] - Edit text files
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options
--help-sm-client Show session management options
Application Options:
-V, --version Show the application's version
--encoding=ENCODING Set the character encoding to be used to open the files listed on the command line
--list-encodings Display list of possible values for the encoding option
--new-window Create a new top-level window in an existing instance of gedit
--new-document Create a new document in an existing instance of gedit
--display=DISPLAY X display to use
UNIX ではファイル名の大文字・小文字が区別される。
[ohsaki@vine work]$ which Gedit
/usr/bin/which: no Gedit in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin)
存在しないので当然実行できない。
[ohsaki@vine work]$ Gedit
-bash: Gedit: command not found
sample.c というファイルを新規に作成する。
[ohsaki@vine work]$ gedit sample.c
(ここで gedit エディタでプログラムを入力)
ファイル sample.c の内容を確認する。
[ohsaki@vine work]$ cat sample.c
#include <stdio.h>
int
main(int argc, char **argv) {
printf ("Hello, world!\n");
}
gedit のコマンドラインオプションを確認する。
[ohsaki@vine ~]$ cat --help
Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit
With no FILE, or when FILE is -, read standard input.
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
Report cat bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report cat translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'cat invocation'
ファイル sample.c の内容を確認する。-n オプションで行番号を表示。
[ohsaki@vine work]$ cat -n sample.c
1 #include <stdio.h>
2 int
3 main(int argc, char **argv) {
4 printf ("Hello, world!\n");
5 }
6
C コンパイラ (gcc) が実行できるか (存在するか) 確認する。
[ohsaki@vine work]$ which gcc
/usr/bin/gcc
gcc のコマンドラインオプションを確認する。
[ohsaki@vine ~]$ gcc --help
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
--help={target|optimizers|warnings|params|[^]{joined|separate|undocumented}}[,...]
Display specific types of command line options
(Use '-v --help' to display command line options of sub-processes)
--version Display compiler version information
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compiler's target processor
-print-search-dirs Display the directories in the compiler's search path
-print-libgcc-file-name Display the name of the compiler's companion library
-print-file-name=<lib> Display the full path to library <lib>
-print-prog-name=<prog> Display the full path to compiler component <prog>
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-print-sysroot Display the target libraries directory
-print-sysroot-headers-suffix Display the sysroot suffix used to find headers
-Wa,<options> Pass comma-separated <options> on to the assembler
-Wp,<options> Pass comma-separated <options> on to the preprocessor
-Wl,<options> Pass comma-separated <options> on to the linker
-Xassembler <arg> Pass <arg> on to the assembler
-Xpreprocessor <arg> Pass <arg> on to the preprocessor
-Xlinker <arg> Pass <arg> on to the linker
-combine Pass multiple source files to compiler at once
-save-temps Do not delete intermediate files
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs=<file> Override built-in specs with the contents of <file>
-std=<standard> Assume that the input sources are for <standard>
--sysroot=<directory> Use <directory> as the root directory for headers
and libraries
-B <directory> Add <directory> to the compiler's search paths
-b <machine> Run gcc for target <machine>, if installed
-V <version> Run gcc version number <version>, if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o <file> Place the output into <file>
-x <language> Specify the language of the following input files
Permissible languages include: c c++ assembler none
'none' means revert to the default behavior of
guessing the language based on the file's extension
Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W<letter> options must be used.
For bug reporting instructions, please see:
<http://gcc.gnu.org/bugs.html>.
sample.c をコンパイルして実行ファイル (sample) を生成する。
[ohsaki@vine work]$ gcc -o sample sample.c
実行ファイルができているか確認する。
[ohsaki@vine work]$ ls
sample* sample.c
実行ファイルを実行する。カレントディレクトリにあるので先頭に ./ が必要。
[ohsaki@vine work]$ ./sample
Hello, world!
Hiroyuki Ohsaki
(ohsaki[atmark]lsnl.jp)