linux 로 서비스하니 tar.gz 로 압축해서 로그를 전달 받게 된다. 오랜만에 tar 를 써보니 파라미터가 생각나지 않아 메모해둔다.
$ tar --help
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.
$ ls
test2.txt
$ tar -cvf test2.tar test2.txt
test2.txt
$ ls
test2.tar test2.txt
생성할 때는 c 옵션을 사용하게 된다.
-c, --create create a new archive
-v, --verbose verbosely list files processed
-f, --file=ARCHIVE use archive file or device ARCHIVE
c : 생성 v : 진행중인 파일 표시 f : 파일로 저장
$ tar -czvf test2.tar.gz test2.txt
test2.txt
$ ls
test2.tar test2.tar.gz test2.txt
압축을 하고 싶다면 z 옵션을 사용하면 된다.
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
z : gzip 을 이용해 압축
$ tar -xvf test2.tar
test2.txt
묶인 파일 해제는 x 명령어를 사용한다.
$ tar -xzvf test2.tar.gz
test2.txt
gzip 으로 압축된 파일을 z 옵션을 추가해줘야 한다.
Main operation mode:
-A, --catenate, --concatenate append tar files to an archive
-c, --create create a new archive
--delete delete from the archive (not on mag tapes!)
-d, --diff, --compare find differences between archive and file system
-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
디스크 관리 프로그램에서 다른 파티션과 달리 오른쪽 메뉴도 없어서 볼륨 삭제와 같은 작업을 진행할 수 없다.
관리자 권한으로 명령 프롬프트를 실행해서 diskpart 명령어를 통해 해당 파티션을 삭제할 수 있다.
C:\Windows\System32>diskpart
Microsoft DiskPart 버전 10.0.22621.1
Copyright (C) Microsoft Corporation.
컴퓨터:
DISKPART> list disk
디스크 ### 상태 크기 사용 가능 Dyn Gpt
---------- ------------- ------- ------------ --- ---
디스크 0 온라인 465 GB 1024 KB
디스크 1 온라인 476 GB 0 B
디스크 2 온라인 931 GB 1024 KB
디스크 3 온라인 1863 GB 0 B * *
디스크 4 온라인 476 GB 2048 KB *
DISKPART> select disk 4
4 디스크가 선택한 디스크입니다.
작업할 파티션이 위치한 디스크를 select disk 를 통해 선택하자.
DISKPART> list partition
파티션 ### 종류 크기 오프셋
---------- ---------------- ------- -------
파티션 1 복구 450 MB 1024 KB
파티션 2 시스템 99 MB 451 MB
파티션 3 예약됨 16 MB 550 MB
파티션 4 주 475 GB 566 MB
파티션 5 복구 817 MB 476 GB
DISKPART> select partition 5
5 파티션이 선택한 파티션입니다.
~$ ln /mnt/x/test test
ln: /mnt/x/test: hard link not allowed for directory
~$ ln -s /mnt/x/test test
~$ ls
test
~$ cd test
~/test$ pwd
/home/userX/test
linux 에서 디렉토리를 연결시킬 때 ln 명령어를 사용한다.
~$ ln --help
Usage: ln [OPTION]... [-T] TARGET LINK_NAME
or: ln [OPTION]... TARGET
or: ln [OPTION]... TARGET... DIRECTORY
or: ln [OPTION]... -t DIRECTORY TARGET...
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.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report ln translation bugs to <https://translationproject.org/team/>
Full documentation at: <https://www.gnu.org/software/coreutils/ln>
or available locally via: info '(coreutils) ln invocation'
$ getconf -a | grep libc
GNU_LIBC_VERSION glibc 2.31
$ ldd --version
ldd (Ubuntu GLIBC 2.31-0ubuntu9.7) 2.31
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.