리눅스 명령어 개요 및 도움말

주영·2023년 9월 11일
1

Linux Master

목록 보기
7/11
post-thumbnail

리눅스 명령어 개요

which 명령어

  • 명령어의 경로를 확인하는 명령어
  • 명령어의 위치($PATH가 설정되어있는 경로에서만 그 명령어의 경로를 찾음)를 찾아주거나 alias를 보여주는 명령어
  • 예시)
    [root@master1 ~]# which ls
    alias ls='ls --color=auto'
          /usr/bin/ls

alias 명령어

  • 자주 사용하는 명령어를 특정 문자로 입력해두고, 명령어 대신 해당 문자를 사용할 수 있게 하는 명령어
  • $ alias 별명='명령어'
  • ex) $ alias m='ls -al | more'

unalias 명령어

  • alias 기능 해제
  • $ unalias 별명
  • ex) $ unalias m

환경변수 PATH

  • PATH : 실행 파일들의 디렉터리 위치를 저장해놓는 환경변수
  • 특정 명령어를 입력 → PATH 변수에 저장되어 있는 경로에서 해당 명령어를 찾아서 실행
  • $ echo $PATH : 지정된 PATH 값 확인 가능
  • $ PATH=$PATH: /dev : 추가
  • 기존의 PATH에 새로운 경로를 추가하는 방법 : 명령어 PATH나 홈 디렉터리의 .bash_profile에 PATH 추가
  • 기존 경로와 새 경로는 ' : ' 으로 구분

리눅스 도움말

man 명령어

  • 리눅스에서 사용하는 명령어들의 매뉴얼(manual) 제공

  • 예시) $ man ls

    # man ls
    LS(1)                           User Commands                           LS(1)
    
    NAME
           ls - list directory contents
    
    SYNOPSIS
           ls [OPTION]... [FILE]...
    
    DESCRIPTION
           List  information  about the FILEs (the current directory by default).
           Sort entries alphabetically if none of -cftuvSUX nor --sort is  speci‐
           fied.
    
           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 ..
    ...

info 명령어

  • 리눅스 명령어의 사용 방법, 옵션 등을 나타냄

  • man보다 상세화된 매뉴얼

  • 예시) $ info ls

    # info ls
    Next: dir invocation,  Up: Directory listing
    
    10.1 ‘ls’: List directory contents
    ==================================
    
    The ‘ls’ program lists information about files (of any type, including
    directories).  Options and file arguments can be intermixed arbitrarily,
    as usual.
    
       For non-option command-line arguments that are directories, by
    default ‘ls’ lists the contents of directories, not recursively, and
    omitting files with names beginning with ‘..  For other non-option
    arguments, by default ‘ls’ lists just the file name.  If no non-option
    argument is specified, ‘ls’ operates on the current directory, acting as
    if it had been invoked with a single argument of ‘..
    
       By default, the output is sorted alphabetically, according to the
    locale settings in effect.(1)  If standard output is a terminal, the
    output is in columns (sorted vertically) and control characters are
    output as question marks; otherwise, the output is listed one per line
    and control characters are output as-is.
    
       Because ‘ls’ is such a fundamental program, it has accumulated many
    options over the years.  They are described in the subsections below;
    within each section, options are listed alphabetically (ignoring case).
    The division of options into the subsections is not absolute, since some
    options affect more than one aspect of ‘ls’’s operation.
    
       Exit status:
    
         0 success
    ...

whatis 명령어

  • 명령어에 대한 기능을 간략하게 나타냄
  • whatis 데이터베이스에서 문자열만 검색하여 명령어의 기능을 간략하게 출력
  • 완전히 키워드가 일치해야만 해당 명령어의 기능 확인 가능
  • 예시) $ whatis ls
    # whatis ls
    ls (1)               - list directory contents
    ls (1p)              - list directory contents

manpath 명령어

  • man 명령어가 참조하는 매뉴얼 페이지의 위치 경로 표시
    # manpath
    /usr/local/share/man:/usr/share/man

whereis 명령어

  • 명령어의 바이너리(실행파일), 소스파일, 매뉴얼 파일의 위치 정보 출력
  • 예시) $ whereis ls
    # whereis ls
    ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

apropos 명령어

  • 명령어나 매뉴얼 페이지에 검색어가 들어있는 모든 명령어 출력
  • 과정 : whatis 데이터베이스에서 검색어를 포함한 것을 검색하여 출력
    = $ man -k
  • 예시 1) $ apropos floppy
    # apropos floppy
    fd (4)               - floppy disk device
    fdformat (8)         - low-level format a floppy disk
    mbadblocks (1)       - tests a floppy disk, and marks the bad blocks in the FAT
    mformat (1)          - add an MSDOS filesystem to a low-level formatted floppy disk
  • 예시 2) $ apropos system | grep ^system
    # apropos system | grep ^system
    system (3)           - execute a shell command
    system (3p)          - issue a command
    system-auth (5)      - Common configuration file for PAMified services
    system.conf.d (5)    - System and session service manager configuration files
    systemctl (1)        - Control the systemd system and service manager
    systemd (1)          - systemd system and service manager
    systemd-analyze (1)  - Analyze and debug system manager
    systemd-ask-password (1) - Query the user for a system password
    systemd-ask-password-console.path (8) - Query the user for system passwords on the console and via wall
    systemd-ask-password-console.service (8) - Query the user for system passwords on the console and via wall
    ...

0개의 댓글

관련 채용 정보