리눅스 / 명령어 / sftp

SFTP(SSH File Transfer Protocol)는 파일을 안전하게 전송하기 위해 SSH 프로토콜을 사용하는 명령어이다.

연결

# sftp root@192.168.3.202
  • 192.168.3.202에 root 계정으로 접속한다. root 게정의 사용자 디렉토리(/root)로 연결된다.
# sftp root@192.168.3.202:/temp
  • 192.168.3.202에 root 계정으로 접속한다. /temp 디렉토리로 연결된다.

연결 끊기

sftp> quit

업로드

sftp> put a.txt
  • a.txt 파일을 업로드한다.
sftp> put *.txt
  • 현재 로컬 디렉토리 안에 있는 모든 txt 파일을 업로드한다.
sftp> put -r abc
  • abc 디렉토리를 업로드한다.

다운로드

sftp> get a.txt
  • a.txt 파일을 다운로드한다.
sftp> get *.txt
  • 현재 원격 디렉토리 안에 있는 모든 txt 파일을 다운로드한다.
sftp> get -r abc
  • abc 디렉토리를 다운로드한다.

기타 명령어

보통 명령어는 원격 컴퓨터 기준이다. 로컬 컴퓨터 기준으로 명령하려면 명령어 앞에 l을 붙인다.

  • pwd : 원격 컴퓨터 현재 디렉토리
  • lpwd : 로컬 컴퓨터 현재 디렉토리
  • ls : 원격 컴퓨터 디렉토리와 파일 목록
  • lls : 로컬 컴퓨터 디렉토리와 파일 목록
  • cd : 원격 컴퓨터에서 디렉토리 변경
  • lcd : 로컬 컴퓨터에서 디렉토리 변경
같은 카테고리의 다른 글

리눅스 / 명령어 / history / 이전에 실행했던 명령어 목록 출력하는 명령어

history는 이전에 실행했던 명령어 목록 출력하는 명령어이다. history 이전에 실행했던 명령어 목록을 일련번호와 함께 출력한다. # history history n 최근 n개의 명령어 목록을 출력한다. 다음과 같이 명령하면 최근 실행한 10개의 명령어를 출력한다. # history 10 !! !!를 입력하고 엔터를 누르면 직전에 실행했던 명령어를 다시 실행한다. !n 일련번호가 n인 명령어를 실행한다. 다음과 같이 명령하면 번호가 202인 명령어를 실행한다. # !202

리눅스 / 게이트웨이(gateway) 확인하는 방법

리눅스에서 네트워크 정보는 주로 ifconfig, ip addr 명령어로 확인한다. 그런데, gateway 정보는 나오지 않는다. 만약 gateway 정보가 필요하다면 route 명령어를 사용한다. Ubuntu애서 명령어가 없다고 나오면 net-tools를 설치한다. apt install net-tools

리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기

명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용한다. which 명령어로 find 명령어를 찾는다. # which find /usr/bin/find whereis 명령어로 find 명령어를 찾는다. # whereis find find: /usr/bin/find /usr/share/man/man1/find.1.gz locate 명령어로 find 명령어를 찾는다. # locate find /usr/bin/find /usr/bin/find2perl /usr/bin/findmnt /usr/bin/nl-link-ifindex2name /usr/bin/nl-link-name2ifindex /usr/bin/oldfind /usr/lib64/python2.7/modulefinder.py /usr/lib64/python2.7/modulefinder.pyc /usr/lib64/python2.7/modulefinder.pyo /usr/sbin/btrfs-find-root /usr/sbin/findfs /usr/share/bash-completion/completions/findmnt /usr/share/doc/findutils-4.5.11 /usr/share/doc/findutils-4.5.11/AUTHORS /usr/share/doc/findutils-4.5.11/COPYING /usr/share/doc/findutils-4.5.11/ChangeLog /usr/share/doc/findutils-4.5.11/NEWS /usr/share/doc/findutils-4.5.11/README /usr/share/doc/findutils-4.5.11/THANKS /usr/share/doc/findutils-4.5.11/TODO /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_find.py /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_stop_find.py /usr/share/info/find-maint.info.gz /usr/share/info/find.info.gz /usr/share/locale/be/LC_MESSAGES/findutils.mo /usr/share/locale/bg/LC_MESSAGES/findutils.mo /usr/share/locale/ca/LC_MESSAGES/findutils.mo /usr/share/locale/cs/LC_MESSAGES/findutils.mo /usr/share/locale/da/LC_MESSAGES/findutils.mo /usr/share/locale/de/LC_MESSAGES/findutils.mo /usr/share/locale/el/LC_MESSAGES/findutils.mo /usr/share/locale/eo/LC_MESSAGES/findutils.mo /usr/share/locale/es/LC_MESSAGES/findutils.mo /usr/share/locale/et/LC_MESSAGES/findutils.mo /usr/share/locale/fi/LC_MESSAGES/findutils.mo /usr/share/locale/fr/LC_MESSAGES/findutils.mo /usr/share/locale/ga/LC_MESSAGES/findutils.mo /usr/share/locale/gl/LC_MESSAGES/findutils.mo /usr/share/locale/hr/LC_MESSAGES/findutils.mo /usr/share/locale/hu/LC_MESSAGES/findutils.mo /usr/share/locale/id/LC_MESSAGES/findutils.mo /usr/share/locale/it/LC_MESSAGES/findutils.mo /usr/share/locale/ja/LC_MESSAGES/findutils.mo /usr/share/locale/ko/LC_MESSAGES/findutils.mo /usr/share/locale/lg/LC_MESSAGES/findutils.mo /usr/share/locale/lt/LC_MESSAGES/findutils.mo /usr/share/locale/ms/LC_MESSAGES/findutils.mo /usr/share/locale/nl/LC_MESSAGES/findutils.mo /usr/share/locale/pl/LC_MESSAGES/findutils.mo /usr/share/locale/pt/LC_MESSAGES/findutils.mo /usr/share/locale/pt_BR/LC_MESSAGES/findutils.mo /usr/share/locale/ro/LC_MESSAGES/findutils.mo /usr/share/locale/ru/LC_MESSAGES/findutils.mo /usr/share/locale/rw/LC_MESSAGES/findutils.mo /usr/share/locale/sk/LC_MESSAGES/findutils.mo /usr/share/locale/sl/LC_MESSAGES/findutils.mo /usr/share/locale/sr/LC_MESSAGES/findutils.mo /usr/share/locale/sv/LC_MESSAGES/findutils.mo /usr/share/locale/tr/LC_MESSAGES/findutils.mo /usr/share/locale/uk/LC_MESSAGES/findutils.mo /usr/share/locale/vi/LC_MESSAGES/findutils.mo /usr/share/locale/zh_CN/LC_MESSAGES/findutils.mo /usr/share/locale/zh_TW/LC_MESSAGES/findutils.mo /usr/share/man/man1/find.1.gz /usr/share/man/man1/find2perl.1.gz /usr/share/man/man1/oldfind.1.gz /usr/share/man/man8/btrfs-find-root.8.gz /usr/share/man/man8/findfs.8.gz /usr/share/man/man8/findmnt.8.gz locate 명령어는 -n 옵션으로 출력 ...

리눅스 / 명령어 / mkdir / 디렉토리 만드는 명령어

mkdir은 make directory의 약자로, 디렉토리를 만드는 명령어이다. abc 디렉토리를 만든다. # mkdir abc abc 디렉토리 아래에 def 디렉토리를 만든다. 만약 abc 디렉토리가 없다면 def 디렉토리를 만들 수 없다는 메시지가 나온다. # mkdir abc/def p 옵션을 붙이면 abc 디렉토리가 없어도 abc 디렉토리를 만든 후에 def 디렉토리를 만든다. # mkdir -p abc/def 리눅스 / 명령어 / rm / 파일 ...

리눅스 / 명령어 / cp - 복사하는 명령어, mv - 이동하는 명령어

cp는 copy의 약자로 복사하는 명령어, mv는 move의 약자로 이동하는 명령어이다. 복사하기 abc.txt 파일을 def.txt로 이름을 바꾸어 복사한다. cp abc.txt def.txt xyz라는 디렉토리가 없다면 abc.txt 파일을 xyz 파일로 복사한다. xyz라는 디렉토리가 있다면 xyz 디렉토리 안에 abc.txt 파일을 복사한다. cp abc.txt xyz abc.txt 파일을 xyz 디렉토리 안에 def.txt라는 이름으로 복사한다. cp abc.txt xyz/def.txt abc가 디렉토리이고 xyz라는 디렉토리가 없다면, abc 디렉토리를 xyz로 ...

리눅스 / 명령어 / passwd / 사용자 암호 설정 명령어

사용자의 비밀번호 설정은 passwd 명령어로 한다. 비밀번호 만들기, 변경하기 사용자 jb의 비밀번호를 만들거나 변경한다. passwd jb 사용자을 적지 않으면 현재 로그인한 사용자의 비밀번호를 만들거나 변경한다. 비밀번호 삭제하기 사용자 jb의 비밀번호를 삭제한다. 사용자는 비밀번호 입력 없이 로그인 가능하다. passwd -d jb 비밀번호 잠그기, 잠금 풀기 사용자 jb를 잠근다. 즉, 사용자는 로그인하지 못한다. passwd -l jb 사용자 jb의 잠금을 푼다. passwd -u jb 비밀번호 만료시키기 사용자 ...

리눅스 / 그룹 / 그룹 조회, 그룹 추가, 그룹 삭제, 그룹 수정

그룹 조회 그룹 목록은 /et/group 파일에 있습니다. cat 명령어로 전체를 조회하거나... cat /etc/group tail 명령어로 마지막 부분을 조회할 수 있습니다. # tail -n 5 /etc/group avahi:x:70: slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: X:Y:Z 형식으로 나오는데, X는 그룹 이름, Y는 그룹 비밀번호, Z는 그룹 ID입니다. 그룹 추가 groupadd 명령으로 그룹을 추가합니다. # groupadd group-1 # tail -n 5 /etc/group slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: group-1:x:1000: 그룹 삭제 groupdel 명령으로 그룹을 삭제합니다. # ...

리눅스 / RAID / Linear RAID, RAID0, RAID1, RAID5, RAID6

RAID 뜻과 종류 RAID Redundant Array of Inexpensive Disk or Redundant Array of Independent Disk 여러 개의 하드디스크를 하나처럼 사용하게 하는 기술. 예를 들어 1TB 하드디스크 두 개를 묶어서 2TB 하드디스크처럼 사용할 수 있다. 크게 하드웨어 RAID와 소프트웨어 RAID로 구분할 수 있다. 하드웨어 RAID는 성능이 좋으나 비싸다. 소프트웨어 RAID는 운영체제에서 지원하는 것으로 OS RAID라고도 한다. Linear RAID 두 ...

리눅스 / 명령어 / rm / 파일 또는 디렉토리 삭제하는 명령어

rm은 remove의 약자로, 파일 또는 디렉토리를 삭제하는 명령어이다. 파일 삭제하기 abc.txt 파일을 삭제한다. 삭제할 건지 다시 묻는다. y 또는 yes를 입력하면 삭제한다. # rm abc.txt 확장자가 txt인 모든 파일을 삭제한다. 각 파일에 대해서 삭제할 건지 묻는다. # rm *.txt 현재 디렉토리에 있는 모든 파일을 삭제한다. 각 파일에 대해서 삭제할 건지 묻고, 디렉토리가 있다면 삭제할 수 없다는 ...

리눅스 / rsync / 동기화 프로그램

rsync는 동기화 프로그램이다. 백업할 때 유용하게 사용할 수 있다. 사용법 기본 abc 디렉토리 안의 def 디렉토리를 xyz 디렉토리 안에 동기화시킨다. 처음 실행하는 것이라면 xyz 디렉토리 안에 def 디렉토리가 복사된다. 다시 실행시키면 /abc/def 디렉토리의 내용 중 수정되거나 추가된 것만 /xyz/def 디렉토리로 복사된다. /abc/def에서 삭제된 내용은 /xyz/def에 반영되지 않는다. # rsync -avz /abc/def /xyz def 뒤에 /를 붙이면 def 디렉토리 ...