아무 내용 없는 빈 파일을 생성하려면 touch 명령을 이용합니다. 원래 touch는 파일의 날짜와 시간 정보를 변경하는 명령인데 아무 옵션 없이 새로운 파일 이름을 지정해서 비어 있는 파일을 생성할 수 있습니다. touch [파일명] 형식으로 입력합니다. 실행 결과 크기가 0이고 접근 권한이 644인 빈 파일이 만들어집니다.
shinjaehun@losttemple:~$ touch teamdata
-rw-rw-r-- 1 shinjaehun shinjaehun 0 9월 22 09:39 teamdata
파일을 복사하는 명령은 cp(copy)입니다. cp [옵션] [원본파일] [사본파일] 형식으로 입력합니다. 현재 작업 디렉터리에 다른 이름의 파일을 복사해서 만듭니다.
shinjaehun@losttemple:~$ cp teamdata giants shinjaehun@losttemple:~$ ls -l giants -rw-rw-r-- 1 shinjaehun shinjaehun 0 9월 22 09:44 giants
원본 또는 사본의 경로를 직접 지정할 수도 있습니다. 다음 명령은 하위 디렉터리에 twins라는 파일을 복사할 것입니다.
shinjaehun@losttemple:~$ cp teamdata baseballteam/KBO/twins shinjaehun@losttemple:~$ ls -l baseballteam/KBO/twins -rw-rw-r-- 1 shinjaehun shinjaehun 0 9월 22 09:47 baseballteam/KBO/twins
baseballteam/KBO 디렉터리가 존재하지 않는다면 mkdir의 -p 옵션을 참고해서 생성합니다.
-R(recursive) 옵션을 붙이면 cp 명령은 디렉터리를 복사합니다.
shinjaehun@losttemple:~$ cp -r baseballteam/KBO/ baseballteam/MLB/ shinjaehun@losttemple:~$ ls -l baseballteam/ drwxrwxr-x 2 shinjaehun shinjaehun 4096 9월 22 16:42 KBO drwxrwxr-x 2 shinjaehun shinjaehun 4096 9월 22 17:13 MLB ...
mv(move) 파일을 이동하는 명령입니다. mv [옵션] [원본파일] [사본파일] 형식으로 입력합니다. cp와 달리 원본 파일이 삭제되므로 주의하기 바랍니다.
shinjaehun@losttemple:~$ mv giants baseballteam/KBO shinjaehun@losttemple:~$ ls giants ls: giants에 접근할 수 없습니다: 그런 파일이나 디렉터리가 없습니다 shinjaehun@losttemple:~$ cd baseballteam/KBO shinjaehun@losttemple:~/baseballteam/KBO$ ls giants twins
사용자 홈 디렉터리에 giants 파일이 존재하지 않으면 touch 명령으로 생성합니다.