UNIX file と directory)


<このページの目次>

〇 階層的directoryを一つ上がるにはホーム directoryに帰るには現在のdirectoryを知りたい時directoryを新しく作るにはdirectoryを消すには他のuserのホーム directoryに入るにはdirectoryをそっくりコピーするには他のuserのfileを自分のホーム directoryにコピーするには他のuserのfileを自分のsub-directoryにコピーするにはfileを強制的に消すには

------------------------------------------------   
--------- 階層的directoryを一つ上がるには -----------
------------------------------------------------

>cd ..

cd は change directory と読む。

-----------------------------------------------
--------- ホーム directoryに帰るには --------------
-----------------------------------------------

>cd

もしくは

> cd ~

~はホームディレクトリを意味する。

ホーム directoryとは端末を立ちあげた時のdirectoryである。

-----------------------------------------------
--------- 現在のdirectory(カレントディレクトリ)を知りたい時 -------------
-----------------------------------------------

> pwd
/home/cai

pwd は present working directory と読む。/home/cai の
homeとはdirectory cai の一つ上のdirectoryと考えよ。諸君
のホーム directoryの一つ上のdirectoryも home である。
ホームとhomeは異なる。



-----------------------------------------------
---------  directoryを新しく作るには --------------
-----------------------------------------------

>mkdir newdir

mkdir は make directory と読む。これで newdir という新
しい directory ができる。

-----------------------------------------------
---------  directoryを消すには ------------------- 
-----------------------------------------------

>rmdir olddir

rmdir は remove directory と読む。ただし、olddirの中
の全てのfile,directoryが消えていないと、olddirは消せない。
ただし、

>rm -r olddir

とすると、olddirの中にfileが有っても、強制的に消せる。

------------------------------------------------
--------- 他のuserのホーム directoryに入るには-------
------------------------------------------------

>cd /home/yoshida2

念のため確かめるには( 絶対パスをつかっている)

cai@xsi09> pwd
/home/yoshida2

すなわち、一行目の >cd /home/yoshida2 では、 cai から一つ
上の  home に上がり、次にhome の一つ下の  yoshida2 に降り
たのである。図で説明すると...こうなる。 



yoshida2 の fileなどを検索するには

cai@xsi09> ls -l
   (途中省略)
drwx--x--x  2 yoshida2     1024 Nov 10 11:34 texdir
-rw-------  1 yoshida2       30 May  1  1995 yoshi.cp
-rw-------  1 yoshida2       30 May  1  1995 yoshida
-rw-r--r--  1 yoshida2       59 May 15  1995 z515

---------------------------------------------------
---------  directoryをそっくりコピーするには ------------
---------------------------------------------------

>cp -rR subdir1 subdir2 RET

subdir1 と subdir2 は directory の名前。subdir1 がそっくり 
subdir2 にコピーされる。ただし、directory subdir2 はまだ
存在していないとする。

注意: 上の cp -rR で、directory subdir2 が既に存在する時は
( >mkdir subdir2 としてある時は)、subdir1 は subdir2/
subdir1 にコピーされる。 


---------------------------------------------------
  他のuserのfileを自分のホーム directoryにコピーするには
---------------------------------------------------

>cd      (自分のホームdirectoryに帰る)
>cp /home/yoshida2/z515 myfile


---------------------------------------------------
  他のuserのfileを自分のsub-directoryにコピーするには
---------------------------------------------------

>cd      (自分のホームdirectoryに帰る)
>cp /home/yoshida2/z515 MYDIR/myfile

(絶対パス)

ただし自分のホームdirectory に subdirectory MYDIR を前もって
作っておく。上の >cp は次のように書いてもよい。

>cp /home/yoshida2/z515  /home/cai/MYDIR/myfile

即ち、自分のdirectoryもフルに書いてしまう。この方法では
present working directoryを気にしなくてよい。

---------------------------------------------------
-------------  fileを強制的に消すには ----------------
---------------------------------------------------

>rm kari    とすると、

rm: remove kari , overriding mode 0400 ?

のようにpermission の関係で、消せない事もある。
強制的に消すには

>rm  -f kari とすればよい。


---------------------------------------------------
-------------  コマンドをしらべるオンラインマニュアル ----------------
---------------------------------------------------

たとえば、ls を調べるには

> man ls 

User Commands                                               LS(1)

NAME
     ls, dir, vdir - list contents of directories

SYNOPSIS
     ls [-abcdfgiklmnpqrstuxABCFGLNQRSUX1] [-w  cols]  [-T  cols]
     [-I  pattern]  [--all]  [--escape]  [--directory]  [--inode]
     [--kilobytes]  [--numeric-uid-gid]   [--no-group]   [--hide-
     control-chars]     [--reverse]    [--size]    [--width=cols]
     [--tabsize=cols] [--almost-all] [--ignore-backups]  [--clas-
     sify]    [--file-type]    [--full-time]   [--ignore=pattern]
     [--dereference]  [--literal]  [--quote-name]   [--recursive]
     [--sort={none,time,size,extension}]
     [--format={long,verbose,commas,across,vertical,single-
     column}]  [--time={atime,access,use,ctime,status}]  [--help]
     [--version]                         [--color[={yes,no,tty}]]
     [--colour[={yes,no,tty}]] [name...]

DESCRIPTION
     This documentation is no longer being maintained and may  be
     inaccurate  or incomplete.  The Texinfo documentation is now
     the authoritative source.

     This manual page documents the GNU version of ls.   dir  and
     vdir  are  versions of ls with different default output for-
     mats.  These programs list  each  given  file  or  directory
     name.   Directory  contents  are sorted alphabetically.  For
     ls, files are by default listed in  columns,  sorted  verti-
     cally,  if the standard output is a terminal; otherwise they
     are listed one per line.  For  dir,  files  are  by  default
     listed  in  columns, sorted vertically.  For vdir, files are
     by default listed in long format.

  OPTIONS
     -a, --all
          List all files in directories, including all files that
          start with `.'.

とでてくる。


--------------------------------------------------
---------  説明おしまい --------------------------- 
--------------------------------------------------