Linux / / 2023. 6. 5. 09:28

Linux리눅스 연습문제 - 기초4

728x90

 

 

 

 

1. ~/0602/down 디렉토리를 생성하시오.

더보기

mkdir -p ~/0602/down

 


2. ~/0602/down 디렉토리에 test1, test2 파일을 생성 하시오 

더보기

touch ~/0602/down/test1 ~/0602/down/test2

 


3. ~/0602/down 디렉토리에 있는 test1, test2 파일을 각각 test3, test4 파일로 /tmp   디렉토리에 복사하시오.
(test1 => test3, test2 => test4)

더보기

cp ~/0602/down/test1 /tmp/test3
cp ~/0602/down/test2 /tmp/test4

 


4. ~/0602/down 디렉토리에 test 디렉토리를 생성하시오. 

더보기

mkdir ~/0602/down/test

 


5. ~/0602/down/test 디렉토리를 /tmp 디렉토리로 이동 하시오 

더보기

mv ~/0602/down/test /tmp

 


6.find 명령어를 통해 /tmp 디렉토리내에 파일명 앞부분에 “test”문자열이 섞인 파일을 검색하면서 삭제 하시오.

더보기

find /tmp -name "test*" -exec rm -r {} \;

 


7.find 명령어를 통해 /etc/group 파일을 찾아서 ~/0602 디렉토리에 복사하시오.

더보기

find /etc/ -name "group" -exec cp -r {} ~/0602\;

 


8.find 명령어를 통해 ~/0602/group 파일을 찾아서 삭제하시오.(단 대화형으로)

더보기

find ~/0602/ -name "group" -exec rm -rf {} \;

 


9.find 명령어를 통해서 / 내에서 소유자가 user인 파일들을 모두 찾아서 자세하게 출력하시오.

더보기

find / -user user -ls

 


10.find 명령어를 통해서 /tmp 내에서 소유자가 user인 파일을 찾아서 삭제 하시오.

 

더보기

find /tmp -user user -exec rm -rf {} \;
find /tmp -user user -delete

 

 

"find -exec 생략이 가능한가??"

 

"Linux find -exec 생략" 에 대한 정리

🐋 문제 리눅스 기초연습문제이당 find 명령어를 통해서 / 내에서 소유자가 user 인 파일들을 모두 찾아서 자세하게 출력하시오. 내 풀이 find ~ -user user -exec ls -l {}\; 정답 풀이 find / -user user -ls 🐋

ms-sh0728.tistory.com

 

 

 

더보기
find 실습

1. ~/0602/down 디렉토리를 생성하시오.

mkdir ~/0602/down

2. ~/0602/down 디렉토리에 test1, test2 파일을 생성 하시오 

touch ~/0602/down/test1 ~/0602/down/test2

3. ~/0602/down 디렉토리에 있는 test1, test2 파일을 각각 test3, test4 파일로 /tmp   디렉토리에 복사하시오.
(test1 => test3, test2 => test4)

cp ~/0602/down/test1 /tmp/test3
cp ~/0602/down/test2 /tmp/test4

4. ~/0602/down 디렉토리에 test 디렉토리를 생성하시오. 

mkdir ~/0602/down/test

5. ~/0602/down/test 디렉토리를 /tmp 디렉토리로 이동 하시오 

mv ~/0602/down/test /tmp

6. find 명령어를 통해 /tmp 디렉토리내에 파일명 앞부분에 “test”문자열이 섞인 파일을 검색하면서 삭제 하시오.

find /tmp -name "test*" -exec rm -r {} \;

7.find 명령어를 통해 /etc/group 파일을 찾아서 /root/ 디렉토리에 복사하시오.

find /etc/ -name "group" -exec cp -r {} /root/ \;

8.find 명령어를 통해 ~/0602/group 파일을 찾아서 삭제하시오.(단 대화형으로)

find ~/0602 -name "group" -ok rm -r {} \;

9.find 명령어를 통해서 / 내에서 소유자가 user 인 파일들을 모두 찾아서 자세하게 출력하시오.

find / -user user -ls

or

find / -user user -exec ls -ild {} \;

10.find 명령어를 통해서 /tmp 내에서 소유자가 user인 파일을 찾아서 삭제 하시오.

find /tmp -user user -exec rm -r {} \;
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유