ubuntu 16.04.7 | centos 7.4 | rhel6.8 | |
cat /etc/*-release 형태 OS 배포판에 따라 명칭이 다름 |
root@ubuntu16:~# cat /etc/os-release NAME="Ubuntu" VERSION="16.04.7 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.7 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial |
[root@centos7 ~]# cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) [root@centos7 ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) |
[root@rhel6 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.8 (Santiago) |
/boot 부팅영역 |
memtest86+_multiboot.bin 2016 memtest86+.elf memtest86+.bin vmlinuz-4.15.0-112 vmlinuz-4.15.0-142-generic grub & kernel, initrd 1)멀티부팅 시 메모리 테스트를 위한 memtest 도구 2)커널 업그레이드할 때 새로운 커널 버젼과 boot file 시스템의 리다이렉트 이미지가 생기게 됨. rpm -e 명령어 로 날리거나, rpm -Uvh 로 rollback 할 수 없게 기존 파일을 없앰. |
CentOS 7 이상부터 grub2가 나오고 해당 디렉터리 안에 grub.cfg grubenv 환경설정 할 수 있는 부분이 있음 |
cent 6이하까지는 /boot/grub까지만 있으며, grub2는 없음 |
/var /var/log/ middleware(web/was, DB)등의 로그도 여기 경로에 쌓임 |
실무적 접근
df 명령어를 활용하여 어디 마운트된 곳에서 많이 용량을 차지하는지, 파악하며, 해당 큰 용량이 찬 경로에
du 명령어를 활용 하거나 find 명령어로 용량 큰 것을 찾는다.
시스템 운영 시, 디스크 용량이 찬다고 SMS 문자를 수신받았 을 때 어떤쪽 디렉터리에 용량이 찾는지 파악하는
명령어는 find로도 활용할 수 있다.
보통 DB가 oracle 까지 사용하는 곳이면, oradata, oracle 이런식으로 80% 넘게 혹은 99%까지도 차있는데,
table space 공간만 크게 잡아놓았을 뿐, 실제 용량은 그만큼 아닐수도 있습니다. DBA와 같이 협력하여 확인했다.
보통 /tmp(예전에 올렸던 패키지 파일 또는 압축파일) 나 /var/log 에 있는 많이 쌓여있는 로그를 지울 때도 많다.
주의!)
파일에 따라서 cat /.. /../oracle>/dev/null 로 보내야 한다. 만약 rm 으로 지웠을 경우 물론 삭제를 해도 남아있는 걸로 보일 것이고, 심지어 오라클 DB 서비스를 다시 restart 시켜야 되는 경우도 있다.
신중히 삭제를 해야할지, null값으로 보낼지 파악해야 함.
[root@centos7 tmp]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-rootlv xfs 14G 3.0G 12G 21% /
devtmpfs devtmpfs 901M 0 901M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 9.0M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 143M 872M 15% /boot
/dev/sda2 vfat 1022M 12K 1022M 1% /boot/efi
tmpfs tmpfs 183M 20K 183M 1% /run/user/1000
/dev/sr0 iso9660 792M 792M 0 100% /run/media/test1/CentOS 7 x86_64
r[root@centos7 /]# find /root/tmp/ -name "*_test" -type d
/root/tmp/gcc_test
/root/tmp/gdb_test
/root/tmp/make_test
[root@centos7 /]# cd /root/tmp/
[root@centos7 tmp]# du -sh *
4.0K core_pattern~
4.0K core_patterr~
4.0K core_patters~
4.0K core_pattert~
4.0K core_patteru~
4.0K core_patterv~
4.0K core_patterw~
4.0K core_patterx~
4.0K core_pattery~
4.0K core_patterz~
16K creat
32K gcc_test
4.0K gdb_test
0 make_test
[root@centos7 tmp]# cd gcc_test/
[root@centos7 gcc_test]# du -sh *
4.0K hello.c
20K hello.i
4.0K hello.o
4.0K hello.s
2. find 명령어
find 경로 파일 type 옵션
find . -name “*.txt” | 내 현재 디렉토리에서부터 확장자가 .txt 인 파일을 찾는 법 |
find . -name “hello*” -type f find . -name “hello*” -type d |
내 현재 디렉토리에서 파일명이 hello로 시작하는 “파일” 만 찾는 법 내 현재 디렉토리에서 디렉토리명이 dir 로 시작하는 “디렉토리” 만 찾는 법 |
find . -size +100000000c | 내 현재 디렉토리에서 용량이 100,000,000바이트 (100M) 보다 큰 파일 찾는 법 |
• find . -size +100000000c <-- 여기 100000000c 대신 100000k 또는 100M 사용 가능 최근 생성된 파일만 찾아보기 (2020년 5월 15일 이후 변경된 파일
• find -newerct “15 May 2020” -ls <-- 여기 newerct 대신 newermt 로 할 경우 최근 변경된 최근 2일에서 5일 사이에 변경된 파일 찾기
• find . -mtime +2 -a -mtime -5 -ls
[root@centos7 gcc_test]# find . -mtime +2 -a -mtime -5 -ls
8426065 0 drwxr-xr-x 2 root root 66 Oct 30 03:55 .
8426068 4 -rw-r--r-- 1 root root 62 Oct 29 23:44 ./hello.c
8426066 20 -rw-r--r-- 1 root root 16863 Oct 29 23:58 ./hello.i
8426070 4 -rw-r--r-- 1 root root 434 Oct 30 00:31 ./hello.s
8426071 4 -rw-r--r-- 1 root root 1496 Oct 30 00:45 ./hello.o
2-2 find 명령어 심화 응용
RHCSA 7에서도 나왔던 형태의 명령어 이다.
root@ubuntu16:~# find / -size +100M -exec ls -l {} \; 2>/dev/null
-rw-r--r-- 1 root root 122241544 7월 2 2020 /usr/lib/thunderbird/libxul.so
-rw-r--r-- 1 root root 142557760 4월 17 2021 /usr/lib/firefox/libxul.so
-r-------- 1 root root 140737477881856 11월 4 01:56 /proc/kcore
=> 경로는 루트(/) 디렉터리로부터 파일사이즈가 +100M이상인 파일을 찾아서 명령어 및 옵션이 ls -l로 표시하기
root@ubuntu16:~# find / -name "*.txt" -exec grep "HELP" {} \; -print 2>/dev/null
HOW TO OBTAIN HELP
/usr/share/vim/vim74/doc/help.txt
=> 경로는 루트(/) 디렉터리로부터 .txt라고 하는 파일들을 찾아서 그안에 HELP라는 글자가 포함된 파일과 내용을 표시할 것
[root@centos7 /]# find / -size 5M -exec ls -l {} \; 2>/dev/null
-rwxr-xr-x. 1 root root 4859392 Aug 4 2017 /usr/bin/ld.gold
-rwxr-xr-x 1 root root 4497120 Aug 9 2019 /usr/lib64/clang-private/libclangCodeGen.so.7
-rwxr-xr-x 1 root root 4817936 Aug 2 2017 /usr/lib64/libgtk-x11-2.0.so.0.2400.31
-rw-r--r-- 1 root root 5001317 Nov 20 2015 /usr/share/libtimezonemap/ui/cities15000.txt
-rw-rw-r-- 1 test1 test1 4940381 Nov 1 11:38 /home/test1/.mozilla/firefox/vjdul1ln.default-release/security_state/data.safe.bin
-rw-r--r-- 1 test1 test1 5242880 Oct 26 17:48 /home/test1/.mozilla/firefox/vjdul1ln.default-release/places.sqlite
-rw-r--r-- 1 test1 test1 5242880 Oct 26 17:41 /home/test1/.mozilla/firefox/vjdul1ln.default-release/favicons.sqlite
root@ubuntu16:/tmp/fs_test# ll
total 12
drwxr-xr-x 2 root root 4096 11월 4 10:26 ./
drwxrwxrwt 12 root root 4096 11월 4 10:31 ../
-rwxr-xr-x 1 root root 6 11월 4 10:27 hello.txt*
root@ubuntu16:/tmp/fs_test# find . -name "hello.txt" -delete // find 명령어로 파일을 찾아서 삭제시키는 옵션도 있음.
root@ubuntu16:/tmp/fs_test# ll
total 8
drwxr-xr-x 2 root root 4096 11월 4 10:39 ./
drwxrwxrwt 12 root root 4096 11월 4 10:39 ../
3. stat 명령어
파일의 상태를 확인할 수 있는 명령어이다.
[root@centos7 gcc_test]# du -sh *
4.0K hello.c
20K hello.i
4.0K hello.o
4.0K hello.s
[root@centos7 gcc_test]#
[root@centos7 gcc_test]# sta
startx stat
[root@centos7 gcc_test]# stat hello.i
File: ‘hello.i’
Size: 16863 Blocks: 40 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 8426066 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-10-29 23:59:06.139904572 +0900
Modify: 2021-10-29 23:58:45.463270805 +0900
Change: 2021-10-29 23:58:45.463270805 +0900
• Access : 파일에 최근 접근 시간(1번만 접근 시 변경되고 그이후 변경 없음)
• Modify : 파일의 내용 변경 시간
• Change : 파일의 수정 시간 (inode 관점에서의 변화 시간 - 생성, 변경, 속성수정 등)
root 계정으로 만들었기 때문에 Uid , Gid가 0이다.
보통 파일은 default 0644 권한으로 생성되며 디렉터리는 defaul 0755
아래는 /tmp/fs_test 의 디렉터리 상태를 보는 것임.
oot@ubuntu16:/tmp/fs_test# stat /tmp/fs_test/
File: '/tmp/fs_test/'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 801h/2049d Inode: 11087 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-11-04 10:26:57.171000000 +0900
Modify: 2021-11-04 10:26:55.515000000 +0900
Change: 2021-11-04 10:26:55.515000000 +0900
Birth: -
root@ubuntu16:/tmp/fs_test# cat hello.txt
hello
root@ubuntu16:/tmp/fs_test# echo world > hello.txt
root@ubuntu16:/tmp/fs_test# cat hello.txt
world
root@ubuntu16:/tmp/fs_test# echo world2 >> hello.txt
root@ubuntu16:/tmp/fs_test# cat hello.txt
world
world2
* > 리다이렉션의 1개와 2개일때의 차이점은 다음과 같다.
> : 1개일 때는 기존의 파일 내용을 변경한다.
>> : 2개일 때는 기존 내용에서 덧붙이는 역할을 한다.
'OS Linux[centos,RHEL] > 구조 (부팅 및 커널)' 카테고리의 다른 글
PAM(Pluggable Authentication Modules) (1) | 2021.11.05 |
---|