중국 네트워크 보안 방화벽 판매 유지보수  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'Macbook Pro 사용기/OSX Command'에 해당하는 글(6)
2015.09.29   root 사용자로 변경 su -i
2011.10.15   pwd 현재 작업하고 있는 디렉토리 위치를 표시
2011.10.15   rm 파일 및 하위 디렉토리 삭제
2011.10.15   rmdir 디렉토리 삭제
2011.10.15   ls 현재 디렉토리내의 파일 또는 하위 디렉토리 목록을 표시
2011.08.28   CP 파일 복사


root 사용자로 변경 su -i

Mac OS를 사용하다보면 root 사용자로 변경하여야 할 경우가 있습니다. 이 때 root 사용자로 전환하는 명령은 아래와 같습니다.


$ su -i


다음의 명령을 치면 password를 물어보는 질문이 나타나며, 이 때 관리자 패스워드를 입력하면 root 사용자로 변경이 됩니다.








pwd 현재 작업하고 있는 디렉토리 위치를 표시
NAME
     pwd -- return working directory name

SYNOPSIS
     pwd [-L | -P]

DESCRIPTION
     The pwd utility writes the absolute pathname of the current working
     directory to the standard output.

     Some shells may provide a builtin pwd command which is similar or
     identical to this utility.  Consult the builtin(1) manual page.

     The options are as follows:

     -L      Display the logical current working directory.

     -P      Display the physical current working directory (all sym-
             bolic links resolved).

     If no options are specified, the -L option is assumed.

ENVIRONMENT
     Environment variables used by pwd:

     PWD  Logical current working directory.

EXIT STATUS
     The pwd utility exits 0 on success, and >0 if an error occurs.

SEE ALSO
     builtin(1), cd(1), csh(1), sh(1), getcwd(3)

STANDARDS
     The pwd utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').

BUGS
     In csh(1) the command dirs is always faster because it is built
     into that shell.  However, it can give a different answer in the
     rare case that the current directory or a containing directory was
     moved after the shell descended into it.

     The -L option does not work unless the PWD environment variable is
     exported by the shell.



rm 파일 및 하위 디렉토리 삭제
NAME
     rm, unlink -- 디렉토리 엔트리를 삭제
 
SYNOPSIS
     rm [-dfiPRrvW] file ...
     unlink file

DESCRIPTION
     The rm utility attempts to remove the non-directory type files specified
     on the command line.  If the permissions of the file do not permit writ-
     ing, and the standard input device is a terminal, the user is prompted
     (on the standard error output) for confirmation.

     The options are as follows:

-d 다른 유형의 파일뿐만 아니라 디렉토리들을 지움(디렉토리 내에 파일이 존재하거나 하위 디렉토리가 존재하는 경우에는 삭제되지 않음
-f Permission에 상황관없이 확인 메시지 없이 파일을 삭제한다. 파일이 해당 디렉토리에 존재하지 않을 경우에 어떠한 에러 메시지도 출력하지 않는다. -f 옵션앞에 -i 옵션이 있을 경우에 -i 옵션은 무시된다.
-i Permission에 상관없이 각 파일을 삭제하기 전에 확인을 요구한다. 또한 표준 입력 디바이스가 터미널이든 아니든 상관하지 않는다. -i 옵션 앞에 -f 옵션이 있을 경우에 -i 옵션은 무시된다.


     -P          Overwrite regular files before deleting them.  Files are
                 overwritten three times, first with the byte pattern 0xff,
                 then 0x00, and then 0xff again, before they are deleted.

     -R          해당 디렉토리와 하위의 파일 및 디렉토리를 삭제한다. -R 옵션은 -d 옵션을 포함하고 있어서 별도로 -d 옵션을 지정하지 않아도 된다.  만약 -i 옵션을 사용하게 되면 각 디렉토리들이 지원지기 전에 사용자 확인 메시지가 나타난다. 사용자가 알맞은 응답을 하지 않았을 경우에 해당 디렉토리와 하위 디렉토리의 삭제는 취소된다.

     -r          -R 옵션과 동일

     -v          Be verbose when deleting files, showing them as they are
                 removed.

     -W          Attempt to undelete the named files.  Currently, this option
                 can only be used to recover files covered by whiteouts.

     The rm utility removes symbolic links, not the files referenced by the
     links.

     It is an error to attempt to remove the files ``.'' or ``..''.

     When the utility is called as unlink, only one argument, which must not
     be a directory, may be supplied.  No options may be supplied in this sim-
     ple mode of operation, which performs an unlink(2) operation on the
     passed argument.

     The rm utility exits 0 if all of the named files or file hierarchies were
     removed, or if the -f option was specified and all of the existing files
     or file hierarchies were removed.  If an error occurs, rm exits with a
     value >0.

NOTE
     The rm command uses getopt(3) to parse its arguments, which allows it to
     accept the `--' option which will cause it to stop processing flag
     options at that point.  This will allow the removal of file names that
     begin with a dash (`-').  For example:
           rm -- -filename
     The same behavior can be obtained by using an absolute or relative path
     reference.  For example:
           rm /home/user/-filename
           rm ./-filename

SEE ALSO
     rmdir(1), undelete(2), unlink(2), fts(3), getopt(3), symlink(7)

BUGS
     The -P option assumes that the underlying file system is a fixed-block
     file system.  In addition, only regular files are overwritten, other
     types of files are not.

COMPATIBILITY
     The rm utility differs from historical implementations in that the -f
     option only masks attempts to remove non-existent files instead of mask-
     ing a large variety of errors.  The -v option is non-standard and its use
     in scripts is not recommended.

     Also, historical BSD implementations prompted on the standard output, not
     the standard error output.

STANDARDS
     The rm command is almost IEEE Std 1003.2 (``POSIX.2'') compatible, except
     that POSIX requires rm to act like rmdir(1) when the file specified is a
     directory.  This implementation requires the -d option if such behavior
     is desired.  This follows the historical behavior of rm with respect to
     directories.

     The simplified unlink command conforms to Version 2 of the Single UNIX
     Specification (``SUSv2'').

HISTORY
     A rm command appeared in Version 1 AT&T UNIX.

-d 다른 유형의 파일뿐만 아니라 디렉토리들을 지움(디렉토리 내에 파일이 존재하거나 하위 디렉토리가 존재하는 경우에는 삭제되지 않음.


rmdir 디렉토리 삭제
NAME
     rmdir -- remove directories

SYNOPSIS
  rmdir [-p] directory ...

DESCRIPTION
     The rmdir utility removes the directory entry specified by each directory
     argument, provided it is empty.

     Arguments are processed in the order given.  In order to remove both a
     parent directory and a subdirectory of that parent, the subdirectory must
     be specified first so the parent directory is empty when rmdir tries to
     remove it.

     The following option is available:

     -p      Each directory argument is treated as a pathname of which all
             components will be removed, if they are empty, starting with the
             last most component.  (See rm(1) for fully non-discriminant
             recursive removal.)

     The rmdir utility exits with one of the following values:

     0       Each directory entry specified by a dir operand referred to an
             empty directory and was removed successfully.

     >0      An error occurred.

SEE ALSO
     rm(1)

STANDARDS
     The rmdir command is expected to be IEEE Std 1003.2 (``POSIX.2'') compat-
     ible.

HISTORY
     A rmdir command appeared in Version 1 AT&T UNIX.



ls 현재 디렉토리내의 파일 또는 하위 디렉토리 목록을 표시
이름
 ls : 현재 디렉토리의 컨텐츠 목록을 표시

개요
 ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]

설명
각 피연산자를 함께 사용해서 관련 정보를 와 함께 파일 또는 디렉토리의 이름을 표시한다. 
For each operand that names a file of a type other than directory, ls displays its name as well as any requested, associated information.  For each operand that names a file of type directory, ls displays the name of files contained within that directory, as well as any requested, associated information.
만약 피연산자를 사용하지 않는 경우에는 현재 디렉토리의 컨텐츠(파일 또는 디렉토리)만을 표시한다. 하나 이상의 피연산자를 사용할 경우에 비디렉토리 관련 피연산자는 첫번째로 표시되어지고, 디렉토리와 비디렉토리 피연자는 사전순으로 분리되어 정렬된다.
If no operands are given, the contents of the current directory are displayed.  If more than one operand is given, non-directory operands are displayed first; directory and non-directory operands are sorted separately and in lexicographical order.

     The following options are available:

     -@      Display extended attribute keys and sizes in long (-l) output.

     -1      (The numeric digit ``one''.)  Force output to be one entry per
             line.  This is the default when output is not to a terminal.

     -A      List all entries except for . and ...  Always set for the super-
             user.

     -a      Include directory entries whose names begin with a dot (.).

     -B      Force printing of non-printable characters (as defined by
             ctype(3) and current locale settings) in file names as \xxx,
             where xxx is the numeric value of the character in octal.

     -b      As -B, but use C escape codes whenever possible.

     -C      Force multi-column output; this is the default when output is to
             a terminal.

     -c      Use time when file status was last changed for sorting (-t) or
             long printing (-l).

     -d      Directories are listed as plain files (not searched recursively).

     -e      Print the Access Control List (ACL) associated with the file, if
             present, in long (-l) output.

     -F      Display a slash (`/') immediately after each pathname that is a
             directory, an asterisk (`*') after each that is executable, an at
             sign (`@') after each symbolic link, an equals sign (`=') after
             each socket, a percent sign (`%') after each whiteout, and a ver-
             tical bar (`|') after each that is a FIFO.

     -f      Output is not sorted.  This option turns on the -a option.

     -G      Enable colorized output.  This option is equivalent to defining
             CLICOLOR in the environment.  (See below.)

     -g      This option is only available for compatibility with POSIX; it is
             used to display the group name in the long (-l) format output
             (the owner name is suppressed).

     -H      Symbolic links on the command line are followed.  This option is
             assumed if none of the -F, -d, or -l options are specified.

     -h      When used with the -l option, use unit suffixes: Byte, Kilobyte,
             Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the
             number of digits to three or less using base 2 for sizes.

     -i      For each file, print the file's file serial number (inode num-
             ber).

     -k      If the -s option is specified, print the file size allocation in
             kilobytes, not blocks.  This option overrides the environment
             variable BLOCKSIZE.

     -L      Follow all symbolic links to final target and list the file or
             directory the link references rather than the link itself.  This
             option cancels the -P option.

     -l      (The lowercase letter ``ell''.)  List in long format.  (See
             below.)  If the output is to a terminal, a total sum for all the
             file sizes is output on a line before the long listing.

     -m      Stream output format; list files across the page, separated by
             commas.

     -n      Display user and group IDs numerically, rather than converting to
             a user or group name in a long (-l) output.  This option turns on
             the -l option.

     -O      Include the file flags in a long (-l) output.

     -o      List in long format, but omit the group id.

     -P      If argument is a symbolic link, list the link itself rather than
             the object the link references.  This option cancels the -H and
             -L options.

     -p      Write a slash (`/') after each filename if that file is a direc-
             tory.

     -q      Force printing of non-graphic characters in file names as the
             character `?'; this is the default when output is to a terminal.

     -R      Recursively list subdirectories encountered.

     -r      Reverse the order of the sort to get reverse lexicographical
             order or the oldest entries first (or largest files last, if com-
             bined with sort by size

     -S      Sort files by size

     -s      Display the number of file system blocks actually used by each
             file, in units of 512 bytes, where partial units are rounded up
             to the next integer value.  If the output is to a terminal, a
             total sum for all the file sizes is output on a line before the
             listing.  The environment variable BLOCKSIZE overrides the unit
             size of 512 bytes.

     -T      When used with the -l (lowercase letter ``ell'') option, display
             complete time information for the file, including month, day,
             hour, minute, second, and year.

     -t      Sort by time modified (most recently modified first) before sort-
             ing the operands by lexicographical order.

     -u      Use time of last access, instead of last modification of the file
             for sorting (-t) or long printing (-l).

     -U      Use time of file creation, instead of last modification for sort-
             ing (-t) or long output (-l).

     -v      Force unedited printing of non-graphic characters; this is the
             default when output is not to a terminal.

     -W      Display whiteouts when scanning directories.  (-S) flag).

     -w      Force raw printing of non-printable characters.  This is the
             default when output is not to a terminal.

     -x      The same as -C, except that the multi-column output is produced
             with entries sorted across, rather than down, the columns.

     The -1, -C, -x, and -l options all override each other; the last one
     specified determines the format used.

     The -c and -u options override each other; the last one specified deter-
     mines the file time used.

     The -B, -b, -w, and -q options all override each other; the last one
     specified determines the format used for non-printable characters.

     The -H, -L and -P options all override each other (either partially or
     fully); they are applied in the order specified.

     By default, ls lists one entry per line to standard output; the excep-
     tions are to terminals or when the -C or -x options are specified.

     File information is displayed with one or more <blank>s separating the
     information associated with the -i, -s, and -l options.

   The Long Format
     If the -l option is given, the following information is displayed for
     each file: file mode, number of links, owner name, group name, number of
     bytes in the file, abbreviated month, day-of-month file was last modi-
     fied, hour file last modified, minute file last modified, and the path-
     name.  In addition, for each directory whose contents are displayed, the
     total number of 512-byte blocks used by the files in the directory is
     displayed on a line by itself, immediately before the information for the
     files in the directory.  If the file or directory has extended
     attributes, the permissions field printed by the -l option is followed by
     a '@' character.  Otherwise, if the file or directory has extended secu-
     rity information (such as an access control list), the permissions field
     printed by the -l option is followed by a '+' character.

     If the modification time of the file is more than 6 months in the past or
     future, then the year of the last modification is displayed in place of
     the hour and minute fields.

     If the owner or group names are not a known user or group name, or the -n
     option is given, the numeric ID's are displayed.

     If the file is a character special or block special file, the major and
     minor device numbers for the file are displayed in the size field.  If
     the file is a symbolic link, the pathname of the linked-to file is pre-
     ceded by ``->''.

     The file mode printed under the -l option consists of the entry type,
     owner permissions, and group permissions.  The entry type character
     describes the type of file, as follows:

           b     Block special file.
           c     Character special file.
           d     Directory.
           l     Symbolic link.
           s     Socket link.
           p     FIFO.
           -     Regular file.

     The next three fields are three characters each: owner permissions, group
     permissions, and other permissions.  Each field has three character posi-
     tions:

           1.   If r, the file is readable; if -, it is not readable.

           2.   If w, the file is writable; if -, it is not writable.

           3.   The first of the following that applies:

                      S     If in the owner permissions, the file is not exe-
                            cutable and set-user-ID mode is set.  If in the
                            group permissions, the file is not executable and
                            set-group-ID mode is set.

                      s     If in the owner permissions, the file is exe-
                            cutable and set-user-ID mode is set.  If in the
                            group permissions, the file is executable and set-
                            group-ID mode is set.

                      x     The file is executable or the directory is search-
                            able.

                      -     The file is neither readable, writable, exe-
                            cutable, nor set-user-ID nor set-group-ID mode,
                            nor sticky.  (See below.)

                These next two apply only to the third character in the last
                group (other permissions).

                      T     The sticky bit is set (mode 1000), but not execute
                            or search permission.  (See chmod(1) or
                            sticky(8).)

                      t     The sticky bit is set (mode 1000), and is search-
                            able or executable.  (See chmod(1) or sticky(8).)

EXAMPLES
     The following is how to do an ls listing sorted by increasing size

           ls -lrS

DIAGNOSTICS
     The ls utility exits 0 on success, and >0 if an error occurs.

ENVIRONMENT
     The following environment variables affect the execution of ls:

     BLOCKSIZE       If the environment variable BLOCKSIZE is set, the block
                     counts (see -s) will be displayed in units of that size
                     block.

     CLICOLOR        Use ANSI color sequences to distinguish file types.  See
                     LSCOLORS below.  In addition to the file types mentioned
                     in the -F option some extra attributes (setuid bit set,
                     etc.) are also displayed.  The colorization is dependent
                     on a terminal type with the proper termcap(5) capabili-
                     ties.  The default ``cons25'' console has the proper
                     capabilities, but to display the colors in an xterm(1),
                     for example, the TERM variable must be set to
                     ``xterm-color''.  Other terminal types may require simi-
                     lar adjustments.  Colorization is silently disabled if
                     the output isn't directed to a terminal unless the
                     CLICOLOR_FORCE variable is defined.

     CLICOLOR_FORCE  Color sequences are normally disabled if the output isn't
                     directed to a terminal.  This can be overridden by set-
                     ting this flag.  The TERM variable still needs to refer-
                     ence a color capable terminal however otherwise it is not
                     possible to determine which color sequences to use.

     COLUMNS         If this variable contains a string representing a decimal
                     integer, it is used as the column position width for dis-
                     playing multiple-text-column output.  The ls utility cal-
                     culates how many pathname text columns to display based
                     on the width provided.  (See -C and -x.)

     LANG            The locale to use when determining the order of day and
                     month in the long -l format output.  See environ(7) for
                     more information.

     LSCOLORS        The value of this variable describes what color to use
                     for which attribute when colors are enabled with
                     CLICOLOR.  This string is a concatenation of pairs of the
                     format fb, where f is the foreground color and b is the
                     background color.

                     The color designators are as follows:

                           a     black
                           b     red
                           c     green
                           d     brown
                           e     blue
                           f     magenta
                           g     cyan
                           h     light grey
                           A     bold black, usually shows up as dark grey
                           B     bold red
                           C     bold green
                           D     bold brown, usually shows up as yellow
                           E     bold blue
                           F     bold magenta
                           G     bold cyan
                           H     bold light grey; looks like bright white
                           x     default foreground or background

                     Note that the above are standard ANSI colors.  The actual
                     display may differ depending on the color capabilities of
                     the terminal in use.

                     The order of the attributes are as follows:

                           1.   directory
                           2.   symbolic link
                           3.   socket
                           4.   pipe
                           5.   executable
                           6.   block special
                           7.   character special
                           8.   executable with setuid bit set
                           9.   executable with setgid bit set
                           10.  directory writable to others, with sticky bit
                           11.  directory writable to others, without sticky
                                bit

                     The default is "exfxcxdxbxegedabagacad", i.e. blue fore-
                     ground and default background for regular directories,
                     black foreground and red background for setuid executa-
                     bles, etc.

     LS_COLWIDTHS    If this variable is set, it is considered to be a colon-
                     delimited list of minimum column widths.  Unreasonable
                     and insufficient widths are ignored (thus zero signifies
                     a dynamically sized column).  Not all columns have
                     changeable widths.  The fields are, in order: inode,
                     block count, number of links, user name, group name,
                     flags, file size, file name.

     TERM            The CLICOLOR functionality depends on a terminal type
                     with color capabilities.

     TZ              The timezone to use when displaying dates.  See
                     environ(7) for more information.

COMPATIBILITY
     The group field is now automatically included in the long listing for
     files in order to be compatible with the IEEE Std 1003.2 (``POSIX.2'')
     specification.

LEGACY DESCRIPTION
     In legacy mode, the -f option does not turn on the -a option and the -g,
     -n, and -o options do not turn on the -l option.

     Also, the -o option causes the file flags to be included in a long (-l)
     output; there is no -O option.

     When -H is specified (and not overridden by -L or -P) and a file argument
     is a symlink that resolves to a non-directory file, the output will
     reflect the nature of the link, rather than that of the file.  In legacy
     operation, the output will describe the file.

     For more information about legacy mode, see compat(5).

SEE ALSO
     chflags(1), chmod(1), sort(1), xterm(1), compat(5), termcap(5),
     symlink(7), sticky(8)

STANDARDS
     The ls utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').

HISTORY
     An ls command appeared in Version 1 AT&T UNIX.

BUGS
     To maintain backward compatibility, the relationships between the many
     options are quite complex.
 


CP 파일 복사
SYNOPSIS
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_directory



Options

-a -pPR 옵션과 동일하며, 가능한 한 원 파일의 구조와 속성을 그래로 복사
-f 복사 위치의 파일이 열려있지 않은 경우, 복사 위치에 같은 이름의 파일이 존재할 때 별도의 확인 메시지 없이 파일을 지우고 새 파일을 복사

The target file is not unlinked before the copy.  Thus, any existing access rights will be retained.

-H

If the -R option is specified, symbolic links on the command line are followed.  (Symbolic links encountered in the tree traversal are not followed.)

-i

Cause cp to write a prompt to the standard error output before copying a file that would overwrite an existing file.  If the response from the standard input begins with the character `y' or `Y', the file copy is attempted.  (The -i option overrides any previous -n option.).

-L If the -R option is specified, all symbolic links are followed.
-n

Do not overwrite an existing file.  (The -n option overrides any previous -f or -i options.)

-P

If the -R option is specified, no symbolic links are followed. This is the default.

-p

Cause cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, user ID, and group ID, as allowed by permissions.  Access Control Lists (ACLs) and Extended Attributes (EAs), including resourceforks, will also be preserved.


If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered.


If the source file has its set-user-ID bit on and the user ID can not be preserved, the set-user-ID bit is not preserved in the copy's permissions.  If the source file has its set-group-ID bit on and the group ID cannot be preserved, the set-group-ID bit is not preserved in the copy's permissions.  If the source file has both its set-user-ID and set-group-ID bits on, and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set- group-ID bits are preserved in the copy's permissions.

-R

If source_file designates a directory, cp copies the directory and the entire subtree connected at that point.  If the source_file ends in a /, the contents of the directory are copied rather than the directory itself.  This option also causes symbolic links to be copied, rather than indirected through, and for cp to create special files rather than copying them as normal files.  Created directories have the same mode as the corresponding source directory, unmodified by the process' umask. 


In -R mode, cp will continue copying even if errors are detected. 


Note that cp copies hard-linked files as separate files.  If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead.

-v Cause cp to be verbose, showing files as they are copied.
-X Do not copy Extended Attributes (EAs) or resource forks.




-b : 복사할 때 덮어쓰게 되는 파일은 백업을 만든다.
-d : 심볼릭 링크는 심볼릭 링크로 복사한다. 그리고 원본 파일과의 하드링크 관계를 유지한다.
-f : 복사 위치에 존재하는 파일을 제거하고 복사한다.
-i : 복사 시 같은 이름의 파일이 존재한다면 덮어쓸것인가 확인한다.
-P : 원본 파일의 소유자, 그룹, 권한 시간 기록을 그대로 복사한다.
-R,-r : 파일과 하위 디렉토리에 포함된 파일 모두를 복사한다.
-s : 디렉토리가 아닌 파일의 심볼릭 링크를 만든다. 소스 파일의 이름은 전체 경로 이름으로 한다       목적지 파일 이름은 전체 결오를 주지 않아도 현재 디렉토리로 간주 되므로 상관 없다.
-u : 새로 수정된 파일만 복사 한다.
-x : 다른 파일 시스템인 하위 디렉토리는 무시한다.

ex) cp -dRP /oracle /mnt  



BLOG main image
 Notice
 Category
분류 전체보기 (14)
Macbook Pro 사용기 (12)
MacPorts (2)
Apache (1)
PHP (1)
PostgreSQL (1)
OS X (1)
OSX Command (6)
출장기 (2)
중국 생활 (0)
사진일기 (0)
 TAGS
BSD lion ls varchar Xian JSP 서안 asp 출장 redirect JavaScript PostgreSQL macports OSX 시안 Xī'ān HTML OS X data type php
 Calendar
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
 Visitor Statistics
Total :
Today :
Yesterday :
rss