Information Communication Technology/LINUX

Linux ls, cd, rm, cp , touch, mv, mkdir, rmdir, head, tail, more, less, clear 등

반응형

▶ls

list. 현재 위치한 디렉터리 안에 있는 파일이나 디렉터리의 목록을 나열하는 명령어.

ls [option] [directory]

▷ls option

[-a], [-all] : 현재 위치한 디렉터리 안에 있는 모든 파일들(숨긴 파일을 포함한)을 보여준다.
[-l] : 현재 위치한 디렉터리 안에 있는 파일 혹은 디렉터리들을 자세하게 보여준다.
ls -al : 디렉터리 안에 있는 모든 파일 혹은 디렉터리들을 자세하게 출력해준다.

실행)

root@server:~/바탕화면#ls-al
합계 12
drwxr-xr-x 2 rootroot40969월 516:35.
drwx------16 rooroot409612월 262021..
-rw-r--r--1 rootroot1039월 516:30 example

▶cd

Change Directory. 현재 위치에서 다른 디렉터리로 옮기고자 할 때 사용하는 명령어.

cd [option] [directory]

실행)

root@server:~/바탕화면# cd exampledir/
root@server:~/바탕화면/exampledir#

▶rm

Remove. 파일이나 디렉터리를 제거하는 명령어.

rm [option] [file or directory]

▷rm option

[-r] : recursive. 재귀적의 하위 디렉터리까지 적용됨.
[-f] : force. 강제적으로 명령.
[-i] : 해당 파일 혹은 디렉터리를 정말 삭제할 것인지 확인 메시지가 출력됨.
rm -rf [file or directory] :강제적으로 파일 혹은 디렉터리를 삭제하는데 그 하위 파일 혹은 하위 디렉터리까지 삭제한다.

실행)

root@server:~# mkdir exampledir
root@server:~# ls
exampledir snap 공개 다운로드 문서 바탕화면 비디오 사진 음악 템플릿
root@server:~# rm -rf exampledir
root@server:~# ls
snap 공개 다운로드 문서 바탕화면 비디오 사진 음악 템플릿

▶cp

copy. 파일 혹은 디렉터리를 복사하는 명령어이다.

cp [option] [before] [after]

▷copy option

[-r] : 디렉터리를 복사할 때 사용.

실행)

root@server:~# cp -r exampledir exampledir2
root@server:~# ls
exampledir snap 다운로드 바탕화면 사진 템플릿
exampledir2 공개 문서 비디오 음악

▶touch

touch. 사이즈가 0인 새로운 파일을 생성해주는 명령어. 만약 명령어에 작성한 파일이 이미 있다면 최종 수정 시간을 변경하고 수정 가능하다.

touch [option] [file]

▷touch option

[-a] : 접근 시간만 변경한다.
[-c], [--no-create] : 어떠한 파일도 생성하지 않는다.
[-d] : 현재 날짜 적용.

실행)

root@server:~# touch example
root@server:~# ls
example exampledir2 공개 문서 비디오 음악
exampledir snap 다운로드 바탕화면 사진 템플릿

▶mv

move. 파일이나 디렉터리를 이동시키는 명령어이다.

mv [option] [원본] [directory]

▷mv option

[-t] : target directory. 옮기고 싶은 디렉터리.
[-f] : force. 강제로 이동.

실행)

root@server:~# mv example exampledir
root@server:~# cd exampledir
root@server:~/exampledir# ls
example

▶mkdir

make directory. 디렉터리를 만드는 명령어이다.

mkdir [option] [new directory]

▷mkdir option

[-p] : parent. 새로 만드는 디렉터리의 부모 디렉터리가 없다면 자동으로 생성시킴.

실행)

root@server:~/바탕화면# mkdir exampledir
root@server:~/바탕화면# ls -al
합계 16
drwxr-xr-x 3 root root 4096 9월 7 16:59.
drwx------ 16 root root 4096 12월 26 2021..
-rw-r--r-- 1 root root 103 9월 5 16:30 example
drwxr-xr-x 2 root root 4096 9월 7 16:59 exampledir

▶rmdir

remove directory. 디렉터리를 삭제하는 명령어이다.

rmdir [option] [directory]

실행)

root@server:~# rmdir exampledir
rmdir: failed to remove 'exampledir': 디렉터리가 비어있지 않음
root@server:~# rm -rf exampledir
root@server:~# ls
exampledir2 snap 공개 다운로드 문서 바탕화면 비디오 사진 음악 템플릿

▶cat

▶head & tail

▶more & tail

▶clear




반응형