티스토리 뷰

Others

[우분투] 설치 후 주요명령어

해구름 2020. 11. 22. 04:36
반응형

최초 설치 후 접속

- 아이디/패스워드: ubuntu/ubuntu
- 화면 지우기: clear
- 디렉터리 나열: ls (-l 옵션: 소유자, 파일크기 등 상세정보 출력, -a 옵션: 숨김파일 출력)
- 디렉터리 이동: cd 디렉터리명
- 관리자 권한 전환: sudo -su

인터넷 연결확인

유선으로 연결된 경우 별도 설정 없이 바로 인터넷에 연결되며, 연결이 정상적인지 확인하기 위해 ping 명령어를 사용함

예를들어 공유기로 IP를 날려보자
- 예시) ping -c 5 192.168.0.1
- 설명) ping -c 요청수 대상IP(또는 도메인)

만약 WIFI를 사용하고 있다면, 인터넷 설정 파일(/etc/netplan의 yaml 파일)을 직접 편집해야함

인터넷 아이피 주소확인

로컬IP: ip addr 또는 ifconfig
공용IP: curl ifconfig.me

열린 포트확인

netstat 명령어를 사용하며, 로컬에 활성화된 네트워크 연결을 표시함

  1. 먼저 net-tools가 설치되어 있어야 netstat명령어를사용할 수 있음
    1. 설치확인
      dpkg -l | grep net-tools
    2. net-tools 설치 명령어
      apt install net-tools
  2. 아래 명령어는 현재 열려있는 포트를 출력
    netstat -ntlp
  3. netstat 명령어의 상세 옵션은 다음과 같음
    root@ubuntu:/home/ubuntu# netstat --help
    usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
           netstat [-vWnNcaeol] [<Socket> ...]
           netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }
    
            -r, --route              display routing table
            -i, --interfaces         display interface table
            -g, --groups             display multicast group memberships
            -s, --statistics         display networking statistics (like SNMP)
            -M, --masquerade         display masqueraded connections
    
            -v, --verbose            be verbose
            -W, --wide               don't truncate IP addresses
            -n, --numeric            don't resolve names
            --numeric-hosts          don't resolve host names
            --numeric-ports          don't resolve port names
            --numeric-users          don't resolve user names
            -N, --symbolic           resolve hardware names
            -e, --extend             display other/more information
            -p, --programs           display PID/Program name for sockets
            -o, --timers             display timers
            -c, --continuous         continuous listing
    
            -l, --listening          display listening server sockets
            -a, --all                display all sockets (default: connected)
            -F, --fib                display Forwarding Information Base (default)
            -C, --cache              display routing cache instead of FIB
            -Z, --context            display SELinux security context for sockets
    
      <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}
               {-x|--unix} --ax25 --ipx --netrom
      <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet
      List of possible address families (which support routing):
        inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
        netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)
        x25 (CCITT X.25)

윈도우에서 ssh로 접속

  1. 우분투에 openssh-server가 설치되어 있어야 함
    1. 설치여부 확인 (openssh-client, openssh-server, openssh-sftp-server 등이 나타나면 이미 설치됨)
      dpkg -l | grep ssh
    2. openssh-server 설치
      sudo apt-get install openssh-server
    3. 설치가 완료되면 22번 포트가 열려있는지 확인
      netstat -ntlp
  2. 윈도우에서 명령프롬프트 등으로 ssh 접속
    예) ssh 계정명@IP주소

 

댓글