[리눅스] 파일 및 폴더 생성

Becoming a Data Engineer ·2023년 9월 6일
0

리눅스

목록 보기
2/9
post-thumbnail

touch : time 변경 또는 빈 파일 생성


change file timestamps

  • Update the access and modification times of each FILE to the current time.
hyojin@computer:~/test2$ ls -l
total 0
-rw-r--r-- 1 hyojin hyojin 14 Sep  5 16:14 memo.txt

hyojin@computer:~/test2$ touch memo.txt

hyojin@computer:~/test2$ ls -l
total 0
-rw-r--r-- 1 hyojin hyojin 14 Sep  5 16:16 memo.txt
  • A FILE argument that does not exist is created empty.
hyojin@computer:~/test2$ touch memo2.txt

hyojin@HDPL35175:~/test2$ ls -l
total 0
-rw-r--r-- 1 hyojin hyojin 14 Sep  5 16:16 memo.txt
-rw-r--r-- 1 hyojin hyojin 0 Sep  5 16:16 memo2.txt		>> 빈 파일로 생성됨

mkdir : 디렉토리 생성


makes directories

hyojin@computer:~/test2$ ls -l
total 4
-rw-r--r-- 1 hyojin hyojin 14 Sep  5 16:20 memo.txt
-rw-r--r-- 1 hyojin hyojin  0 Sep  5 16:16 memo2.txt

hyojin@computer:~/test2$ mkdir sub

hyojin@computer:~/test2$ ls -l
total 8
-rw-r--r-- 1 hyojin hyojin   14 Sep  5 16:20 memo.txt
-rw-r--r-- 1 hyojin hyojin    0 Sep  5 16:16 memo2.txt
drwxr-xr-x 2 hyojin hyojin 4096 Sep  5 16:24 sub
  • -p : no error if existing, make parent directories as needed
hyojin@computer:~/test2$ ls -l
total 8
-rw-r--r-- 1 hyojin hyojin   14 Sep  5 16:20 memo.txt
-rw-r--r-- 1 hyojin hyojin    0 Sep  5 16:16 memo2.txt
drwxr-xr-x 2 hyojin hyojin 4096 Sep  5 16:24 sub

hyojin@computer:~/test2$ mkdir sub2/sub2-1
mkdir: cannot create directory ‘sub2/sub2-1’: No such file or directory

hyojin@HDPL35175:~/test2$ mkdir -p sub2/sub2-1

hyojin@computer:~/test2$ ls -l
total 12
-rw-r--r-- 1 hyojin hyojin   14 Sep  5 16:20 memo.txt
-rw-r--r-- 1 hyojin hyojin    0 Sep  5 16:16 memo2.txt
drwxr-xr-x 2 hyojin hyojin 4096 Sep  5 16:24 sub
drwxr-xr-x 3 hyojin hyojin 4096 Sep  5 16:29 sub2

hyojin@computer:~/test2$ ls -l sub2
total 4
drwxr-xr-x 2 hyojin hyojin 4096 Sep  5 16:29 sub2-1
  • mkdir 디렉토리명 && cd 디렉토리명 : 디렉토리를 만들고 만든 디렉토리로 바로 이동
hyojin@computer:~$ mkdir sample && cd sample
hyojin@computer:~/sample$ pwd
/home/ubuntu/sample

file : 파일 타입 확인


determine file type (확장자명을 보고 파일의 타입을 결정하는 건 X)

profile
I want to improve more 👩🏻‍💻

0개의 댓글