ubuntu 기본 명령어
이미지 출처: http://idchowto.com/?p=18437
1. ubuntu 명령어
1.1. pwd(print working directory)
hanjoong@ubuntu:~$ pwd
/home/hanjoong
hanjoong@ubuntu:~$
1.2. ls
옵션
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
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, newest first
-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, --kibibytes use 1024-byte blocks
-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, newest first
-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 is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
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.
예시
hanjoong@ubuntu:~/apache-activemq-5.14.3$ ls -lat
total 15916
drwxr-xr-x 6 hanjoong hanjoong 4096 Jan 25 01:05 ..
drwxr-xr-x 10 root root 4096 Dec 19 07:41 .
drwxr-xr-x 7 root root 4096 Dec 19 07:41 examples
-rw-r--r-- 1 root root 40580 Dec 19 07:41 LICENSE
-rw-r--r-- 1 root root 3334 Dec 19 07:41 NOTICE
-rw-r--r-- 1 root root 2610 Dec 19 07:41 README.txt
-rwxr-xr-x 1 root root 16207404 Dec 19 07:39 activemq-all-5.14.3.jar
drwxr-xr-x 3 root root 4096 May 5 2016 data
drwxr-xr-x 6 root root 4096 May 5 2016 lib
drwxr-xr-x 5 root root 4096 May 5 2016 bin
drwxr-xr-x 3 root root 4096 May 5 2016 webapps-demo
drwxr-xr-x 2 root root 4096 May 5 2016 conf
drwxr-xr-x 6 root root 4096 May 5 2016 webapps
drwxr-xr-x 2 root root 4096 May 5 2016 docs
hanjoong@ubuntu:~/apache-activemq-5.14.3$
1.3. cd
예시
hanjoong@ubuntu:/home/activemq$ pwd
/home/activemq
hanjoong@ubuntu:/home/activemq$ cd ~
hanjoong@ubuntu:~$ pwd
/home/hanjoong
hanjoong@ubuntu:~$ cd .
hanjoong@ubuntu:~$ cd ..
hanjoong@ubuntu:/home$ cd -
/home/hanjoong
hanjoong@ubuntu:~$ pwd
/home/hanjoong
hanjoong@ubuntu:~$ cd -
/home
hanjoong@ubuntu:/home$ pwd
/home
hanjoong@ubuntu:/home$
1.4. cat
옵션
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.
예시
hanjoong@ubuntu:~$ cat -n .profile
1 # ~/.profile: executed by the command interpreter for login shells.
2 # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
3 # exists.
4 # see /usr/share/doc/bash/examples/startup-files for examples.
5 # the files are located in the bash-doc package.
6
7 # the default umask is set in /etc/profile; for setting the umask
8 # for ssh logins, install and configure the libpam-umask package.
9 #umask 022
10
11 # if running bash
12 if [ -n "$BASH_VERSION" ]; then
13 # include .bashrc if it exists
14 if [ -f "$HOME/.bashrc" ]; then
15 . "$HOME/.bashrc"
16 fi
17 fi
18
19 # set PATH so it includes user's private bin if it exists
20 if [ -d "$HOME/bin" ] ; then
21 PATH="$HOME/bin:$PATH"
22 fi
1.5. cp
옵션
Mandatory arguments to long options are mandatory for short options too.
-a, --archive same as -dR --preserve=all
--attributes-only don't copy the file data, just the attributes
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
--copy-contents copy contents of special files when recursive
-d same as --no-dereference --preserve=links
-f, --force if an existing destination file cannot be
opened, remove it and try again (this option
is ignored when the -n option is also used)
-i, --interactive prompt before overwrite (overrides a previous -n
option)
-H follow command-line symbolic links in SOURCE
-l, --link hard link files instead of copying
-L, --dereference always follow symbolic links in SOURCE
-n, --no-clobber do not overwrite an existing file (overrides
a previous -i option)
-P, --no-dereference never follow symbolic links in SOURCE
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST] preserve the specified attributes (default:
mode,ownership,timestamps), if possible
additional attributes: context, links, xattr,
all
--no-preserve=ATTR_LIST don't preserve the specified attributes
--parents use full source file name under DIRECTORY
-R, -r, --recursive copy directories recursively
--reflink[=WHEN] control clone/CoW copies. See below
--remove-destination remove each existing destination file before
attempting to open it (contrast with --force)
--sparse=WHEN control creation of sparse files. See below
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-s, --symbolic-link make symbolic links instead of copying
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY
-T, --no-target-directory treat DEST as a normal file
-u, --update copy only when the SOURCE file is newer
than the destination file or when the
destination file is missing
-v, --verbose explain what is being done
-x, --one-file-system stay on this file system
--help display this help and exit
--version output version information and exit
예시
hanjoong@ubuntu:~/apache-activemq-5.14.3$ cp -b activemq-all-5.14.3.jar test.jar
hanjoong@ubuntu:~/apache-activemq-5.14.3$ ls -la
total 47572
drwxrwxrwx 10 root root 4096 Feb 26 10:40 .
drwxr-xr-x 6 hanjoong hanjoong 4096 Jan 25 01:05 ..
-rwxrwxrwx 1 root root 16207404 Dec 19 07:39 activemq-all-5.14.3.jar
drwxr-xr-x 5 root root 4096 May 5 2016 bin
drwxr-xr-x 2 root root 4096 May 5 2016 conf
drwxr-xr-x 3 root root 4096 May 5 2016 data
drwxr-xr-x 2 root root 4096 May 5 2016 docs
drwxr-xr-x 7 root root 4096 Dec 19 07:41 examples
drwxr-xr-x 6 root root 4096 May 5 2016 lib
-rw-r--r-- 1 root root 40580 Dec 19 07:41 LICENSE
-rw-r--r-- 1 root root 3334 Dec 19 07:41 NOTICE
-rw-r--r-- 1 root root 2610 Dec 19 07:41 README.txt
-rwxrwxr-x 1 hanjoong hanjoong 16207404 Feb 26 10:40 test.jar
-rwxrwxr-x 1 hanjoong hanjoong 16207404 Feb 26 10:40 test.jar~
drwxr-xr-x 6 root root 4096 May 5 2016 webapps
drwxr-xr-x 3 root root 4096 May 5 2016 webapps-demo
hanjoong@ubuntu:~/apache-activemq-5.14.3$
1.6. mv
옵션
Usage: mv [OPTION]... [-T] SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-f, --force do not prompt before overwriting
-i, --interactive prompt before overwrite
-n, --no-clobber do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY
-T, --no-target-directory treat DEST as a normal file
-u, --update move only when the SOURCE file is newer
than the destination file or when the
destination file is missing
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:
none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups
1.7. rm
옵션
Remove (unlink) the FILE(s).
-f, --force ignore nonexistent files and arguments, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or
when removing recursively. Less intrusive than -i,
while still giving protection against most mistakes
--interactive[=WHEN] prompt according to WHEN: never, once (-I), or
always (-i). Without WHEN, prompt always
--one-file-system when removing a hierarchy recursively, skip any
directory that is on a file system different from
that of the corresponding command line argument
--no-preserve-root do not treat '/' specially
--preserve-root do not remove '/' (default)
-r, -R, --recursive remove directories and their contents recursively
-d, --dir remove empty directories
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit
By default, rm does not remove directories. Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.
To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
rm -- -foo
rm ./-foo
1.8. chmod
옵션
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that of RFILE.
-c, --changes like verbose but report only when a change is made
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
예시
hanjoong@ubuntu:~/test$ ls -la
total 12
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 10:49 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
-rw-rw-rw- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$ chmod o-r,o-w *
hanjoong@ubuntu:~/test$ ls -la
total 12
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 10:49 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$
1.9. gzip
옵션
Compress or uncompress FILEs (by default, compress FILES in-place).
Mandatory arguments to long options are mandatory for short options too.
-c, --stdout write on standard output, keep original files unchanged
-d, --decompress decompress
-f, --force force overwrite of output file and compress links
-h, --help give this help
-k, --keep keep (don't delete) input files
-l, --list list compressed file contents
-L, --license display software license
-n, --no-name do not save or restore the original name and time stamp
-N, --name save or restore the original name and time stamp
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories
-S, --suffix=SUF use suffix SUF on compressed files
-t, --test test compressed file integrity
-v, --verbose verbose mode
-V, --version display version number
-1, --fast compress faster
-9, --best compress better
--rsyncable Make rsync-friendly archive
With no FILE, or when FILE is -, read standard input.
예시
hanjoong@ubuntu:~/test$ ls -la
total 32
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:04 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data01
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data05
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$ gzip data01
hanjoong@ubuntu:~/test$ ls -la
total 32
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:08 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
-rw-rw---- 1 hanjoong hanjoong 33 Feb 26 10:57 data01.gz
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data05
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$ gzip -d data01.gz
hanjoong@ubuntu:~/test$ ls -la
total 32
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:08 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data01
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data05
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$
1.10. tar
옵션
Usage: tar [OPTION...] [FILE]...
GNU 'tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.
Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
Main operation mode:
-A, --catenate, --concatenate append tar files to an archive
-c, --create create a new archive
-d, --diff, --compare find differences between archive and file system
--delete delete from the archive (not on mag tapes!)
-r, --append append files to the end of an archive
-t, --list list the contents of an archive
--test-label test the archive volume label and exit
-u, --update only append files newer than copy in archive
-x, --extract, --get extract files from an archive
Operation modifiers:
--check-device check device numbers when creating incremental
archives (default)
-g, --listed-incremental=FILE handle new GNU-format incremental backup
-G, --incremental handle old GNU-format incremental backup
--ignore-failed-read do not exit with nonzero on unreadable files
--level=NUMBER dump level for created listed-incremental archive
-n, --seek archive is seekable
--no-check-device do not check device numbers when creating
incremental archives
--no-seek archive is not seekable
--occurrence[=NUMBER] process only the NUMBERth occurrence of each file
in the archive; this option is valid only in
conjunction with one of the subcommands --delete,
--diff, --extract or --list and when a list of
files is given either on the command line or via
the -T option; NUMBER defaults to 1
--sparse-version=MAJOR[.MINOR]
set version of the sparse format to use (implies
--sparse)
-S, --sparse handle sparse files efficiently
Overwrite control:
-k, --keep-old-files don't replace existing files when extracting,
treat them as errors
--keep-directory-symlink preserve existing symlinks to directories when
extracting
--keep-newer-files don't replace existing files that are newer than
their archive copies
--no-overwrite-dir preserve metadata of existing directories
--overwrite overwrite existing files when extracting
--overwrite-dir overwrite metadata of existing directories when
extracting (default)
--recursive-unlink empty hierarchies prior to extracting directory
--remove-files remove files after adding them to the archive
--skip-old-files don't replace existing files when extracting,
silently skip over them
-U, --unlink-first remove each file prior to extracting over it
-W, --verify attempt to verify the archive after writing it
Select output stream:
--ignore-command-error ignore exit codes of children
--no-ignore-command-error treat non-zero exit codes of children as
error
-O, --to-stdout extract files to standard output
--to-command=COMMAND pipe extracted files to another program
Handling of file attributes:
--atime-preserve[=METHOD] preserve access times on dumped files, either
by restoring the times after reading
(METHOD='replace'; default) or by not setting the
times in the first place (METHOD='system')
--delay-directory-restore delay setting modification times and
permissions of extracted directories until the end
of extraction
--group=NAME force NAME as group for added files
--mode=CHANGES force (symbolic) mode CHANGES for added files
--mtime=DATE-OR-FILE set mtime for added files from DATE-OR-FILE
-m, --touch don't extract file modified time
--no-delay-directory-restore
cancel the effect of --delay-directory-restore
option
--no-same-owner extract files as yourself (default for ordinary
users)
--no-same-permissions apply the user's umask when extracting permissions
from the archive (default for ordinary users)
--numeric-owner always use numbers for user/group names
--owner=NAME force NAME as owner for added files
-p, --preserve-permissions, --same-permissions
extract information about file permissions
(default for superuser)
--preserve same as both -p and -s
--same-owner try extracting files with the same ownership as
exists in the archive (default for superuser)
-s, --preserve-order, --same-order
member arguments are listed in the same order as
the files in the archive
Handling of extended file attributes:
--acls Enable the POSIX ACLs support
--no-acls Disable the POSIX ACLs support
--no-selinux Disable the SELinux context support
--no-xattrs Disable extended attributes support
--selinux Enable the SELinux context support
--xattrs Enable extended attributes support
--xattrs-exclude=MASK specify the exclude pattern for xattr keys
--xattrs-include=MASK specify the include pattern for xattr keys
Device selection and switching:
-f, --file=ARCHIVE use archive file or device ARCHIVE
--force-local archive file is local even if it has a colon
-F, --info-script=NAME, --new-volume-script=NAME
run script at end of each tape (implies -M)
-L, --tape-length=NUMBER change tape after writing NUMBER x 1024 bytes
-M, --multi-volume create/list/extract multi-volume archive
--rmt-command=COMMAND use given rmt COMMAND instead of rmt
--rsh-command=COMMAND use remote COMMAND instead of rsh
--volno-file=FILE use/update the volume number in FILE
Device blocking:
-b, --blocking-factor=BLOCKS BLOCKS x 512 bytes per record
-B, --read-full-records reblock as we read (for 4.2BSD pipes)
-i, --ignore-zeros ignore zeroed blocks in archive (means EOF)
--record-size=NUMBER NUMBER of bytes per record, multiple of 512
Archive format selection:
-H, --format=FORMAT create archive of the given format
FORMAT is one of the following:
gnu GNU tar 1.13.x format
oldgnu GNU format as per tar <= 1.12
pax POSIX 1003.1-2001 (pax) format
posix same as pax
ustar POSIX 1003.1-1988 (ustar) format
v7 old V7 tar format
--old-archive, --portability
same as --format=v7
--pax-option=keyword[[:]=value][,keyword[[:]=value]]...
control pax keywords
--posix same as --format=posix
-V, --label=TEXT create archive with volume name TEXT; at
list/extract time, use TEXT as a globbing pattern
for volume name
Compression options:
-a, --auto-compress use archive suffix to determine the compression
program
-I, --use-compress-program=PROG
filter through PROG (must accept -d)
-j, --bzip2 filter the archive through bzip2
-J, --xz filter the archive through xz
--lzip filter the archive through lzip
--lzma filter the archive through xz
--lzop
--no-auto-compress do not use archive suffix to determine the
compression program
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-Z, --compress, --uncompress filter the archive through compress
Local file selection:
--add-file=FILE add given FILE to the archive (useful if its name
starts with a dash)
--backup[=CONTROL] backup before removal, choose version CONTROL
-C, --directory=DIR change to directory DIR
--exclude=PATTERN exclude files, given as a PATTERN
--exclude-backups exclude backup and lock files
--exclude-caches exclude contents of directories containing
CACHEDIR.TAG, except for the tag file itself
--exclude-caches-all exclude directories containing CACHEDIR.TAG
--exclude-caches-under exclude everything under directories containing
CACHEDIR.TAG
--exclude-tag=FILE exclude contents of directories containing FILE,
except for FILE itself
--exclude-tag-all=FILE exclude directories containing FILE
--exclude-tag-under=FILE exclude everything under directories
containing FILE
--exclude-vcs exclude version control system directories
-h, --dereference follow symlinks; archive and dump the files they
point to
--hard-dereference follow hard links; archive and dump the files they
refer to
-K, --starting-file=MEMBER-NAME
begin at member MEMBER-NAME when reading the
archive
--newer-mtime=DATE compare date and time when data changed only
--no-null disable the effect of the previous --null option
--no-recursion avoid descending automatically in directories
--no-unquote do not unquote filenames read with -T
--null -T reads null-terminated names, disable -C
-N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
only store files newer than DATE-OR-FILE
--one-file-system stay in local file system when creating archive
-P, --absolute-names don't strip leading '/'s from file names
--recursion recurse into directories (default)
--suffix=STRING backup before removal, override usual suffix ('~'
unless overridden by environment variable
SIMPLE_BACKUP_SUFFIX)
-T, --files-from=FILE get names to extract or create from FILE
--unquote unquote filenames read with -T (default)
-X, --exclude-from=FILE exclude patterns listed in FILE
File name transformations:
--strip-components=NUMBER strip NUMBER leading components from file
names on extraction
--transform=EXPRESSION, --xform=EXPRESSION
use sed replace EXPRESSION to transform file
names
File name matching options (affect both exclude and include patterns):
--anchored patterns match file name start
--ignore-case ignore case
--no-anchored patterns match after any '/' (default for
exclusion)
--no-ignore-case case sensitive matching (default)
--no-wildcards verbatim string matching
--no-wildcards-match-slash wildcards do not match '/'
--wildcards use wildcards (default for exclusion)
--wildcards-match-slash wildcards match '/' (default for exclusion)
Informative output:
--checkpoint[=NUMBER] display progress messages every NUMBERth record
(default 10)
--checkpoint-action=ACTION execute ACTION on each checkpoint
--full-time print file time to its full resolution
--index-file=FILE send verbose output to FILE
-l, --check-links print a message if not all links are dumped
--no-quote-chars=STRING disable quoting for characters from STRING
--quote-chars=STRING additionally quote characters from STRING
--quoting-style=STYLE set name quoting style; see below for valid STYLE
values
-R, --block-number show block number within archive with each message
--show-defaults show tar defaults
--show-omitted-dirs when listing or extracting, list each directory
that does not match search criteria
--show-snapshot-field-ranges
show valid ranges for snapshot-file fields
--show-transformed-names, --show-stored-names
show file or archive names after transformation
--totals[=SIGNAL] print total bytes after processing the archive;
with an argument - print total bytes when this
SIGNAL is delivered; Allowed signals are: SIGHUP,
SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; the names
without SIG prefix are also accepted
--utc print file modification times in UTC
-v, --verbose verbosely list files processed
--warning=KEYWORD warning control
-w, --interactive, --confirmation
ask for confirmation for every action
Compatibility options:
-o when creating, same as --old-archive; when
extracting, same as --no-same-owner
Other options:
-?, --help give this help list
--restrict disable use of some potentially harmful options
--usage give a short usage message
--version print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control may be set with --backup or VERSION_CONTROL, values are:
none, off never make backups
t, numbered make numbered backups
nil, existing numbered if numbered backups exist, simple otherwise
never, simple always make simple backups
Valid arguments for the --quoting-style option are:
literal
shell
shell-always
c
c-maybe
escape
locale
clocale
*This* tar defaults to:
--format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt
--rsh-command=/usr/bin/rsh
예시
hanjoong@ubuntu:~/test$ ls -la
total 16
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:26 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 pack
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$ tar -cvf pack.tar pack
pack/
pack/data05
pack/data03
pack/data02
pack/data01
pack/data04
hanjoong@ubuntu:~/test$ ls -la
total 28
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:27 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 pack
-rw-rw-r-- 1 hanjoong hanjoong 10240 Feb 26 11:27 pack.tar
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$ mv pack pack_bak
hanjoong@ubuntu:~/test$ tar -xvf pack.tar
pack/
pack/data05
pack/data03
pack/data02
pack/data01
pack/data04
hanjoong@ubuntu:~/test$ ls -la
total 32
drwxrwxr-x 4 hanjoong hanjoong 4096 Feb 26 11:28 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 pack
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 pack_bak
-rw-rw-r-- 1 hanjoong hanjoong 10240 Feb 26 11:27 pack.tar
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
hanjoong@ubuntu:~/test$
1.11 chown
옵션
Usage: chown [OPTION]... [OWNER][:[GROUP]] FILE...
or: chown [OPTION]... --reference=RFILE FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP.
With --reference, change the owner and group of each FILE to those of RFILE.
-c, --changes like verbose but report only when a change is made
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--dereference affect the referent of each symbolic link (this is
the default), rather than the symbolic link itself
-h, --no-dereference affect symbolic links instead of any referenced file
(useful only on systems that can change the
ownership of a symlink)
--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of each file only if
its current owner and/or group match those specified
here. Either may be omitted, in which case a match
is not required for the omitted attribute
--no-preserve-root do not treat '/' specially (the default)
--preserve-root fail to operate recursively on '/'
--reference=RFILE use RFILE's owner and group rather than
specifying OWNER:GROUP values
-R, --recursive operate on files and directories recursively
The following options modify how a hierarchy is traversed when the -R
option is also specified. If more than one is specified, only the final
one takes effect.
-H if a command line argument is a symbolic link
to a directory, traverse it
-L traverse every symbolic link to a directory
encountered
-P do not traverse any symbolic links (default)
--help display this help and exit
--version output version information and exit
Owner is unchanged if missing. Group is unchanged if missing, but changed
to login group if implied by a ':' following a symbolic OWNER.
OWNER and GROUP may be numeric as well as symbolic.
Examples:
chown root /u Change the owner of /u to "root".
chown root:staff /u Likewise, but also change its group to "staff".
chown -hR root /u Change the owner of /u and subfiles to "root".
예시
hanjoong@ubuntu:~/test$ ls -laR
.:
total 16
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:33 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
drwxrwxr-x 2 root hanjoong 4096 Feb 26 11:13 pack
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
./pack:
total 28
drwxrwxr-x 2 root hanjoong 4096 Feb 26 11:13 .
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:33 ..
-rw-rw---- 1 root hanjoong 6 Feb 26 10:57 data01
-rw-rw---- 1 root hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 root hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 root hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 root hanjoong 6 Feb 26 10:57 data05
hanjoong@ubuntu:~/test$ sudo chown -R hanjoong pack
hanjoong@ubuntu:~/test$ ls -laR
.:
total 16
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:33 .
drwxr-xr-x 7 hanjoong hanjoong 4096 Feb 26 10:48 ..
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 pack
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:49 test.txt
./pack:
total 28
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:13 .
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:33 ..
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data01
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data05
hanjoong@ubuntu:~/test$
1.12. find
옵션
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:
operators (decreasing precedence; -and is implicit where no others are given):
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2
EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2
positional options (always true): -daystart -follow -regextype
normal options (always true, specified before other expressions):
-depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
--version -xdev -ignore_readdir_race -noignore_readdir_race
tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
-nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
-readable -writable -executable
-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
-used N -user NAME -xtype [bcdpfls]
actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print
-fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
-exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
-execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;
예시
hanjoong@ubuntu:~$ find -name *data*
./test/pack/data05
./test/pack/data03
./test/pack/data02
./test/pack/data01
./test/pack/data04
./apache-activemq-5.14.3/data
./apache-activemq-5.14.3/data/kahadb/db.data
./apache-activemq-5.14.3/lib/optional/jackson-databind-2.6.3.jar
hanjoong@ubuntu:~$
1.13. ln
옵션
Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
or: ln [OPTION]... TARGET (2nd form)
or: ln [OPTION]... TARGET... DIRECTORY (3rd form)
or: ln [OPTION]... -t DIRECTORY TARGET... (4th form)
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
By default, each destination (name of new link) should not already exist.
When creating hard links, each TARGET must exist. Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent directory.
Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-d, -F, --directory allow the superuser to attempt to hard link
directories (note: will probably fail due to
system restrictions, even for the superuser)
-f, --force remove existing destination files
-i, --interactive prompt whether to remove destinations
-L, --logical dereference TARGETs that are symbolic links
-n, --no-dereference treat LINK_NAME as a normal file if
it is a symbolic link to a directory
-P, --physical make hard links directly to symbolic links
-r, --relative create symbolic links relative to link location
-s, --symbolic make symbolic links instead of hard links
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY specify the DIRECTORY in which to create
the links
-T, --no-target-directory treat LINK_NAME as a normal file always
-v, --verbose print name of each linked file
--help display this help and exit
--version output version information and exit
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:
none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups
Using -s ignores -L and -P. Otherwise, the last option specified controls
behavior when a TARGET is a symbolic link, defaulting to -P.
예시
hanjoong@ubuntu:~/test/pack$ ln /home/hanjoong/test/test.txt /home/hanjoong/test/pack/test_link.txt
hanjoong@ubuntu:~/test/pack$ ls -la
total 32
drwxrwxr-x 2 hanjoong hanjoong 4096 Feb 26 11:46 .
drwxrwxr-x 3 hanjoong hanjoong 4096 Feb 26 11:33 ..
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data01
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data02
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data03
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data04
-rw-rw---- 1 hanjoong hanjoong 6 Feb 26 10:57 data05
-rw-rw---- 2 hanjoong hanjoong 6 Feb 26 10:49 test_link.txt
hanjoong@ubuntu:~/test/pack$ cat test_link.txt
12345
hanjoong@ubuntu:~/test/pack$
1.14. grep
옵션
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
Regexp selection and interpretation:
-E, --extended-regexp PATTERN is an extended regular expression (ERE)
-F, --fixed-strings PATTERN is a set of newline-separated fixed strings
-G, --basic-regexp PATTERN is a basic regular expression (BRE)
-P, --perl-regexp PATTERN is a Perl regular expression
-e, --regexp=PATTERN use PATTERN for matching
-f, --file=FILE obtain PATTERN from FILE
-i, --ignore-case ignore case distinctions
-w, --word-regexp force PATTERN to match only whole words
-x, --line-regexp force PATTERN to match only whole lines
-z, --null-data a data line ends in 0 byte, not newline
Miscellaneous:
-s, --no-messages suppress error messages
-v, --invert-match select non-matching lines
-V, --version print version information and exit
--help display this help and exit
--mmap deprecated no-op; evokes a warning
Output control:
-m, --max-count=NUM stop after NUM matches
-b, --byte-offset print the byte offset with output lines
-n, --line-number print line number with output lines
--line-buffered flush output on every line
-H, --with-filename print the file name for each match
-h, --no-filename suppress the file name prefix on output
--label=LABEL use LABEL as the standard input file name prefix
-o, --only-matching show only the part of a line matching PATTERN
-q, --quiet, --silent suppress all normal output
--binary-files=TYPE assume that binary files are TYPE;
TYPE is 'binary', 'text', or 'without-match'
-a, --text equivalent to --binary-files=text
-I equivalent to --binary-files=without-match
-d, --directories=ACTION how to handle directories;
ACTION is 'read', 'recurse', or 'skip'
-D, --devices=ACTION how to handle devices, FIFOs and sockets;
ACTION is 'read' or 'skip'
-r, --recursive like --directories=recurse
-R, --dereference-recursive likewise, but follow all symlinks
--include=FILE_PATTERN search only files that match FILE_PATTERN
--exclude=FILE_PATTERN skip files and directories matching FILE_PATTERN
--exclude-from=FILE skip files matching any file pattern from FILE
--exclude-dir=PATTERN directories that match PATTERN will be skipped.
-L, --files-without-match print only names of FILEs containing no match
-l, --files-with-matches print only names of FILEs containing matches
-c, --count print only a count of matching lines per FILE
-T, --initial-tab make tabs line up (if needed)
-Z, --null print 0 byte after FILE name
Context control:
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
-NUM same as --context=NUM
--color[=WHEN],
--colour[=WHEN] use markers to highlight the matching strings;
WHEN is 'always', 'never', or 'auto'
-U, --binary do not strip CR characters at EOL (MSDOS/Windows)
-u, --unix-byte-offsets report offsets as if CRs were not there
(MSDOS/Windows)
예시
hanjoong@ubuntu:~$ grep if .profile
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
hanjoong@ubuntu:~$ grep -c if .profile
7
hanjoong@ubuntu:~$