[linux]리눅스 기초 명령어 / Basic Linux Commands

리눅스 기초 명령어
리눅스는 명령어 기반으로 작동하는 운영체제입니다. 윈도우나 macOS와는 달리, 마우스 클릭 대신 명령어를 입력하여 작업을 수행합니다. 처음에는 낯설 수 있지만, 익숙해지면 빠르고 효율적인 작업이 가능합니다.

  1. 파일 및 디렉토리 관련 명령어
    ls (list)
    현재 디렉토리의 파일 및 디렉토리 목록을 보여줍니다.

ls: 현재 디렉토리의 파일 및 디렉토리 목록을 간략하게 보여줍니다.
ls -l: 파일 및 디렉토리의 상세 정보(권한, 소유자, 크기, 수정 날짜 등)를 함께 보여줍니다.
ls -a: 숨겨진 파일 및 디렉토리를 포함한 모든 목록을 보여줍니다.
ls -al: 위 두 옵션을 함께 사용하여 상세 정보와 숨겨진 파일을 모두 보여줍니다.
cd (change directory)
디렉토리를 변경합니다.

cd [디렉토리]: 지정된 디렉토리로 이동합니다.
cd ..: 상위 디렉토리로 이동합니다.
cd: 홈 디렉토리로 이동합니다.
pwd (print working directory)
현재 작업 중인 디렉토리의 경로를 보여줍니다.

mkdir (make directory)
새로운 디렉토리를 생성합니다.

mkdir [디렉토리]: 지정된 이름의 디렉토리를 생성합니다.
rmdir (remove directory)
빈 디렉토리를 삭제합니다.

rmdir [디렉토리]: 지정된 이름의 빈 디렉토리를 삭제합니다.
rm (remove)
파일 또는 디렉토리를 삭제합니다.

rm [파일]: 지정된 파일을 삭제합니다.
rm -r [디렉토리]: 지정된 디렉토리와 그 내용을 모두 삭제합니다. (주의: -r 옵션은 매우 강력하므로 신중하게 사용해야 합니다.)
cp (copy)
파일 또는 디렉토리를 복사합니다.

cp [원본 파일] [대상 파일]: 원본 파일을 대상 파일로 복사합니다.
cp -r [원본 디렉토리] [대상 디렉토리]: 원본 디렉토리를 대상 디렉토리로 복사합니다.
mv (move)
파일 또는 디렉토리를 이동하거나 이름을 변경합니다.

mv [원본 파일] [대상 파일]: 원본 파일을 대상 파일로 이동하거나 이름을 변경합니다.
mv [원본 디렉토리] [대상 디렉토리]: 원본 디렉토리를 대상 디렉토리로 이동합니다.

  1. 파일 내용 확인 및 편집 명령어
    cat (concatenate)
    파일 내용을 화면에 출력합니다.

cat [파일]: 지정된 파일의 내용을 화면에 출력합니다.
less
파일 내용을 페이지 단위로 끊어서 보여줍니다.

less [파일]: 지정된 파일의 내용을 페이지 단위로 보여줍니다. (Space 키로 다음 페이지, Q 키로 종료)
head
파일의 앞부분 내용을 보여줍니다.

head [파일]: 지정된 파일의 앞 10줄을 보여줍니다.
head -n [숫자] [파일]: 지정된 파일의 앞 [숫자] 줄을 보여줍니다.
tail
파일의 뒷부분 내용을 보여줍니다.

tail [파일]: 지정된 파일의 마지막 10줄을 보여줍니다.
tail -n [숫자] [파일]: 지정된 파일의 마지막 [숫자] 줄을 보여줍니다.
vi (visual editor)
텍스트 편집기입니다.

vi [파일]: 지정된 파일을 vi 편집기로 엽니다. (i 키로 입력 모드, Esc 키로 명령 모드, :wq로 저장 후 종료)

  1. 시스템 관리 명령어
    ps (process status)
    현재 실행 중인 프로세스 목록을 보여줍니다.

ps: 현재 사용자의 프로세스 목록을 보여줍니다.
ps -ef: 모든 사용자의 프로세스 목록을 보여줍니다.
top
시스템의 전반적인 상태를 실시간으로 보여줍니다.

kill
지정된 프로세스를 종료합니다.

kill [프로세스 ID]: 지정된 프로세스 ID를 가진 프로세스를 종료합니다.
df (disk free)
디스크 공간 정보를 보여줍니다.

du (disk usage)
디렉토리별 디스크 사용량을 보여줍니다.

ifconfig (interface configuration)
네트워크 인터페이스 정보를 보여줍니다.

ping
지정된 호스트와 네트워크 연결 상태를 확인합니다.

ping [호스트 주소]: 지정된 호스트 주소로 ping을 보내서 연결 상태를 확인합니다.

  1. 기타 유용한 명령어
    man (manual)
    명령어에 대한 도움말을 보여줍니다.

man [명령어]: 지정된 명령어에 대한 도움말을 보여줍니다.
clear
터미널 화면을 깨끗하게 지웁니다.

history
사용자가 입력했던 명령어 목록을 보여줍니다.

grep (global regular expression print)
파일에서 특정 문자열을 검색합니다.

grep [문자열] [파일]: 지정된 파일에서 특정 문자열을 검색하여 해당 줄을 출력합니다.

리눅스 명령어는 대소문자를 구분합니다.
Tab 키를 사용하여 명령어 또는 파일 이름을 자동 완성할 수 있습니다.
Ctrl + C 키를 사용하여 실행 중인 명령어를 강제로 종료할 수 있습니다.


Basic Linux Commands
Linux is an operating system that operates on commands. Unlike Windows or macOS, which rely on mouse clicks, Linux uses commands to perform tasks. While this may seem unfamiliar at first, it allows for faster and more efficient work once you become accustomed to it.

  1. File and Directory Related Commands
    ls (list)
    Displays a list of files and directories in the current directory.

ls: Briefly displays a list of files and directories in the current directory.
ls -l: Displays detailed information about files and directories (permissions, owner, size, modification date, etc.).
ls -a: Displays all lists, including hidden files and directories.
ls -al: Displays both detailed information and hidden files using the options above.
cd (change directory)
Changes the directory.

cd [directory]: Moves to the specified directory.
cd ..: Moves to the parent directory.
cd: Moves to the home directory.
pwd (print working directory)
Displays the path of the current working directory.

mkdir (make directory)
Creates a new directory.

mkdir [directory]: Creates a directory with the specified name.
rmdir (remove directory)
Deletes an empty directory.

rmdir [directory]: Deletes an empty directory with the specified name.
rm (remove)
Deletes a file or directory.

rm [file]: Deletes the specified file.
rm -r [directory]: Deletes the specified directory and all its contents. (Caution: The -r option is very powerful and should be used with care.)
cp (copy)
Copies a file or directory.

cp [original file] [target file]: Copies the original file to the target file.
cp -r [original directory] [target directory]: Copies the original directory to the target directory.
mv (move)
Moves a file or directory or renames it.

mv [original file] [target file]: Moves the original file to the target file or renames it.
mv [original directory] [target directory]: Moves the original directory to the target directory.

  1. Commands to Check and Edit File Content
    cat (concatenate)
    Outputs the file content to the screen.

cat [file]: Outputs the content of the specified file to the screen.
less
Shows file content by dividing it into pages.

less [file]: Shows the content of the specified file in page units. (Space key for the next page, Q key to exit)
head
Shows the content at the beginning of the file.

head [file]: Shows the first 10 lines of the specified file.
head -n [number] [file]: Shows the first [number] lines of the specified file.
tail
Shows the content at the end of the file.

tail [file]: Shows the last 10 lines of the specified file.
tail -n [number] [file]: Shows the last [number] lines of the specified file.
vi (visual editor)
Text editor.

vi [file]: Opens the specified file with the vi editor. (i key for input mode, Esc key for command mode, :wq to save and exit)

  1. System Management Commands
    ps (process status)
    Displays a list of currently running processes.

ps: Displays a list of the current user’s processes.
ps -ef: Displays a list of all users’ processes.
top
Shows the overall status of the system in real time.

kill
Terminates the specified process.

kill [process ID]: Terminates the process with the specified process ID.
df (disk free)
Displays disk space information.

du (disk usage)
Displays disk usage by directory.

ifconfig (interface configuration)
Displays network interface information.

ping
Checks the network connection status with the specified host.

ping [host address]: Sends a ping to the specified host address to check the connection status.

  1. Other Useful Commands
    man (manual)
    Displays help for commands.

man [command]: Displays help for the specified command.
clear
Clears the terminal screen.

history
Displays a list of commands the user has entered.

grep (global regular expression print)
Searches for a specific string in a file.

grep [string] [file]: Searches for a specific string in the specified file and outputs the line.
Tips
Linux commands are case sensitive.
Use the Tab key to autocomplete commands or file names.
Use Ctrl + C keys to forcefully terminate a running command.

Leave a Reply

Your email address will not be published. Required fields are marked *