본문 바로가기
컴퓨터 활용(한글, 오피스 등)/50_2.운영체제_리눅스

리눅스_ 명령어

by 3604 2022. 11. 22.
728x90

Linux zip/unzip 으로 압축하고 해제하기

 

zip

zip 은 여러 파일을 묶고 압축할 수 있는 유틸리티로 tar 와는 달리 아카이빙과 압축을 같이 할 수 있습니다. 

하위 디렉터리 압축

하위 디렉터리를 포함하는 압축 옵션인 -r 을 사용해서 compressed.zip 파일에 /path/to/dir 내용을 압축합니다.

zip -r compressed.zip /path/to/dir
 
 

여러 소스 압축

dir1, dir2, file3 세 개의 소스를 압축합니다.

zip -r compressed.zip /path/to/dir1 /path/to/dir2 /path/to/file3
 

zip 에 내용 추가

이미 존재하는 zip 파일에 새로운 파일 추가합니다.

zip compressed.zip path/to/file
 
 

특정 폴더 제외

특정 폴더를 제외하려면 -x 옵션을 사용하며 아래는 .git 폴더는 빼고 압축합니다. (.git 앞뒤에 

 이 있는걸 주의하세요)

zip -9 -r compressed.zip /path/to/dir -x '*.git*'
 
 

unzip

unzip  zip 으로 압축된 파일을 푸는 명령어입니다.

압축내 목록 보기

압축을 해제(❌)하지 않고 압축 파일내의 목록만 출력합니다.

unzip -l compressed.zip 
 
 

압축 해제

현재 폴더에 압축 해제합니다.

unzip compressed.zip 
 
 

특정 폴더에 해제

압축이 풀릴 대상을 지정하는 -d 옵션을 사용하면 원하는 폴더에 압축을 해제할 수 있습니다.

unzip compressed.zip  -d /path/to/put
 
 

여러 파일 압축 해제

unzip 은 file globing 을 제대로 지원하지 않아서 다음과 같이 사용할 수가 없습니다.

unzip *.zip  -d /path/to/put
 

 

여러 파일 압축 해제가 필요할 경우 bash 의 for 함수를 이용해서 간단하게 처리할 수 있습니다.

for i in *.zip; do unzip $i -d /path/to/put;done
 
 

주요 옵션

zip

  • -r  : 디렉터리까지 압축
  • -1: 빠른 압축(압축률 ⬇)
  • -9: 높은 압축률 (속도 ⬇)
  • -e: zip 파일에 암호 설정
  • -x: 압축시 파일 제외

unzip

  • -d: 지정한 디렉터리에 압축 해제
  • -l: 압축 파일내 목록 보기

 

[Linux] alien 명령어 (feat. 확장자 변환 .rpm > .deb)

 

0. 들어가면서Permalink

최근 우분투에서 .rpm 확장자 파일을 다운받아 .deb 확장자 파일로 변환하여 특정 소프트웨어를 설치하였습니다. 저는 주로 우분투를 사용하였기에 .rpm 확장자를 가지는 파일은 처음 보았습니다. 관련된 내용을 정리해둬야겠습니다.

1. .rpm 파일Permalink

  • 레드햇 패키지 매니저(Redhat Package Manager) 프로그램이 관리하는 파일 형식입니다.
  • .rpm 확장자는 레드햇(Redhat) 계열 리눅스의 패키지 매니저가 관리하는 파일 형식입니다.
  • rpm 명령어에 의해 설치, 업데이트, 삭제 그리고 정보 제공이 이뤄집니다.

레드햇(Redhat) 계열 리눅스Permalink

  • Red Hat Linux
  • Fedora
  • CentOS

2. .deb 파일Permalink

  • 데비안(Debian) 계열 리눅스의 소프트웨어 패키지 포맷의 확장자입니다.
  • .deb 확장자는 데비안 계열 리눅스의 패키지 매니저가 사용하는 파일 형식입니다.
  • dpkg 명령어에 의해 설치, 삭제 그리고 정보 제공이 이뤄집니다.

데비안(Debian) 계열 리눅스Permalink

  • Debian
  • Ubuntu
  • Linux Mint

3. alien 명령어Permalink

우분투에서 .rpm 파일을 직접 사용할 수 없으니 변환 작업이 필요합니다. alien 명령어 설치 방법부터 사용 예시까지 정리해보겠습니다.

3.1. 설치Permalink

패키지 최신화Permalink

$ sudo apt-get update
$ sudo apt-get upgrade

alien 설치Permalink

$ sudo apt install alien

3.2. 명령어 살펴보기Permalink

$ alien -h
Usage: alien [options] file [...]
  file [...]                Package file or files to convert.
  -d, --to-deb              Generate a Debian deb package (default).
     Enables these options:
       --patch=<patch>      Specify patch file to use instead of automatically
                            looking for patch in /var/lib/alien.
       --nopatch	        Do not use patches.
       --anypatch           Use even old version os patches.
       -s, --single         Like --generate, but do not create .orig
                            directory.
       --fixperms           Munge/fix permissions and owners.
       --test               Test generated packages with lintian.
  -r, --to-rpm              Generate a Red Hat rpm package.
      --to-slp              Generate a Stampede slp package.
  -l, --to-lsb              Generate a LSB package.
  -t, --to-tgz              Generate a Slackware tgz package.
     Enables these options:
       --description=<desc> Specify package description.
       --version=<version>  Specify package version.
  -p, --to-pkg              Generate a Solaris pkg package.
  -i, --install             Install generated package.
  -g, --generate            Generate build tree, but do not build package.
  -c, --scripts             Include scripts in package.
      --target=<arch>       Set architecture of the generated package.
  -v, --verbose             Display each command alien runs.
      --veryverbose         Be verbose, and also display output of run commands.
  -k, --keep-version        Do not change version of generated package.
      --bump=number         Increment package version by this number.
  -h, --help                Display this help message.
  -V, --version		        Display alien's version number.

3.3. 명령어 사용Permalink

3.3.1. 변경 전 디렉토리Permalink

~/Downloads$ ls
galera-4-26.4.9-1.el8.x86_64.rpm

3.3.2. 명령어 수행Permalink

  • .rpm 파일을 .deb 파일로 변경하는 -d 옵션을 사용합니다.
  • --scripts 옵션으로 패키지 내 스크립트도 함께 포함시킵니다.
  • warning의 원인과 해결 방법에 대해서 확인 중 입니다.
~/Downloads$ sudo alien --scripts -d galera-4-26.4.9-1.el8.x86_64.rpm 
warning: galera-4-26.4.9-1.el8.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
warning: galera-4-26.4.9-1.el8.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
...
galera-4_26.4.9-2_amd64.deb generated

3.3.3. 변경 전 디렉토리Permalink

~/Downloads$ ls
galera-4-26.4.9-1.el8.x86_64.rpm  galera-4_26.4.9-2_amd64.deb

CLOSINGPermalink

개발을 진행하다보면 리눅스 명령어를 자주 사용하게 되는데 관련 명령어를 정리한 적이 없습니다. 매번 인터넷에서 찾다보니 예전에 참고했던 내용을 다시 못 찾는 경우도 허다합니다. 오늘부터라도 블로그에 기록해두고 찾아서 사용해야겠습니다.

REFERENCEPermalink

 

How To Install glibc-tools on Ubuntu 22.04

In this tutorial we learn how to install glibc-tools on Ubuntu 22.04. glibc-tools is Tools and libraries that used to be part of glibc

Introduction

In this tutorial we learn how to install glibc-tools on Ubuntu 22.04.

What is glibc-tools

glibc-tools is:

This package contains tools and library formerly provided by glibc that either have been deprecated or moved out from the project.

Currently it contains:

  • The ’libSigSegv’ library.
  • The ‘catchsegv’ script.

There are three ways to install glibc-tools on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install glibc-tools Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update
Copy

After updating apt database, We can install glibc-tools using apt-get by running the following command:

sudo apt-get -y install glibc-tools
Copy

Install glibc-tools Using apt

Update apt database with apt using the following command.

sudo apt update
Copy

After updating apt database, We can install glibc-tools using apt by running the following command:

sudo apt -y install glibc-tools
Copy

Install glibc-tools Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update
Copy

After updating apt database, We can install glibc-tools using aptitude by running the following command:

sudo aptitude -y install glibc-tools
Copy

How To Uninstall glibc-tools on Ubuntu 22.04

To uninstall only the glibc-tools package we can use the following command:

sudo apt-get remove glibc-tools
Copy

Uninstall glibc-tools And Its Dependencies

To uninstall glibc-tools and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove glibc-tools
Copy

Remove glibc-tools Configurations and Data

To remove glibc-tools configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge glibc-tools
Copy

Remove glibc-tools configuration, data, and all of its dependencies

We can use the following command to remove glibc-tools configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge glibc-tools
Copy

References

Summary

In this tutorial we learn how to install glibc-tools package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.

 

참고

1. zip unzip  https://www.lesstif.com/lpt/linux-zip-unzip-80248839.html

 

Linux zip/unzip 으로 압축하고 해제하기

 

www.lesstif.com

2. alien https://junhyunny.github.io/information/linux/linux-alien/

728x90