Computer >> 컴퓨터 >  >> 프로그래밍 >> 프로그래밍

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

소개

필수 Linux 명령에 대한 이 포괄적인 가이드를 통해 Linux 시스템의 잠재력을 최대한 활용하세요. 숙련된 관리자이든 이제 막 시작하는 관리자이든 효율적인 서버 관리, 스크립트 작성 및 문제 해결을 위해서는 이러한 명령을 익히는 것이 중요합니다. 이 튜토리얼에서는 파일 관리, 프로세스 제어, 사용자 액세스, 네트워크 구성 및 시스템 디버깅에 가장 자주 사용되는 강력한 명령을 배우게 됩니다.

반드시 알아야 할 50가지 이상의 Linux 명령을 배우게 됩니다. 그것은 당신을 Linux 고급 사용자로 변화시킬 것입니다. 기본부터 고급까지 이러한 명령은 어떤 작업이든 처리하는 데 꼭 필요한 도구가 될 것입니다.

주요 시사점

  • Linux 명령은 목적에 따라 구성됩니다:파일 관리(ls , cp , mv , rm ), 프로세스 제어(ps , kill , top ), 사용자 권한(chmod , chown , sudo ) 및 네트워킹(ssh , ping , wget ).
  • man 명령은 모든 Linux 명령에 대한 내장 문서를 제공하며 구문이나 옵션 세부정보가 필요할 때 기본 참조로 사용됩니다.
  • grep 사용 텍스트 출력이나 파일을 검색하려면 head /tail 파일 내용을 미리 보려면 diff /cmp 파일을 비교합니다.
  • 파일 권한은 chmod으로 관리됩니다. (모드 비트 변경) 및 chown (소유자 변경)은 서버 보안 및 액세스 제어에 매우 중요합니다.
  • tar과 같은 명령 , zipunzip 보관 및 압축을 처리합니다. sshscp 안전한 원격 액세스 및 파일 전송을 처리합니다.
  • 프로세스 관리 명령(ps , kill , killall , top )은 시스템 상태를 모니터링하고 응답하지 않는 프로세스를 종료하는 데 필수적입니다.

전제조건

이 명령은 Ubuntu 서버에서 실행되지만 모든 최신 Linux 배포판에서 따라갈 수 있습니다. Ubuntu 초기 서버 설정 가이드에 따라 이 튜토리얼을 위한 Ubuntu 서버를 설정할 수 있습니다.

DigitalOcean 앱 플랫폼을 사용하여 GitHub에서 프런트엔드 애플리케이션을 배포하세요. DigitalOcean이 앱 확장에 집중하도록 하세요.

바로 시작해 보겠습니다!

일반 사용자가 꼭 알아야 할 상위 50개 Linux 명령

  1. ls - Linux에서 디렉토리 목록을 나열하기 위해 가장 자주 사용되는 명령
  2. 비밀번호 - Linux에서 작업 디렉토리 명령 인쇄
  3. CD - 디렉토리를 탐색하는 Linux 명령
  4. mkdir - Linux에서 디렉토리를 생성하는 데 사용되는 명령
  5. MV - Linux에서 파일 이동 또는 이름 바꾸기
  6. cp - mv와 유사하지만 Linux에서 파일을 복사하는 경우
  7. RM - 파일이나 디렉토리 삭제
  8. 터치 - 빈/빈 파일 만들기
  9. - 다른 파일에 대한 심볼릭 링크(바로가기) 만들기
  10. 지우기 - 터미널 디스플레이 지우기
  11. 고양이 - 터미널에 파일 내용 표시
  12. 에코 - 명령 다음에 오는 텍스트를 인쇄합니다.
  13. 적게 - 터미널에 페이지 출력을 표시하는 Linux 명령
  14. 남자 - 모든 Linux 명령에 대한 매뉴얼 페이지에 액세스
  15. 이름 없음 - OS에 대한 기본 정보를 가져오는 Linux 명령
  16. 후아미 - 활성 사용자 이름 가져오기
  17. 타르 - 리눅스에서 파일을 추출하고 압축하는 명령
  18. 그렙 - 출력 내에서 문자열 검색
  19. 머리 - 위에서부터 지정된 개수만큼의 라인을 반환
  20. 꼬리 - 맨 아래부터 지정된 수만큼의 라인을 반환
  21. 차이점 - 두 파일의 차이점 찾기
  22. cmp - 두 파일이 동일한지 확인할 수 있습니다
  23. 통신 - diff와 cmp의 기능을 결합
  24. 정렬 - 출력하는 동안 파일 내용을 정렬하는 Linux 명령
  25. 내보내기 - Linux에서 환경 변수 내보내기
  26. 압축 - Linux의 Zip 파일
  27. 압축해제 - Linux에서 파일 압축 풀기
  28. ssh - Linux의 Secure Shell 명령
  29. 서비스 - 서비스를 시작하고 중지하는 Linux 명령
  30. ps - 활성 프로세스 표시
  31. 죽이고 죽이고 - 프로세스 ID 또는 이름으로 활성 프로세스 종료
  32. DF - 디스크 파일 시스템 정보 표시
  33. 마운트 - Linux에서 파일 시스템 마운트
  34. chmod - 파일 권한을 변경하는 명령
  35. - 파일이나 폴더의 소유권을 부여하는 명령
  36. ifconfig - 네트워크 인터페이스 및 IP 주소 표시
  37. 추적 경로 - 목적지에 도달하기 위한 모든 네트워크 홉을 추적합니다.
  38. wget - 인터넷에서 직접 파일 다운로드
  39. 어휴 - 방화벽 명령
  40. iptables - 다른 모든 방화벽 유틸리티와 인터페이스할 수 있는 기본 방화벽
  41. apt, 팩맨, 냠, rpm - 배포판에 따른 패키지 관리자
  42. 스도 - Linux에서 권한을 상승시키는 명령
  43. - 명령줄 달력 보기
  44. 별칭 - 자주 사용하는 명령에 대한 사용자 정의 단축키 만들기
  45. dd - 주로 부팅 가능한 USB 스틱을 만드는 데 사용됩니다.
  46. 어디 - 명령에 대한 바이너리, 소스 및 매뉴얼 페이지 찾기
  47. 무엇입니까 - 명령의 용도 찾기
  48. 상단 - 시스템 사용량과 함께 활성 프로세스를 실시간으로 봅니다.
  49. useradd 및 usermod - 새로운 사용자 추가 또는 기존 사용자 데이터 변경
  50. 비밀번호 - 기존 사용자의 비밀번호 생성 또는 업데이트

파일 및 디렉토리 명령

명령 설명 예 lsList 디렉터리 내용.ls cdChange 디렉토리.cd /path/to/directory pwd현재 디렉토리를 표시합니다.pwd mkdir새 디렉토리를 생성합니다.mkdir new_directory rmdir빈 디렉토리를 제거합니다.rmdir empty_directory rm파일이나 디렉터리를 삭제합니다.rm file.txt touch빈 파일을 생성하세요.touch new_file.txt cp파일이나 디렉터리를 복사합니다.cp file.txt /path/to/destination mv파일을 이동하거나 이름을 바꿉니다.mv file.txt /path/to/new_location cat표시 파일 내용.cat file.txt nano / vimEdit 파일을 터미널에서.nano file.txt find디렉토리 계층 구조에서 파일을 검색합니다.find . -name "file.txt" grep패턴을 사용하여 텍스트를 검색합니다.grep "pattern" file.txt tarArchive 및 압축 파일.tar -cvf archive.tar file1.txt file2.txt df파일 시스템의 디스크 사용량을 표시합니다.df duShow 디렉터리/파일 크기.du -sh /path/to/directory chmodChange 파일 권한.chmod 755 file.txt chown파일 소유자를 변경합니다.chown user:group file.txt mount파일 시스템을 마운트합니다.mount /dev/sdb1 /mnt umount파일 시스템을 마운트 해제합니다.umount /mnt

네트워킹 명령

명령 설명 샘플 사용법 호스트에 대한 pingTest 연결입니다.ping google.com ifconfig / ip a디스플레이 네트워크 인터페이스.ifconfig 또는 ip a netstat / ss네트워크 연결을 표시합니다.netstat -tuln 또는 ss -tuln wgetHTTP/FTP를 통해 파일을 다운로드합니다.wget http://example.com/file.zip 컬URL 구문을 사용하여 데이터를 전송합니다.curl -O http://example.com/file.zip nc(Netcat)네트워크 디버깅 및 데이터 전송.nc -zv 192.168.1.1 80 tcpdump네트워크 패킷을 캡처하고 분석합니다.tcpdump -i eth0 iptables방화벽 규칙을 구성합니다.iptables -A INPUT -p tcp --dport 22 -j ACCEPT Traceroute패킷이 네트워크 호스트에 도달하는 경로를 추적합니다.traceroute example.com nslookupQuery DNS를 사용하여 도메인 이름 또는 IP 주소 매핑을 얻습니다.nslookup example.com ssh원격 호스트에 안전하게 연결하세요.ssh user@example.com

프로세스 및 시스템 모니터링 명령

명령 설명 예제 명령어 ps실행 중인 프로세스를 표시합니다.ps aux topDynamic 프로세스 뷰어.top htoptop.htop의 향상된 버전 kill프로세스에 신호를 보냅니다.kill <PID> killallKill은 이름별로 프로세스를 처리합니다.killall <process_name> uptimeSystem 가동 시간 및 로드.uptime whoami현재 로그인된 사용자입니다.whoami env표시 환경 변수.env 프로세스의 straceTrace 시스템 호출.strace -p <PID> systemctl시스템 서비스를 관리합니다.systemctl status <service_name> JournalctlView 시스템 로그.journalctl -xe freeDisplay 메모리 사용량.free -h vmstatReport 가상 메모리 통계.vmstat 1 iostatCPU 및 I/O 통계를 보고합니다.iostat lsofList는 프로세스별로 파일을 엽니다.lsof dmesg커널 링 버퍼 메시지를 인쇄합니다.dmesg

사용자 및 권한 관리 명령

명령 설명 예제 명령어 passwd사용자 비밀번호를 변경하세요.passwd <username> adduser / useradd새 사용자를 추가하세요.adduser <username> 또는 useradd <username> deluser / userdel사용자를 삭제합니다.deluser <username> 또는 userdel <username> usermod사용자 계정을 수정합니다.usermod -aG <group> <username> groups그룹 멤버십을 표시합니다.groups <username> sudoExecute 명령을 루트로 실행합니다.sudo <command> chage사용자 비밀번호 만료 정보를 변경합니다.chage -l <username> id사용자 신원 정보를 표시합니다.id <username> newgrp새 그룹에 로그인하세요.newgrp <group>

파일 전송 및 동기화 명령

명령 설명 예제 명령어 scpSSH를 통해 파일을 안전하게 복사합니다.scp user@remote:/path/to/file /local/destination rsync파일과 디렉터리를 효율적으로 동기화합니다.rsync -avz /local/directory/ user@remote:/path/to/destination ftp파일 전송 프로토콜을 사용하여 파일을 전송합니다.ftp ftp.example.com sftpSSH 파일 전송 프로토콜을 사용하여 파일을 안전하게 전송합니다.sftp user@remote:/path/to/file wget웹에서 파일을 다운로드합니다.wget http://example.com/file.zip 컬서버와 데이터를 주고 받습니다.curl -O http://example.com/file.zip

텍스트 처리 명령

명령 설명 예제 명령어 awk패턴 스캔 및 처리.awk '{print $1}' file.txt 텍스트 필터링/수정을 위한 sedStream 편집기.sed 's/old/new/g' file.txt cut텍스트 줄에서 섹션을 제거합니다.cut -d':' -f1 /etc/passwd sort텍스트 줄을 정렬합니다.sort file.txt grep텍스트의 패턴을 검색합니다.grep 'pattern' file.txt wc단어, 줄, 문자 수를 계산합니다.wc -l file.txt PasteMerge 파일 줄.paste file1.txt file2.txt Join공통 필드에 있는 두 파일의 행을 결합합니다.join file1.txt file2.txt headOutput 파일의 첫 번째 부분.head -n 10 file.txt tail파일의 마지막 부분을 출력합니다.tail -n 10 file.txt

셸 유틸리티 및 단축키 명령

명령 설명 예제 명령어 aliasCreate 단축키를 명령에 사용하세요.alias ll='ls -la' unalias별칭을 제거합니다.unalias ll 기록이전에 입력한 명령을 표시합니다.history Clear터미널 화면을 지웁니다.clear 재부팅시스템을 재부팅하세요.reboot 종료시스템 전원을 끕니다.shutdown now date시스템 날짜 및 시간을 표시하거나 설정합니다.date echo텍스트 한 줄을 표시합니다.echo "Hello, World!" 지정된 시간 동안 sleepDelay를 수행합니다.sleep 5 time명령 실행 기간을 측정합니다.time ls watch프로그램을 주기적으로 실행하여 출력을 전체 화면으로 표시합니다.watch -n 5 df -h

이제 각 명령에 대해 좀 더 자세히 살펴보고 더 자세히 이해해 보겠습니다. 각 개별 명령에 대한 기존 기사가 이미 많이 있습니다. 귀하의 편의를 위해 모든 기존 기사에 대한 링크를 추가하고 새로운 주제가 다루어지면 기사를 계속 업데이트할 것입니다.

ls Linux의 명령

ls 명령은 현재 작업 디렉터리의 파일과 디렉터리를 나열하는 데 사용됩니다. 이것은 여러분이 반드시 알아야 할 가장 자주 사용되는 Linux 명령 중 하나가 될 것입니다.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위 이미지에서 볼 수 있듯이 인수 없이 명령 자체를 사용하면 디렉터리의 모든 파일과 디렉터리가 포함된 출력이 제공됩니다. 이 명령은 출력에 데이터를 표시하는 측면에서 많은 유연성을 제공합니다.

ls 사용에 대해 자세히 알아보세요. 명령

명령 목록으로 돌아가기 ↑

pwd Linux의 명령

pwd 명령을 사용하면 터미널의 현재 작업 디렉터리를 인쇄할 수 있습니다. 아주 기본적인 명령이고 목적을 아주 잘 해결해줍니다.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

이제 일반적으로 터미널 프롬프트에는 전체 디렉토리가 있어야 합니다. 하지만 그렇지 않은 경우에는 현재 있는 디렉터리를 확인하는 빠른 명령이 될 수 있습니다. 이 명령의 또 다른 응용 프로그램은 스크립트를 생성할 때 이 명령을 사용하여 스크립트가 저장된 디렉터리를 찾을 수 있습니다.

명령 목록으로 돌아가기 ↑

cd Linux의 명령

터미널 내에서 작업하는 동안 디렉토리 내에서 이동하는 것은 거의 필수입니다. cd 명령은 꼭 알아야 할 중요한 Linux 명령 중 하나이며 디렉터리를 탐색하는 데 도움이 됩니다. cd를 입력하세요. 아래와 같이 디렉토리가 따라옵니다.

root@ubuntu:~# cd <directory path>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위 명령에서 볼 수 있듯이 저는 간단히 cd /etc/를 입력했습니다. /etc 디렉토리로 들어가세요. 우리는 pwd을 사용했습니다. 현재 작업 디렉토리를 인쇄하는 명령입니다.

명령 목록으로 돌아가기 ↑

mkdir Linux의 명령

mkdir 명령을 사용하면 터미널 내에서 디렉터리를 만들 수 있습니다.

root@ubuntu:~# mkdir <folder name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위 스크린샷에서 볼 수 있듯이 이 간단한 명령만으로 새 디렉터리를 만들었습니다.

명령 목록으로 돌아가기 ↑

cpmv 명령

cpmv 명령은 Windows의 복사-붙여넣기 및 잘라내기-붙여넣기 명령과 동일합니다. 하지만 Linux에는 실제로 파일 이름을 바꾸는 명령이 없기 때문에 mv도 사용합니다. 파일과 폴더의 이름을 바꾸는 명령입니다.

root@ubuntu:~# cp <source> <destination>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위 명령에서는 Sample.dll이라는 파일의 복사본을 만들었습니다. mv를 사용하면 어떻게 되는지 살펴보겠습니다. 같은 방법으로 명령을 내리세요.

root@ubuntu:~# mv <source> <destination>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위의 경우 동일한 디렉터리 내에서 파일을 이동했기 때문에 이름 바꾸기 역할을 했습니다. 이제 파일명이 변경되었습니다.

명령 목록으로 돌아가기 ↑

rm Linux의 명령

이전 섹션에서는 Sample-Copy 파일을 삭제했습니다. rm 명령은 파일과 폴더를 삭제하는 데 사용되며 반드시 알아야 할 중요한 Linux 명령 중 하나입니다.

root@ubuntu:~# rm <file name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

디렉터리를 삭제하려면 -r을 추가해야 합니다. 그것에 대한 주장. -r가 없는 경우 인수, rm 명령은 디렉토리를 삭제하지 않습니다.

root@ubuntu:~# rm -r <folder/directory name>

-r rm의 플래그 Linux의 명령은 "재귀적을 의미합니다. ". rm과 함께 사용하는 경우 명령을 실행하면 지정된 파일뿐만 아니라 모든 하위 디렉터리와 해당 하위 디렉터리 내의 파일도 반복적으로 제거됩니다.

참고: rm를 사용할 때는 주의하는 것이 중요합니다. -r를 사용한 명령 플래그를 사용하면 많은 수의 파일과 디렉터리를 빠르고 영구적으로 삭제할 수 있습니다. -i을 사용하는 것이 좋습니다. -r와 함께 플래그 각 파일과 디렉터리를 삭제하기 전에 확인 메시지를 표시하는 플래그입니다.

예를 들어 mydir을 제거하려면 디렉토리와 그 내용을 확인한 후 다음 명령을 사용할 수 있습니다:

root@ubuntu:~# rm -ri mydir

mydir 내의 각 파일과 디렉터리를 삭제하기 전에 확인 메시지가 표시됩니다. 디렉터리입니다.

명령 목록으로 돌아가기 ↑

touch Linux의 명령

touch Linux의 명령은 빈 파일을 생성하거나 기존 파일의 타임스탬프를 업데이트합니다.

root@ubuntu:~# touch <file name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

명령 목록으로 돌아가기 ↑

ln Linux의 명령

다른 파일에 대한 링크를 만들려면 ln을 사용합니다. 명령. 이는 Linux 관리자로 일할 계획이라면 알아야 할 가장 중요한 Linux 명령 중 하나입니다.

root@ubuntu:~# ln -s <source path> <link name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

-s 플래그는 기호 링크를 생성합니다. (심볼릭 링크 또는 소프트 링크라고도 함)을 파일이나 디렉터리에 연결합니다. 심볼릭 링크는 다른 파일이나 디렉터리에 대한 바로가기나 포인터 역할을 하는 특별한 유형의 파일입니다.

기본적으로 ln 명령은 하드 링크를 만듭니다. 심볼릭 링크나 소프트 링크 대신.

참고: 텍스트 파일이 있다고 가정해 보겠습니다. 심볼릭 링크를 만들면 해당 파일에 대한 링크는 원본 파일에 대한 포인터일 뿐입니다. 원본 파일을 삭제하면 링크가 더 이상 연결되지 않으므로 링크가 깨집니다.

하드 링크 내용이 완전히 동일한 원본 파일의 미러 복사본입니다. 심볼릭 링크와 마찬가지로 원본 파일의 내용을 편집하면 해당 변경 사항이 하드 링크에 반영됩니다. 하지만 원본 파일을 삭제하더라도 하드 링크는 계속 작동하며 원본 파일의 일반 복사본처럼 보고 편집할 수 있습니다.

소프트 링크와 하드 링크에 대해 자세히 알아보세요.

명령 목록으로 돌아가기 ↑

clear Linux의 명령

clear Linux의 명령은 터미널 화면을 지웁니다. 현재 터미널에 표시된 모든 텍스트와 출력을 제거하고 작업할 수 있는 깨끗한 상태를 제공합니다.

다음은 clear 사용 방법의 예입니다. 명령:

root@ubuntu:~# clear

그러면 터미널 화면이 지워지고 커서가 화면 왼쪽 상단으로 이동됩니다.

clear을 사용할 수도 있습니다. 다음과 같이 다른 명령과 조합하여 명령을 사용합니다:

root@ubuntu:~# ls -l; clear

그러면 현재 디렉터리의 파일과 디렉터리가 나열되고 터미널 화면이 지워집니다.

참고: clear 명령은 시스템에서 파일이나 데이터를 삭제하지 않습니다. 터미널 표시에만 영향을 미칩니다.

cat , echoless 명령

파일의 내용을 출력하거나 터미널 출력에 무엇이든 인쇄하려면 cat를 사용합니다. 또는 echo 명령. 기본적인 사용법을 살펴보겠습니다.

root@ubuntu:~# cat <file name>
root@ubuntu:~# echo <Text to print on terminal>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위의 예에서 볼 수 있듯이 cat New-File에서 사용되는 명령 , 파일의 내용을 인쇄합니다. 동시에 echo를 사용하면 명령을 사용하면 명령 뒤에 오는 모든 내용을 간단히 인쇄합니다.

less 명령은 명령으로 인쇄된 출력이 화면 공간보다 크고 스크롤이 필요할 때 사용됩니다. less 명령을 사용하면 사용자가 Enter 키나 스페이스바를 사용하여 출력을 분할하고 스크롤할 수 있습니다.

이를 수행하는 간단한 방법은 파이프 연산자(|)를 사용하는 것입니다. ).

root@ubuntu:~# cat /boot/grub/grub.cfg | less

참고: -S을 사용하세요 less으로 플래그 지정 줄 바꿈을 활성화합니다. 이렇게 하면 가로로 스크롤하지 않고도 긴 줄의 텍스트를 볼 수 있습니다.

-N을 사용하세요 less으로 플래그 지정 줄 번호를 표시합니다. 이는 특정 텍스트의 줄 번호를 알아야 할 때 유용할 수 있습니다.

이러한 유용한 플래그를 다음과 같은 방법으로 사용할 수 있습니다:

root@ubuntu:~# cat /boot/grub/grub.cfg | less -SN

less 사용 파이프 연산자를 사용하면 다양한 상황에서 유용할 수 있습니다. 다음은 몇 가지 예입니다:

  • top와 같은 장기 실행 명령의 출력 보기 또는 htop .
  • grep과 같은 명령 출력에서 특정 텍스트 검색 또는 cat .

명령 목록으로 돌아가기 ↑

man Linux의 명령

man 명령은 반드시 알아야 할 매우 유용한 Linux 명령입니다. Linux로 작업할 때 다운로드하는 패키지에는 많은 기능이 있을 수 있습니다. 모든 것을 아는 것은 불가능합니다.

man Linux의 명령은 특정 명령에 대한 매뉴얼 페이지를 표시하는 데 사용됩니다. 구문, 옵션, 예를 포함하여 명령에 대한 자세한 정보를 제공합니다.

man을 사용하는 방법의 예는 다음과 같습니다. 명령:

  1. 터미널을 열고 man ls을 입력하세요. ls에 대한 매뉴얼 페이지를 표시하려면 명령.
root@ubuntu:~# 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 specified.
 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 ..
 -c with -lt: sort by, and show, ctime (time of last modification
 of file status information) with -l: show ctime and sort
 by name; 
...

명령 목록으로 돌아가기 ↑

uname 그리고 whoami 명령

uname 그리고 whoami 명령을 사용하면 여러 시스템에서 작업할 때 유용한 몇 가지 기본 정보에 액세스할 수 있습니다.

uname Linux의 명령은 커널 이름, 호스트 이름, 커널 릴리스, 커널 버전, 컴퓨터 하드웨어 이름을 포함하여 시스템 커널에 대한 정보를 표시합니다.

whoami Linux의 명령은 현재 사용자의 사용자 이름을 반환합니다. 그것은 “나는 누구인가?”를 의미합니다. 쉘 스크립트나 터미널에서 현재 사용자의 신원을 확인하는 데 자주 사용됩니다.

명령의 출력과 이를 사용하는 방법을 살펴보겠습니다.

root@ubuntu:~# uname -a

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

매개변수 -a uname로 명령은 "모두"를 의미합니다. 그러면 전체 정보가 인쇄됩니다. 매개변수를 추가하지 않으면 "Linux"만 출력됩니다.

참고: uname와 함께 사용할 수 있는 몇 가지 중요한 플래그 명령을 내리세요.

  1. uname -s 사용 커널 이름을 표시합니다.
  2. uname -n 사용 호스트 이름을 표시합니다.
  3. uname -r 사용 커널 릴리스를 표시합니다.
  4. uname -v 사용 커널 버전을 표시합니다.
  5. uname -m 사용 기계 하드웨어 이름을 표시합니다.

명령 목록으로 돌아가기 ↑

tar , zipunzip 명령

tar Linux의 명령은 아카이브된 파일을 생성하고 추출하는 데 사용됩니다. tar을 사용하여 여러 개의 서로 다른 아카이브 파일을 추출할 수 있습니다. 명령을 내리세요.

아카이브를 생성하려면 -c을 사용합니다. 매개변수를 사용하고 아카이브를 추출하려면 -x을 사용합니다. 매개변수. 어떻게 작동하는지 살펴보겠습니다.

#Compress
root@ubuntu:~# tar -cvf <archive name> <files separated by space>
#Extract
root@ubuntu:~# tar -xvf <archive name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

첫 번째 줄에서는 Compress.tar라는 이름의 아카이브를 만들었습니다. 새 파일 및 새 파일 링크를 사용합니다. 다음 명령에서는 아카이브에서 해당 파일을 추출했습니다.

zip에 대해 논의해 보겠습니다. 및 unzip 명령. 둘 다 매우 간단합니다. 매개변수 없이 사용할 수 있으며 의도한 대로 작동합니다. 아래 예시를 살펴보겠습니다.

root@ubuntu:~# zip <archive name> <file names separated by space>
root@ubuntu:~# unzip <archive name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

동일한 디렉터리에 해당 파일이 이미 있으므로 unzip 명령은 해당 파일을 덮어쓰기 전에 메시지를 표시합니다.

명령 목록으로 돌아가기 ↑

grep Linux의 명령

grep 명령은 Linux 및 Unix 기반 운영 체제에서 강력하고 다양한 텍스트 검색 도구입니다. 하나 이상의 파일에서 특정 패턴이나 문자열을 검색하고 다른 명령의 출력을 필터링할 수 있습니다.

grep 명령은 "전역 정규식 인쇄"를 의미하며, 이는 여러 줄과 파일에서 정규식을 검색하는 기능을 반영합니다.

root@ubuntu:~# <Any command with output> | grep "<string to find>"

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

이것은 명령의 간단한 시연이었습니다. grep 명령에 대해 자세히 알아보세요.

명령 목록으로 돌아가기 ↑

headtail 명령

대용량 파일을 출력할 때 headtail 명령이 유용합니다. 이 명령은 각각 파일의 시작이나 끝을 표시합니다. 일반적으로 텍스트 편집기에서 파일을 열지 않고도 파일 내용을 빠르게 보는 데 사용됩니다.

headtail 명령은 기본적으로 파일의 처음 10줄을 표시합니다. 다른 수의 줄을 표시하려면 -n을 사용할 수 있습니다. 옵션 다음에 표시하려는 줄 수를 입력하세요.

head를 사용하는 예는 다음과 같습니다. 및 tail 명령:

root@ubuntu:~# head <file name>
root@ubuntu:~# tail <file name>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

보시다시피 head 명령은 파일 상단부터 10줄을 보여줍니다.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

tail 명령은 파일에서 맨 아래 10줄을 출력했습니다.

이러한 명령을 사용하면 파일 내용을 빠르게 보고, 문제 해결을 위해 실시간 업데이트를 모니터링하고, 다른 명령의 출력을 필터링하고, 로그 분석을 수행할 수 있습니다.

명령 목록으로 돌아가기 ↑

diff , commcmp 명령

diff , commcmp 명령은 모두 Linux 및 Unix 기반 운영 체제에서 파일을 비교하는 데 사용됩니다. 이 명령을 사용하면 두 파일 간의 차이점을 식별하고, 변경 사항을 병합하고, 기타 파일 비교 작업을 수행할 수 있습니다.

root@ubuntu:~# diff <file 1> <file 2>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

위에서 볼 수 있듯이 New-File-Edited 파일에 "이 줄은 편집되었습니다"라는 작은 텍스트를 추가했습니다.

cmp 명령은 두 파일을 비교하고 서로 다른 첫 번째 바이트를 표시하는 데 사용됩니다. 바이너리 파일 간의 차이점을 식별하거나 파일의 손상을 확인하는 데 사용할 수 있습니다.

root@ubuntu:~# cmp <file 1> <file 2>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

cmp 명령은 줄 번호만 알려주는데, 이는 다릅니다. 실제 텍스트가 아닙니다.

comm 명령은 정렬된 두 파일을 비교하고 각 파일에 고유한 줄과 두 파일에 공통된 줄을 표시하는 데 사용됩니다.

root@ubuntu:~# comm <file 1> <file2>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

왼쪽에 정렬된 텍스트는 file 1에만 있습니다. . 가운데 정렬된 텍스트는 file 2에만 있습니다. . 그리고 오른쪽 정렬된 텍스트가 두 파일 모두에 존재합니다.

그러고 보니 comm 이 명령은 더 큰 파일을 비교하려고 할 때 모든 것이 함께 정렬되어 있는지 보고 싶을 때 가장 적합합니다.

이 세 가지 명령은 모두 Linux 및 Unix 기반 운영 체제에서 파일 작업을 위한 필수 도구입니다. diff 사용법을 이해함으로써 , commcmp 명령을 효과적으로 사용하면 파일 간의 차이점을 식별하고, 변경 사항을 병합하고, 기타 파일 비교 작업을 수행할 수 있습니다.

이러한 명령은 파일 문제를 식별 및 해결하고 변경 사항을 추적하고 버전 제어를 유지하는 데 도움이 될 수 있습니다. 개발자이든 시스템 관리자이든 이러한 명령은 툴킷의 필수적인 부분입니다.

명령 목록으로 돌아가기 ↑

sort Linux의 명령

sort 명령은 Linux 및 Unix 기반 운영 체제에서 텍스트 파일이나 표준 입력의 줄을 정렬하는 데 사용됩니다. 오름차순 또는 내림차순으로 줄을 정렬하고 필드별 정렬 또는 사용자 정의 정렬 순서 사용과 같은 기타 정렬 작업을 수행하는 데 사용할 수 있습니다.

sort의 기본 구문 명령은 다음과 같습니다:

root@ubuntu:~# sort <filename>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

기본적으로 sort 명령은 ASCII 조합 순서로 줄을 정렬합니다. , 숫자나 특수 문자를 정렬할 때 예상치 못한 결과가 발생할 수 있습니다. 숫자를 숫자순으로 정렬하려면 -n을 사용하세요. 옵션입니다.

다음은 -n 사용 예입니다. 옵션:

root@ubuntu:~# sort -n file.txt

위 명령은 file.txt의 행을 정렬합니다. 번호순으로요.

sort -k를 사용하여 특정 필드를 기준으로 줄을 정렬하는 데에도 명령을 사용할 수 있습니다. 옵션입니다.

-k를 사용하는 예는 다음과 같습니다. 옵션:

root@ubuntu:~# sort -k 2 file.txt

이 명령은 file.txt의 행을 정렬합니다. 두 번째 필드를 기준으로 합니다.

sort 명령은 Linux 및 Unix 기반 운영 체제에서 텍스트 파일 작업을 위한 강력하고 유연한 도구입니다. sort 사용법을 이해함으로써 명령을 효과적으로 사용하면 텍스트 파일의 줄을 정렬하고, 특정 필드를 기준으로 줄을 정렬하고, 기타 정렬 작업을 수행할 수 있습니다.

이러한 명령은 데이터를 구성 및 분석하고 기타 파일 조작 작업을 수행하는 데 도움이 될 수 있습니다. 개발자이든 시스템 관리자이든 sort 명령은 툴킷의 필수적인 부분입니다.

명령 목록으로 돌아가기 ↑

export Linux의 명령

export Linux 및 Unix 기반 운영 체제의 명령은 환경 변수를 설정하는 데 사용됩니다. 환경 변수는 프로세스나 명령에서 사용할 수 있는 정보를 저장하는 데 사용됩니다.

환경 변수가 설정되면 동일한 셸에서 실행되는 모든 프로세스나 명령에서 액세스할 수 있습니다.

환경 변수는 구성 설정, 사용자 기본 설정, 시스템 정보 등 광범위한 정보를 저장하는 데 사용할 수 있습니다.

export를 사용하는 예는 다음과 같습니다. 명령:

root@ubuntu:~# export <variable name>=<value>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

export에 대해 자세히 알아보세요. 명령

명령 목록으로 돌아가기 ↑

ssh Linux의 명령

ssh Linux 및 Unix 기반 운영 체제의 명령은 원격 서버에 대한 보안 셸 연결을 설정합니다. 이 명령은 로컬 서버와 원격 서버 사이에 안전하게 암호화된 연결을 제공하여 사용자가 안전하게 명령을 실행하고 파일을 전송할 수 있도록 합니다.

ssh의 기본 구문 명령은 다음과 같습니다:

root@ubuntu:~ ssh username@remote-server

이 명령은 ssh을 설정합니다. remote-server에 연결 username 사용 계정.

ssh 명령은 다음을 포함하여 광범위한 옵션과 구성을 지원합니다.

  • 인증 방법 구성(비밀번호, 공개 키 등)
  • 암호화 알고리즘 구성
  • 압축 구성
  • Configuring port forwarding
  • Configuring X11 forwarding
  • Configuring SSH keys

The service command in Linux

The service command in Linux is used to manage system services, which are long-running processes that are started at boot time and run in the background. These services are responsible for providing various system functionalities, such as networking, database management, and user authentication.

The service command is used to start, stop, restart, and check the status of these services. It is a front-end to the systemctl command, which is used to manage the systemd service manager.

The basic syntax of the command is as below.

root@ubuntu:~ service ssh status
root@ubuntu:~ service ssh stop
root@ubuntu:~ service ssh start 

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

As you can see in the image, the ssh server is running on our system.

Jump back to commands list ↑

The ps , kill , and killall commands

The ps , kill , and killall commands are all used to manage processes in Linux.

The ps command is used to display information about the current running processes on the system. Here are some examples of using the ps command:

Display a list of all running processes:

root@ubuntu:~ ps -ef

Display a list of all processes for a specific process ID (PID):

root@ubuntu:~ ps -p PID

Let’s see all of this in action:

root@ubuntu:~ ps 
root@ubuntu:~ kill <process ID>
root@ubuntu:~ killall <process name>

For demonstration purposes, we will create a shell script with an infinite loop and will run it in the background.

With the use of the & symbol, we can pass a process into the background. As you can see, a new bash process with PID 14490 is created.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

Now, to kill a process with the kill command, you can type kill followed by the PID(Process Id) of the process.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

But if you do not know the process ID and just want to kill the process with the name, you can make use of the killall command.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

You will notice that PID 14490 stayed active. That is because, both times, we killed the sleep process.

Learn more about the ps command and the kill command.

Jump back to commands list ↑

The df and mount commands

When working with Linux, the df and mount commands are very efficient utilities to mount filesystems and get details of the file system.

The df command is used to display the amount of disk space used and available on the file systems, and the mount command is used to mount a file system or device to a specific directory.

When we say mount , it means that we’ll connect the device to a folder so we can access the files from our filesystem. The default syntax to mount a filesystem is below:

root@ubuntu:~ mount /dev/cdrom /mnt
root@ubuntu:~ df -h

In the above case, /dev/cdrom is the device that needs to be mounted. Usually, a mountable device is found inside the /dev 폴더. mnt is the destination folder to which to mount the device. You can change it to any folder you want, but we have used /mnt as it’s the system’s default folder for mounting devices.

To see the mounted devices and get more information about them, we use the df command. Just typing df will give us the data in bytes, which is not readable. So, we’ll use the -h parameter to make the data human-readable.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

Jump back to commands list ↑

The chmod and chown commands

The chmod and chown commands are used to modify file permissions and ownership in Linux.

The chmod command is used to change the permissions of a file or directory, and the chown command is used to change the ownership of a file or directory

The default syntax for both the commands is chmod <parameter> filename and chown <user:group> filename

root@ubuntu:~ chmod +x loop.sh
root@ubuntu:~ chmod root:root loop.sh

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

In the above example, we’re adding executable permissions to the loop.sh file with the chmod 명령. In addition, with the chown command, we’ve made it accessible only to the root user and users within the root group.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

As you will notice, the root root part is now changed to www-data which is the new user who has full file ownership.

Learn more about the Linux file Permissions and using the chmod command.

Jump back to commands list ↑

The ifconfig and traceroute commands

The ifconfig and traceroute commands manage network interfaces and trace the route of network packets in Linux.

The ifconfig command will give you the list of all the network interfaces along with the IP addresses, MAC addresses and other information about the interface.

root@ubuntu:~ ifconfig

There are multiple parameters that can be used, but we’ll work with the basic command here.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

The traceroute command is used to trace the route of network packets and determine the path they take to reach a specific destination.

When working with traceroute , you can simply specify the IP address, hostname, or domain name of the endpoint.

root@ubuntu:~ traceroute <destination address>

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

Now, obviously, localhost is just one hop (the network interface itself). You can try this same command with any other domain name or IP address to see all the routers your data packets pass through to reach the destination.

Jump back to commands list ↑

The wget command in Linux

If you want to download a file from within the terminal, the wget command is one of the handiest command-line utilities available. It is one of the important Linux commands you should know when working with source files.

When you specify the link for download, it has to directly be a link to the file. If the file cannot be accessed by the wget command, it will simply download the webpage in HTML format instead of the actual file that you wanted.

Let’s try an example. The basic syntax of the wget command is :

root@ubuntu:~ wget <link to file>

Or,

root@ubuntu:~ wget -c <link to file>

The -c argument allows us to resume an interrupted download.

Jump back to commands list ↑

The ufw and iptables commands

The ufw and iptables commands are used to manage firewalls in Linux.

UFW and IPTables are firewall interfaces for the Linux Kernel’s netfilter firewall. IPTables directly passes firewall rules to Netfilter while UFW configures the rules in IPTables, which then sends those rules to Netfilter.

Why do we need UFW when we have IPTables? Because IPTables is pretty difficult for a newbie. UFW makes things extremely easy. See the below example where we are trying to allow port 80 for our webserver.

root@ubuntu:~# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
root@ubuntu:~# ufw allow 80

I’m sure you now know why UFW was created! Look at how easy the syntax becomes. Both these firewalls are very comprehensive and can allow you to create any kind of configuration required for your network. Learn at least the basics of UFW or IPTables firewall, as these are the Linux commands you must know.

Learn more about managing firewall with ufw and managing firewall with iptables .

Jump back to commands list ↑

Package Managers in Linux

Different Linux distributions use different package managers. Since we’re working on a Ubuntu server, we have the apt package manager. But for someone working on a Fedora, Red Hat, Arch, or Centos machine, the package manager will be different.

Below are the commands on how to use these package managers on different Linux distributions.

  • Debian and Debian-based distros - apt install <package name>
  • Arch and Arch-based distros - pacman -S <package name>
  • Red Hat and Red Hat-based distros - yum install <package name>
  • Fedora and CentOS - yum install <package>

Getting yourself well versed with the package manager of your distribution will make things much easier for you in the long run. So even if you have a GUI based package management tool installed, try an make use of the CLI based tool before you move on to the GUI utility. Add these to your list of Linux commands you must know.

Jump back to commands list ↑

The sudo command in Linux

“With great power, comes great responsibility” _

This is the quote displayed when a sudo-enabled user(sudoer) first uses the sudo command to escalate privileges. This command is equivalent to logging in as root (based on what permissions you have as a sudoer).

non-root-user@ubuntu:~# sudo <command you want to run>
Password: 

Just add the command sudo before any command that you need to run with escalated privileges, and that’s it. It’s very simple to use, but can also be an added security risk if a malicious user gains access to a sudoer.

Learn more about how to create a new sudo user and how to edit sudoers file.

Jump back to commands list ↑

The cal command in Linux

Have you ever wanted to view the calendar in the terminal? There apparently are people who want it to happen, and well, here it is.

The cal command displays a well-presented calendar on the terminal. Just enter the command cal on your terminal prompt.

root@ubuntu:~# cal
root@ubuntu:~# cal March 2024

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

Although we don’t need it often, it’s a great addition! It’s an amazing option for terminal fans.

Jump back to commands list ↑

The alias command

Do you have some commands that you run very frequently while using the terminal? It could be rm -r or ls -l , or it could be something longer like tar -xvzf .

This is one of the productivity-boosting Linux commands you must know.

If you know a command that you run very often, it’s time to create an alias .

What’s an alias? In simple terms, it’s another name for a command that you’ve defined.

root@ubuntu:~# alias lsl="ls -l"
OR
root@ubuntu:~# alias rmd="rm -r"

Now, every time you enter lsl or rmd in the terminal, you’ll receive the output that you’d have received if you had used the full commands.

The examples here are for really small commands that you can still type by hand every time. But in some situations where a command has too many arguments that you need to type, it’s best to create a shorthand version of the same.

Jump back to commands list ↑

The dd command in Linux

This command was created to convert and copy files from multiple file system formats. In the current day, the command is simply used to create bootable USB for Linux but there still are some things important you can do with the command.

The dd command in Linux is a versatile command used for low-level copying and conversion of data. It stands for “data-description” or “data definition,” and it can be used to copy and convert data between different file formats and storage devices.

For example, if we wanted to back up the entire hard drive as is to another drive, we would use the dd command.

root@ubuntu:~# dd if=/dev/sdb of=/dev/sda

The if and of arguments stand for input file and output file .

It’s a powerful and flexible tool, but it can also be dangerous if not used carefully. Always double-check your syntax and make sure you know what the command will do before executing it.

Jump back to commands list ↑

The whereis and whatis commands

The whereis and whatis commands are used in Linux to search for information about programs and files.

The whereis command locates the binary, source, and manual pages for a specific command or program, and the whatis command displays a short description of a command or program.

root@ubuntu:~# whereis sudo
sudo: /usr/bin/sudo /usr/lib/sudo /usr/share/man/man8/sudo.8.gz

The whatis command gives us an explanation of what a command actually is.

root@ubuntu:~# whatis sudo
sudo (8) - execute a command as another user

Jump back to commands list ↑

The top command in Linux

A few sections earlier, we talked about the ps 명령. You observed that the ps command will output the active processes and end itself.

The top command is like a CLI version of the task manager in Windows.

The top command in Linux is a system monitoring tool that displays real-time information about system processes and resource usage. It provides a dynamic, real-time view of system activity, including CPU usage, memory usage, and process information.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

참고: Here are some examples of using the top command:

  • Sort processes by memory usage:
root@ubuntu:~# top -o MEM

This will sort the process list by memory usage, with the most memory-intensive processes at the top.

  • Display detailed information about a specific process:
root@ubuntu:~# top -p PID

Replace PID with the ID of the process you want to inspect.

  • Display a summary of system resource usage:
root@ubuntu:~# top -n 1

This will display a single summary screen of system resource usage.

It’s a powerful and flexible tool for monitoring system activity and troubleshooting performance issues.

Jump back to commands list ↑

The useradd and usermod commands

The useradd and usermod commands are used in Linux to manage user accounts.

The useradd or adduser commands are the exact same commands where adduser is just a symbolic link to the useradd 명령. This command allows us to create a new user in Linux.

root@ubuntu:~# useradd JournalDev -d /home/JD

The above command will create a new user named JournalDev with the home directory as /home/JD .

The usermod command, on the other hand, is used to modify existing users. You can modify any value of the user including the groups, the permissions, etc.

For example, if you want to add more groups to the user, you can type in:

root@ubuntu:~# usermod JournalDev -a -G sudo, audio, mysql

Jump back to commands list ↑

The passwd command in Linux

Now that you know how to create new users, let’s also set the password for them. The passwd command lets you set the password for your own account, or if you have the permissions, set the password for other accounts.

Here are some examples of using the passwd command:

  • Change the password for the current user:

    root@ubuntu:~# passwd
    

This will prompt you to enter a new password for the current user.

  • Change the password for a specific user:

    root@ubuntu:~# passwd username
    

Replace username with the name of the user whose password you want to change.

  • Force a user to change their password at the next login:

    root@ubuntu:~# passwd -f username
    
  • Set an expiration date for a user’s password:

    root@ubuntu:~# passwd -e -n days -w warndays username
    

Replace days with the number of days before the password expires and warm days with the number of days before the password expires that the user will be warned.

These are just a few examples of using the passwd command in Linux. By understanding how to use this command effectively, you can manage user accounts and ensure that your system is secure.

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령

Jump back to commands list ↑

Common Errors and Debugging

When working with Linux commands, you may encounter various errors and issues. Here are some common problems and how to resolve them:

1. Fixing “command not found” errors

If you receive a command not found error, it means that the command you are trying to run is not recognized by the system. This can happen for several reasons:

  1. The command is not installed on your system. You can install it using your package manager (e.g., apt , yum , dnf ).

    If you see:

    bash: xyz: command not found
    

    Use:

    which xyz
    

    If the command isn’t installed, try installing:

    apt-get install <package-name>
    
  2. The command is not in your system’s PATH. You can add the directory containing the command to your PATH.

    export PATH=$PATH:/path/to/command
    
  3. You made a typo. Double-check the command for any spelling errors.

2. Resolving permission issues with sudo

If you encounter permission issues, you can use sudo to run the command with superuser privileges. 예:

sudo command_name

3. Handling File Conflicts

File conflicts can occur when multiple users or processes attempt to modify the same file simultaneously. Here are some ways to handle file conflicts:

  1. Use Version Control Systems (VCS): Tools like Git can help manage file conflicts by allowing users to merge changes and resolve conflicts manually.

    git merge <branch_name>
    

    If there are conflicts, Git will prompt you to resolve them. Open the conflicting files, make the necessary changes, and then commit the resolved files.

    git add <resolved_file>
    git commit -m "Resolved merge conflict"
    
  2. Locking Mechanisms: Implement file locking to prevent multiple processes from writing to the same file simultaneously. Use flock in Linux to create a lock on a file.

    flock -x <file> -c "<command>"
    
  3. Atomic Operations: Use atomic operations to ensure that file writes are completed in a single step, reducing the risk of conflicts.

    mv temp_file target_file
    

    Or, Use mv with -f (force) or cp with -i (interactive):

    mv -f file1 file2
    cp -i file1 file2
    

4. Debugging Performance Bottlenecks

Performance bottlenecks can significantly impact the efficiency of your system. Here are some steps to debug and resolve them:

  1. Identify the Bottleneck: Use tools like top , htop , vmstat , and iostat to monitor system performance and identify the resource causing the bottleneck (CPU, memory, disk I/O, etc.).

    top
    
  2. Analyze Logs: Check system and application logs for any errors or warnings that might indicate performance issues.

    tail -f /var/log/syslog
    
  3. Optimize Code: Review and optimize your code to improve performance. Look for inefficient algorithms, unnecessary computations, and memory leaks.

  4. Profile Your Application: Use profiling tools like gprof , perf , or valgrind to analyze your application’s performance and identify slow functions or memory issues.

    gprof <executable> gmon.out
    
  5. Scale Resources: If the bottleneck is due to resource limitations, consider scaling up your hardware or using load balancing to distribute the load across multiple servers.

FAQs

1. What are the most used Linux commands?

The most used Linux commands include cd , ls , mkdir , rm , cp , mv , echo , cat , grep , find , man , sudo , apt-get , ssh , ping , df , du , free , top , ps , kill , killall , service , systemctl , reboot , shutdown , whoami , uname , uptime , history , and clear .

2. How do I list all available commands in Linux?

You can list all available commands in Linux by using the compgen -c 명령. This will display a list of all commands that are available on your system.

3. How do I find a file in Linux?

You can find a file in Linux using the find 명령. The basic syntax is find <path> -name "<filename>" , where <path> is the directory where you want to start searching, and <filename> is the name of the file you’re looking for. For example, find /home/user -name "example.txt" .

4. How do I kill a process in Linux?

You can kill a process in Linux using the kill 명령. First, you need to find the process ID (PID) of the process you want to kill using the ps or top 명령. Then, use the kill command followed by the PID. For example, kill 1234 , where 1234 is the PID of the process.

5. What is the difference between cp and mv ?

The cp command is used to copy files or directories, while the mv command is used to move or rename files or directories. cp creates a duplicate of the original file, leaving the original intact, whereas mv moves the file to a new location, removing it from the original location.

6. How do I check my Linux system’s memory usage?

You can check your Linux system’s memory usage using the free 명령. This command displays the total amount of free and used physical and swap memory in the system. For example, free -h will display the memory usage in a human-readable format.

결론

In this tutorial, you explored over 50 essential Linux commands covering file and directory management, process control, user permissions, networking, text processing, and shell utilities. You also worked through real-world examples, troubleshooting patterns, and comparisons between related commands.

You can now navigate the Linux filesystem, manage processes, configure permissions, and troubleshoot common issues from the command line. These commands form the foundation of effective Linux system administration and scripting.

To go deeper on specific topics, explore these tutorials:

  • The grep Command in Linux/Unix
  • The ls Command in Linux/Unix
  • Process Management in Linux
  • The ps Command in Linux
  • An Introduction to the Linux Terminal

Master Linux:효율적인 시스템 관리를 위한 50개 이상의 필수 명령 This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.