Chapter 5. Unix Basic Commands _ mkdir , rm dir
디렉토리 관리
■ mkdir CMD
■ rmdir CMD
mkdir CMD
________________
make directories
The mkdir command creates the named directories in mode 777
(possibly altered by the file mode creation mask umask(1)).
Standard entries in a directory (for instance, the files
".", for the directory itself, and "..", for its parent) are
made automatically. mkdir cannot create these entries by
name. Creation of a directory requires write permission in
the parent directory.
The owner-ID and group-ID of the new directories are set to
the process's effective user-ID and group-ID, respectively.
mkdir calls the mkdir(2) system call.
빈 디렉토리 생성
(명령어 형식)
# mkdir dir1
# mkdir dir1 dir2
# mkdir -p dir1/dir2/dir3 // -p : 기존에 폴더가 있으면 만들지 않고 없으면 만든다.
# man mkdir
.....
OPTIONS
-p With this option, mkdir creates dir by creating
all the non-existing parent directories first.
The mode given to intermediate directories will
be the difference between 777 and the bits set in
the file mode creation mask. The difference, how-
ever, must be at least 300 (write and execute
permission for the user).
.....
[EX] mkdir -p 명령어 실습
# cd /test
# rm -r *
# mkdir dir1
# mkdir -p dir1/dir2/dir3
# ls -lR
rmdir CMD
________________
remove directory entries
The rm utility removes the directory entry specified by each
file argument. If a file has no write permission and the
standard input is a terminal, the full set of permissions
(in octal) for the file are printed followed by a question
mark. This is a prompt for confirm!ation. If the answer
begins with y (for yes), the file is deleted, otherwise the
file remains.
빈 디렉토리 삭제
(명령어 형식)
# rmdir dir1
# rmdir dir1 dir2
OPTIONS
-p Allows users to remove the directory dirname and its
parent directories which become empty. A message is
printed to standard error if all or part of the path
could not be removed.
[참고] 비어있지 않은 디렉토리 삭제시
# rm -r dir2 (recusive) // 비어있지 않을경우 파일 삭제후 폴더 삭제 !!! recusive!
출처 : http://cafe.daum.net/bscsolaris