이 연재글은 Linux command 알아보기의 2번째 글입니다.

touch – 빈 파일 생성

$) touch hello.txt

mkdir – 디렉터리 생성

$) mkdir hellodir

rm – 파일 삭제

$) rm hello.txt

rm – 확인 없이 파일 삭제

$) rm -f hello.txt

rm – 확인 없이 디렉터리 삭제.

$) rm -rf hellodir

rm – 디렉터리 하위의 mov 확장자 파일을 모두 삭제

$) rm /hello/*.mov

cp – 파일 복사

$) cp hello.txt hello2.txt

cp – 디렉터리 하위의 모든 파일과 디렉터리를 다른 디렉터리로 복사

$) cp -R /hello /hello2

mv – 파일을 이동

$) mv hello.txt /hi/hello.txt

mv – 파일명 변경. 같은 디렉터리 내에서 없는 커맨드를 호출하면 이름이 변경된다.

$) mv hello.txt hello2.txt

mv – 디렉토리 이동/복사. hellodir2가 존재하면 하위로 hellodir이 이동되고 없으면 hellodir의 이름이 hellodir2로 이름이 변경된다.

$) mv /ubuntu/hellodir /ubuntu/hellodir2

du – 디렉토리내 파일, 디렉터리들의 용량 확인(disk usage)

$ du 44	./deps/hiredis/adapters 40	./deps/hiredis/examples 1304	./deps/hiredis 368	./deps/jemalloc/bin 88	./deps/jemalloc/build-aux 324	./deps/jemalloc/doc 684	./deps/jemalloc/include/jemalloc/internal 768	./deps/jemalloc/include/jemalloc 12	./deps/jemalloc/include/msvc_compat/C99 20	./deps/jemalloc/include/msvc_compat 788	./deps/jemalloc/include 16	./deps/jemalloc/m4 24	./deps/jemalloc/msvc/projects/vc2015/jemalloc

du – 해당 디렉터리 용량 확인

$ du -hs redis-5.0.4 115M	redis-5.0.4

du – 현재 디렉터리에 있는 디렉터리 및 파일 용량 확인

$ du -hs * 100K	00-RELEASENOTES 8.0K	MANIFESTO 4.0K	Makefile 24K	README.md 61M	deps 64K	redis.conf 4.0K	runtest-sentinel 12K	sentinel.conf 53M	src 796K	tests 160K	utils

du – 현재 디렉터리에 있는 디렉터리 및 파일 중에서 용량이 큰것순으로 5개 보기

$ du -hsx * | sort -rh | head -n 5 61M	deps 53M	src 796K	tests 160K	utils 100K	00-RELEASENOTES

df – 리눅스 디스크 사용량 확인

$ df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 485712 0 485712 0% /dev tmpfs 503624 0 503624 0% /dev/shm tmpfs 503624 492 503132 1% /run tmpfs 503624 0 503624 0% /sys/fs/cgroup /dev/xvda1 8376300 5294644 3081656 64% / tmpfs 100728 0 100728 0% /run/user/1000

df – 읽기 쉽게 보기

$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 475M 0 475M 0% /dev tmpfs 492M 0 492M 0% /dev/shm tmpfs 492M 492K 492M 1% /run tmpfs 492M 0 492M 0% /sys/fs/cgroup /dev/xvda1 8.0G 5.1G 3.0G 64% / tmpfs 99M 0 99M 0% /run/user/1000

연재글 이동[이전글] Linux Command – cd, dirname, basename, id, uname, cpuinfo, meminfo, locale, ps, kill, top