linuxfromscratch

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
linuxfromscratch [2024/06/07 19:41] – [Binutils 설치하기 전에 ISL 설치하기 (실패)] baecylinuxfromscratch [2025/12/21 18:46] (현재) – [PS1 설정] baecy
줄 1: 줄 1:
-====== Linux From Scratch ======+===== 토막 상식 =====
  
 +==== 설치된 Perl Module 목록 확인 ====
 +=== Perl과 기본 시스템 도구만 이용 ===
 +<codeprism bash>
 +#!/bin/sh
 +
 +# Begin ~/bin/pml.sh
 +
 +# List of installed Perl Modules
 +
 +# grep "$pattern" - $1이 비어있으면 전체 검색(.), 있으면 $1로 검색
 +# /"Module"/ - "Module" 가 포함된 줄만 선택
 +# !seen[$NF]++ - awk 내부 배열을 사용해서 중복 제거
 +# print $NF - 마지만 단어(모듈명)
 +# sort --ignore-case (-f) | 대소문자 구분없이 정렬
 +
 +pattern="${1:-.}"
 +
 +perldoc perllocal | awk '/"Module"/ {if (!seen[$NF]++) print $NF}' | sort --ignore-case | grep --color=always -E -i "$pattern"
 +
 +# End ~/bin/pml.sh
 +</codeprism>
 +<codeprism cmd=true cmdout=2-10>
 +pml.sh "tiny|test"
 +Capture::Tiny
 +Class::Tiny
 +Test::Deep
 +Test::Exception
 +Test::Fatal
 +Test::Needs
 +Test::Warnings
 +Try::Tiny</codeprism>
 +
 +이런 방식으로 다중 검색도 가능함.
 +
 +=== ExtUtils::Install module 이용 ===
 +<codeprism bash>
 +#!/bin/sh
 +
 +# Begin ~/bin/pml.sh
 +
 +# List of installed Perl Modules
 +
 +# 검색어가 없으면 사용법 출력
 +if [ -z "$1" ]; then
 +        echo "Usage: $(basename $0) [pattern]"
 +        echo "Example: $(basename $0) build"
 +        exit 1
 +fi
 +
 +QUERY=$1
 +
 +echo "---- Searching installed Perl modules for: $QUERY ----"
 +
 +# ExtUtils::Installed를 사용하여 설치된 모듈 목록과 버전을 출력
 +# grep -i를 사용하여 대소문자 구분 없이 검색
 +
 +perl -MExtUtils::Installed -e '
 +        my $inst = ExtUtils::Installed->new();
 +        foreach my $mod ($inst->modules()) {
 +                my $ver = $inst->version($mod) || "N/A";
 +                print "$mod | Version: $ver\n";
 +        }
 +' | grep --color=auto -E -i "$QUERY"
 +
 +# 일치하는 결과가 없으면
 +
 +if [ ${PIPESTATUS[1]} -ne 0 ]; then
 +        echo "Result: No Matching Modules found."
 +fi
 +
 +# End ~/bin/pml.sh</codeprism>
 +<codeprism cmd=true cmdout=2-10>
 +pml.sh text
 +---- Searching installed Perl modules for: text ----
 +Text::BibTeX | Version: 0.91
 +Text::Diff | Version: 1.45
 +Text::Glob | Version: 0.11</codeprism>
 +
 +버전을 출력해주는 장점이 있음. \\
 +특정 모듈 설치전에는 사용하기 힘들다는 단점이 있음.
 +==== 설치된 Python3 Module 목록 확인 ====
 +
 +<codeprism bash>
 +pip3 list
 +</codeprism>
 +
 +==== Qemu Screen Dump ====
 +
 +  - <Ctrl>+<Alt>+<2> 그래픽 모드 \\ <Ctrl>+<A>, <C> -nographic 모드 \\ 모니터 콘솔로 전환
 +  - screendump __filename.ppm__ \\ 다음과 같이 **-f** 옵션으로 저장 포맷 지정 가능 \\ screendump screenshot.png -f png \\ 포맷 지정 저장 방식에서 세그폴트 발생하면 ppm으로 저장후 변환
 +  - <Ctrl>+<Alt>+<1> 가상 머신 화면 복귀
 +
 +
 +==== xwindow screen saver & dpms 시간 설정 ====
 +
 +<codeprism bash>
 +xset s 600 600
 +xset dpms 600 600 600
 +</codeprism>
 +순서대로 \\
 +화면보호기 작동시간,전환시간\\
 +DPMS 대기,유예,끄기 \\
 +
 +==== for, echo and sed =====
 +
 +<code bash>
 +for i in $(echo "ldapadd, ldapcompare, ldapdelete, ldapexop, ldapmodify, slapschema, slaptest" | sed 's/,/ /g') ; do find /usr/bin -type f -name $i ; done
 +</code>
 ==== Grep && Tar ==== ==== Grep && Tar ====
  
줄 84: 줄 192:
  
 <code bash> <code bash>
-function double-check() {                                                                                                   +function file-finder() { 
-    local FindWord=*${1}*                                                                                                   +    local FindWord=*${1}* 
-    local FindDir=$2                                                                                                        +    local FindDir=$2 
-                                                                                                                            +    if [ -z $FindDir ] ; then 
-    if [ -z $FindDir ] ; then                                                                                               +        FindDir=/usr 
-        FindDir=/usr                                                                                                        +    fi 
-    fi                                                                                                                      +    find $FindDir -name $FindWord 2> /dev/null | sort | grep -E --color=always $1 
-                                                                                                                            +    echo "Found file $(ansi --green ${1}) in directory $(ansi --yellow ${FindDir}) (refer to the list abovc).
-    find $FindDir -name $FindWord 2> /dev/null | sort | grep $1                                                             +
-                                                                                                                            +export -f file-finder
-    echo "I searched for $(ansi --green ${1}) you wanted in th $(ansi --yellow ${FindDir}) you specified                  +
-                                                                                                                          +
-                                                                                                                            +
-export -f double-check  +
 </code> </code>
  
줄 129: 줄 233:
 ---- ----
 ==== PS1 설정 ==== ==== PS1 설정 ====
 +일반사용자
 +<codeprism bash>\[\033[01;34m\]\u\[\033[00m\]@\[\033[01;36m\]\h \[\033[01;34m\]\w\[\033[00m\] \$ </codeprism>
 +루트사용자
 +<codeprism bash>\[\033[01;35m\]\u\[\033[00m\]@\[\033[01;35m\]\h \[\033[01;37m\]\w \[\033[01;31m\]# \[\033[00m\]</codeprism>
  
-=== 최초 === 
  
-++++ 많이 지저분하고 번로움 +=== 2차 개선 === 
-<code lang=bash cmd=true user=root+++++ 아닌데 쓸데없이 길어짐
-touch $LFS/etc/lfs-chroot</code>\\ +<code bash> 
-~/.bashrc\\ +PS1_ROOT='\[$(tput setaf 203)\][ \[$(tput sgr0)\]\w \[$(tput setaf 203)\]] \[$(tput sgr0)\]\$\n' 
-<code lang=bash> +PS1_USER='\[$(tput setaf 75)\]\[$(tput sgr0)\]\\[$(tput setaf 75)\]\[$(tput sgr0)\]\$\n' 
-if -f /etc/lfs-chroot ]; then +PS1_HEAD='\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h ' 
-  PS1='\[$(tput setaf 75)\]<LFS> \[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\\[$(tput setaf 75)\]\\[$(tput sgr0)\]\$\n'+if [ "$(awk '$5=="/" {print $1}' </proc/1/mountinfo)" != "$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)" ] ; then 
 +    if [ $(id -u) -eq 0 ] ; then 
 +        PS1="<Chroot>${PS1_HEAD}${PS1_ROOT}" 
 +    else 
 +        PS1="<Chroot>${PS1_HEAD}${PS1_USER}" 
 +    fi
 else else
-  PS1='\[$(tput setaf 75)\]\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h \[$(tput setaf 75)\]\w \[$(tput sgr0)\]\$\n' +    if [ $(id -u) -eq 0 ; then 
-fi</code>\\+        PS1="${PS1_HEAD}${PS1_ROOT}" 
 +    else 
 +        PS1="${PS1_HEAD}${PS1_USER}" 
 +    fi 
 +fi 
 +</code>
 ++++ ++++
- 
 === 1차 개선 === === 1차 개선 ===
  
줄 161: 줄 277:
 </code> </code>
 ++++ ++++
 +=== 최초 ===
  
-=== 2차 개선 === +++++ 많이 지저분하고 번거로움 | 
- +<code lang=bash cmd=true user=root> 
-<code bash> +touch $LFS/etc/lfs-chroot</code>\\ 
-PS1_ROOT='\[$(tput setaf 203)\][ \[$(tput sgr0)\]\w \[$(tput setaf 203)\]] \[$(tput sgr0)\]\$\n' +~/.bashrc\\ 
-PS1_USER='\[$(tput setaf 75)\]\[$(tput sgr0)\]\\[$(tput setaf 75)\]\[$(tput sgr0)\]\$\n' +<code lang=bash> 
-PS1_HEAD='\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h ' +if -f /etc/lfs-chroot ]; then 
-if [ "$(awk '$5=="/" {print $1}' </proc/1/mountinfo)" != "$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)" ] ; th +  PS1='\[$(tput setaf 75)\]<LFS> \[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\\[$(tput setaf 75)\]\\[$(tput sgr0)\]\$\n'
-en                                                                                                                 +
-    if [ $(id -u) -eq 0 ] ; then +
-        PS1="<Chroot>${PS1_HEAD}${PS1_ROOT}" +
-    else +
-        PS1="<Chroot>${PS1_HEAD}${PS1_USER}"                                                                       +
-    fi+
 else else
-    if [ $(id -u) -eq 0 ; then +  PS1='\[$(tput setaf 75)\]\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h \[$(tput setaf 75)\]\w \[$(tput sgr0)\]\$\n' 
-        PS1="${PS1_HEAD}${PS1_ROOT}"                                                                               +fi</code>\\ 
-    else +++++
-        PS1="${PS1_HEAD}${PS1_USER}" +
-    fi +
-fi +
-</code> +
 ---- ----
 ==== Debian 설치 후 추가적인 사항 ==== ==== Debian 설치 후 추가적인 사항 ====
줄 189: 줄 295:
 LFS 진행에 필요한 패키지 설치 LFS 진행에 필요한 패키지 설치
  
-<codelang=bash >+<code bash >
 sudo apt install build-essentials bison gawk m4 texinfo texinfo  ## 필수 사항 sudo apt install build-essentials bison gawk m4 texinfo texinfo  ## 필수 사항
 sudo apt install gettext libisl-dev                              ## 선택 사항 sudo apt install gettext libisl-dev                              ## 선택 사항
줄 344: 줄 450:
 ---- ----
 ==== Swap file ==== ==== Swap file ====
 +
 <code cmd=true cmdout=6,7> <code cmd=true cmdout=6,7>
 export LFS=/mnt/lfs export LFS=/mnt/lfs
줄 353: 줄 460:
 no label, UUID=890ba9a5-da48-4374-84ce-b71b91863e00 no label, UUID=890ba9a5-da48-4374-84ce-b71b91863e00
 sudo swapon $LFS_SWAP sudo swapon $LFS_SWAP
-sudo echo "$LFS_SWAP  swap  swap  defaults  0  0" >> /etc/fstab</code>\\+sudo echo "$LFS_SWAP  swap  swap  defaults  0  0" >> /etc/fstab 
 +</code>
  
 +----
 ==== Binutils 설치하기 전에 ISL 설치하기 ==== ==== Binutils 설치하기 전에 ISL 설치하기 ====
  
줄 378: 줄 487:
  
 ---- ----
-==== BLFS 시작하기 전에 필요한 패키지 ==== 
-sudo, nfs-utils(또는 sshfs), openssh, wget 
  
 ==== $LFS/sources에서 디렉토리 검색 ==== ==== $LFS/sources에서 디렉토리 검색 ====
 +가장 간단한 방법
 +<code lang=bash>
 +ls -d */
 +</code>
 +
 <code lang=bash> <code lang=bash>
 alias dirfind="find -mindepth 1 -maxdepth 1 -type d | sed 's@^./@@'" alias dirfind="find -mindepth 1 -maxdepth 1 -type d | sed 's@^./@@'"
줄 387: 줄 499:
 rm -rf $(dirfind)  ## 설치 완료된 소스 디렉토리 삭제 rm -rf $(dirfind)  ## 설치 완료된 소스 디렉토리 삭제
 ## 설치 완료된 패키지 디렉토리만 삭제할거면 다음과 같이 ## 설치 완료된 패키지 디렉토리만 삭제할거면 다음과 같이
-alias SearchAndDestroy='find -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;'</code> \\+alias SearchAndDestroy='find -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;' 
 +</code>
  
 +----
 ==== SBU 측정 ==== ==== SBU 측정 ====
 <code lang=bash> <code lang=bash>
  • linuxfromscratch.1717789273.txt.gz
  • 마지막으로 수정됨: 2024/06/07 19:41
  • 저자 baecy