linux-filesystem 계층구조 -루트 디렉토리 구조

 다음 두 페이지를 참고함

https://medium.com/harrythegreat/%EB%A6%AC%EB%88%85%EC%8A%A4-%EA%B8%B0%EC%B4%88-%EB%A3%A8%ED%8A%B8%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC-%EA%B5%AC%EC%A1%B0-b3e4871af4b3

https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/index.html

/bin & /sbin

/bin : User binaries(이진수) 실행가능한 프로그램, 기본 커멘드, 쉘

/sbin : system binaries : 시스템 관련 프로그램, 리부트 등등

bin폴더는 Binary의 약자로 OS의 최소한의 정상적인 구동을 위해 필요한 프로그램이 들어있는 폴더입니다. cat, chmod, chown, cp, date, echo, kill, ln, ls, mkdir, etx 와같은 기초적인 프로그램들이 포함됩니다. 또한 루트사용자, 일반사용자 모두 접근가능합니다.

sbin 폴더는 bin과 유사하지만 오직 루트유저만 실행할 수 있는 프로그램들이 들어있습니다.

/bin

시스템 관리자 뿐만아니라 일반 사용자도 사용할수 있는 명령어들을 포함한다. bash, csh 등과 같은 shell을 포함하고 cp, mv, rm, cat, ls등과 같은 명령어들이 있다. 이런 이유로 /usr/bin과 다르게, /bin 폴더는 꼭 있어야하는 폴더이다. / 만이 마운트 되었더라도 반드시 이용가능해야하는 기본적인 시스템 프로그램들을 포함하기 때문이다. 또한 부팅 스크립트를 실행하기 위한 프로그램도 존재한다. FSSTND(Filesystem standard)에 따르면 /bin에는 하위 폴더가 없다.

cat      Utility to concatenate files to standard output
chgrp    Utility to change file group ownership
chmod    Utility to change file access permissions
chown    Utility to change file owner and group
cp       Utility to copy files and directories
date     Utility to print or set the system data and time
dd       Utility to convert and copy a file
df       Utility to report filesystem disk space usage
dmesg    Utility to print or control the kernel message buffer
echo     Utility to display a line of text
false    Utility to do nothing, unsuccessfully
hostname Utility to show or set the system's host name
kill     Utility to send signals to processes
ln       Utility to make links between files
login    Utility to begin a session on the system
ls       Utility to list directory contents
mkdir    Utility to make directories
mknod    Utility to make block or character special files
more     Utility to page through text
mount    Utility to mount a filesystem
mv       Utility to move/rename files
ps       Utility to report process status
pwd      Utility to print name of current working directory
rm       Utility to remove files or directories
rmdir    Utility to remove empty directories
sed      The `sed' stream editor
sh       The Bourne command shell
stty     Utility to change and print terminal line settings
su       Utility to change user ID
sync     Utility to flush filesystem buffers
true     Utility to do nothing, successfully
umount   Utility to unmount file systems
uname    Utility to print system information

If /bin/sh is not a true Bourne shell, it must be a hard or symbolic link to the real shell command.

The rationale behind this is because sh and bash mightn't necessarily behave in the same manner. 
The use of a symbolic link also allows users to easily see that /bin/sh is not a true Bourne shell.

The [ and test commands must be placed together in either /bin or /usr/bin.

The requirement for the [ and test commands to be included as binaries (even if implemented internally by the shell) is shared with the POSIX.2 standard.

The following programs, or symbolic links to programs, must be in /bin if the corresponding subsystem is installed:

csh     The C shell (optional)
ed      The `ed' editor (optional)
tar     The tar archiving utility (optional)
cpio    The cpio archiving utility (optional)
gzip    The GNU compression utility (optional)
gunzip  The GNU uncompression utility (optional)
zcat    The GNU uncompression utility (optional)
netstat The network statistics utility (optional)
ping    The ICMP network test utility (optional)

If the gunzip and zcat programs exist, they must be symbolic or hard links to gzip. /bin/csh may be a symbolic link to /bin/tcsh or /usr/bin/tcsh.

The tar, gzip and cpio commands have been added to make restoration of a system possible (provided that / is intact).

Conversely, if no restoration from the root partition is ever expected, then these binaries might be omitted 
(e.g., a ROM chip root, mounting /usr through NFS). If restoration of a system is planned through the network, 
then ftp or tftp (along with everything necessary to get an ftp connection) must be available on the root partition.

/boot

부트로더와같이 시스템 부팅에 필요한 파일들이 위치. 부트 로더가 파일을 부팅할 수 있도록 준비하는데 필요한 프로그램은 /sbin, 부트로더용 configuration 파일은 /etc에 위치. 시스템 커널은 루트에 위치

/dev

device의 약자로 모든것은 파일이다 라는 리눅스모토에맞게 키보드, 마우스, 프린터등과같은 디바이스들을 파일 또는 디렉토리의 형태로 dev 폴더 안에 존재하기때문에 표준 입출력(ex. ‘cat /boot/vmlinuz > /dev/dsp’)을 통해 읽기 쓰기도 가능하며 디렉토리 어디에서든 접근 가능

/dev/cdrom은 CD-ROM드라이브, /dev/fd0는 플로피 드라이브, /dev/dsp는 스피커 장치

예로, 'cat /boot/vmlinuz > /dev/dsp' 를 입력하면 커널의 소리를 스피커에서 들을 수 있다.

/dev/lp0로 파일을 보내면 인쇄를 한다.

일반적으로 'block device'를 데이터를 갖고 있거나 저장하는 장치(CD-ROM같은), 'character device'는 데이터를 전송 또는 변환하는 장치(예로 스피커나 프린터)

대부분의 장치 파일들은 설치과정에서 기본적으로 만들어진다. 실수로 특정 파일을 지웠다면 MAKEDEV * 을 실행하면 알려진 장치 파일들을 자동생성한다. → 옛날이야기. 요즘 리눅스에는 MAKEDEV가 없음. 다른 명령어 찾아봐야함

/dev/ttyS0 (First communications port, COM1)
First serial port (mice, modems).

/dev/psaux (PS/2)
PS/2 mouse connection (mice, keyboards).

/dev/lp0 (First printer port, LPT1)
First parallel port (printers, scanners, etc).

/dev/dsp (First audio device)
The name DSP comes from the term digital signal processor, a specialized processor chip optimized for digital signal analysis. Sound cards may use a dedicated DSP chip, or may implement the functions with a number of discrete devices. Other terms that may be used for this device are digitized voice and PCM.

/dev/usb (USB Devices)
This subdirectory contains most of the USB device nodes. Device name allocations are fairly simplistic so no elaboration is be necessary.

/dev/sda (C:\\, SCSI device)
First SCSI device (HDD, Memory Sticks, external mass storage devices such as CD-ROM drives on laptops, etc).

/dev/scd (D:\\, SCSI CD-ROM device)
First SCSI CD-ROM device.

/dev/js0 (Standard gameport joystick)
First joystick device.

/etc

설정관련 파일, 파일 내용 수정해서 각종 설정 수정가능. 일반적으로 binary 파일은 없음

[jihoon@localhost etc]$ ls
DIR_COLORS               audisp                   cron.monthly  dracut.conf.d  group        inittab        libnl                     modprobe.d                openldap    ppp             rc4.d           securetty      subgid              tmpfiles.d      yum.repos.d
DIR_COLORS.256color      audit                    cron.weekly   e2fsck.conf    group-       inputrc        libuser.conf              modules-load.d            opt         prelink.conf.d  rc5.d           security       subuid              tuned
DIR_COLORS.lightbgcolor  bash_completion.d        crontab       environment    grub.d       iproute2       locale.conf               motd                      os-release  printcap        rc6.d           selinux        sudo-ldap.conf      udev
GREP_COLORS              bashrc                   crypttab      ethertypes     grub2.cfg    issue          localtime                 mtab                      pam.d       profile         redhat-release  services       sudo.conf           vconsole.conf
NetworkManager           binfmt.d                 csh.cshrc     exports        gshadow      issue.net      login.defs                my.cnf                    passwd      profile.d       resolv.conf     sestatus.conf  sudoers             vimrc
OpenCL                   centos-release           csh.login     favicon.png    gshadow-     kdump.conf     logrotate.conf            my.cnf.d                  passwd-     protocols       rpc             shadow         sudoers.d           virc
X11                      centos-release-upstream  dbus-1        filesystems    gss          kernel         logrotate.d               netconfig                 pkcs11      python          rpm             shadow-        sysconfig           vulkan
adjtime                  chkconfig.d              default       firewalld      host.conf    krb5.conf      lvm                       networks                  pki         rc.d            rsyncd.conf     shells         sysctl.conf         wgetrc
aliases                  containerd               depmod.d      fstab          hostname     krb5.conf.d    machine-id                nsswitch.conf             plymouth    rc.local        rsyslog.conf    skel           sysctl.d            wpa_supplicant
aliases.db               cron.d                   dhcp          fuse.conf      hosts        ld.so.cache    magic                     nsswitch.conf.bak         pm          rc0.d           rsyslog.d       ssh            system-release      xdg
alternatives             cron.daily               dkms          gcrypt         hosts.allow  ld.so.conf     makedumpfile.conf.sample  ntp                       polkit-1    rc1.d           rwtab           ssl            system-release-cpe  xinetd.d
anacrontab               cron.deny                docker        gnupg          hosts.deny   ld.so.conf.d   man_db.conf               ntp.conf                  popt.d      rc2.d           rwtab.d         statetab       systemd             yum
asound.conf              cron.hourly              dracut.conf   groff          init.d       libaudit.conf  mke2fs.conf               nvidia-container-runtime  postfix     rc3.d           sasl2           statetab.d     terminfo            yum.conf

/home

사용자들의 폴더, 사용자 폴더가 home 하위 directory로 있음. 파일을 저장하거나 개인공간으로 사용한다.

개인설정파일들이 보통 숨김처리(.으로 시작하는 파일, 디렉토리)되어 있고 시스템 설정파일과 겹치는 경우 개인설정내용이 우선시된다.

/lib, /lib32, /lib64

커널 모듈과 시스템을 부팅하고 루트 파일 시스템에서 명령을 실행하는 데 필요한 공유 라이브러리 이미지 (C 프로그래밍 코드 라이브러리)가 포함

/bin 또는 /sbin 내의 프로그램 실행에 필요한 라이브러리도 포함

/media & /mnt

두개 다 파일시스템이 마운팅되는 포인트라는 점에서는 비슷합니다. 하지만 Media는 OS에서 자동으로 마운팅해주는 포인트로 주로 사용되며 Mnt는 사용자가 직접 마운트하는 경로로 사용됩니다. 예를들어 컴퓨터에 USB꽂아 OS에 자동으로 마운팅된다면 주로 Media 폴더 내에 마운팅 포인트가 생성되지만 외부에 있는 디스크등을 직접 명령어를 통해 마운트한다면 Mnt 디렉토리에 위치하게됩니다.

/opt

optional add-on application : 프로그램은 원래 자동으로 어디론가 저장되는데 지정해야되는경우 이 위치를 활용해도됨

/proc

prod에는 각 프로세스 이름에 따라 수많은 폴더들이 존재하고 현재 실행되는 프로세스에 대한 정보와 데이터가 담겨있습니다. 실제 디스크 공간에는 존재하지않는 가상의 디렉토리입니다. 현재 cpu에서의 사용값, IO포트 등등 프로세스에대한 다양한 정보가 들어있습니다.

/var

variable files , log같은 파일들, 파일들이 증가하거나 없어지거나 하는 내용

기타 모든 다용도로 사용될 수 있는 파일들이 저장되며 로그파일, 데이터베이스 캐싱파일, 웹서버 이미지 파일등이 위치할 수 있으며 파일의 크기가 추후 계속 확장될 수 있을경우 더욱 적합합니다.

/tmp

재부팅되면 다 삭제되는 임시 폴더

/usr

하위폴더로 bin , sbin등이 있음. 사용자가 설치하는 프로그램들이 usr아래 설치됨

주로 시스템에서 가장 많은 영역을 차지하며 루트유저와 자기 자신만 접근가능합니다. usr는 사실 하나의 파티션이 아니라 각각의 유저별로 다른 파티션으로 존재하기때문에 다른사용자들이 사용할 수 있도록 마운트할 수 있지만 이 경우 수정할수는 없습니다.

/cdrom

시디롬을 위한 마운팅 포인트지만 현재는 잘 사용되어지지않습니다.

/etc

etc 폴더는 대부분의 설정 파일들이 저장됩니다. 리눅스의 전신인 유닉스의 초창기에는 부팅과 관련한 모든 설정정보는 boot 폴더 디바이스와 관련된 설정 정보는 dev 폴더에 위치했지만 시간이 지나며 etcetera라는 이름의 etc 폴더를 만들어 설정 정보를 따로 보관했습니다. 이후 시간이 지나며 etc 뜻 그 자체처럼 시스템 전체에서 사용하는 설정과 같은 엑스트라 데이터들이 저장되는 폴더가 되었습니다.

/srv

srv 디렉토리는 서버를 위한 폴더입니다. 주로 FTP, SFTP, RSync와 같은 프로토콜을 이용하여 외부 사용자와의 공유를 위해 사용되며 다른디렉토리에비해 비교적 외부 사용자들이 쉽게 접근할 수 있습니다.

/sys

sys와 유사하며 실제 디스크의 물리적 영역이 아닌 RAM을 기반으로한 파일시스템입니다. 현재 커널 데이터에 대한 구조 속성등 현재 시스템 전반에 대한 내용을 제공합니다. 매번 다시 시작할때마다 새로 생성됩니다.

/tmp

세션정보나 혹은 워드프로세서에서 작업한다면 현재까지 저장되어있지 않은 현재 작업내용등이 저장됩니다.

예전에 플로피 디스크 용량 제한 때문에 컴퓨터 사용시 필요할때마다 필요한 디스크 바꿔끼워가면서 사용해야했기 때문에 폴더들을 구분했으나, bin-sbin, usr-home 등의 구분은 앞으로 없어지는 추세


댓글 쓰기

0 댓글