절대경로 최상위 디렉토리(/)부터 시작해서 목표 디렉토리까지 가는 경로를 전부 기술하는 방식
절대경로로 경로를 기술할 때에는 최상위 디렉토리(/)가 붙는다.
상대경로 현재 자신이 있는 위치를 기준으로 이동하는 것을 뜻한다. 현재 자신의 위치는 .(마침표)로 표기한다.
절대경로와 상대경로의 경우는 mkdir과 cd를 통해 실습을 해보고자 한다.
# root 계정으로 들어오면 ~의 기호를 볼 수 있다.
# ~ 의 뜻은 pwd(디렉토리 정보출력)로 확인해보면 root계정에 대한 home 디렉토리라 볼 수 있다.
# 만약 다른 계정의 pwd를 확인해보면 계정에 대한 디렉토리 정보를 확인할 수 있다.
# root는 admin이기 때문에 따로 /home 디렉토리로 잡혀 있는 것은 아니다.
[root@localhost ~]# pwd
/root
[oracle@localhost ~]$ pwd
/home/oracle
# 절대경로로 a1 디렉토리에 b1/c1/d1을 생성하면 절대경로에 디렉터리를 생성했기 때문에
# 당연히 ~는 /root 디렉토리기 때문에 a1에 대한 디렉토리가 없음을 확인할 수 있다.
[root@localhost ~]# mkdir -p /a1/b1/c1/d1
[root@localhost ~]# ls
anaconda-ks.cfg original-ks.cfg test2.txt testjs test.sh test.tmp
# 상대경로로 a2 디렉토리 생성을 했을 경우에는 root 디렉토리에 생성 되어 있음을 확인 할 수 있다.
[root@localhost ~]# mkdir -p a2/b1/c1/d1
[root@localhost ~]# ls
a2 anaconda-ks.cfg original-ks.cfg test2.txt testjs test.sh test.tmp
[root@localhost a2]# pwd
/root/a2
# 현재 어떠한 경로에 위치해 있어도
[root@localhost ~]# ls
a2 anaconda-ks.cfg original-ks.cfg test2.txt testjs test.sh test.tmp
[root@localhost ~]# cd a2
[root@localhost a2]# pwd
/root/a2
[root@localhost a2]# ls
b1
# a2 디렉토리는 /root/a2에 위치 해있으나 cd와 절대경로(/)에 위치한 a1으로 이동
[root@localhost a2]# cd /a1
[root@localhost a1]# pwd
/a1
[root@localhost a1]# ls
b1
[root@localhost a1]# cd /a2
-bash: cd: /a2: No such file or directory
[root@localhost a1]# cd a2
-bash: cd: a2: No such file or directory
[root@localhost a1]# cd /root/a2/b1/c1/
[root@localhost c1]#
확실한 절대경로와 상대경로의 차이점 예시
c1 에서 ./root를 입력했을때와 / 이것 그리고 /root의 차이점을 확인해보면
c1 > ./root 의 경우는 찾을 수 없는 디렉토리라 표시되어 있는데 이는 c1 디렉토리 안에 root라는 폴더가 없기 때문이다.
c1 > /root 의 경우는 앞에 .(마침표)가 없기 때문에 최상위 디렉토리(/)에서의 root 디렉토리로 들어간 것이다.
c1 > / 는 최상위 경로인 /로 이동한 것이다.
[root@localhost c1]# cd ./root
-bash: cd: ./root: No such file or directory
[root@localhost c1]# cd /root
[root@localhost ~]# cd /a1/b1/c1/
[root@localhost c1]# cd /
[root@localhost /]#
'OS' 카테고리의 다른 글
리눅스 실습하기(chmod/chown)-01{2023년05월15~16일} (0) | 2023.05.16 |
---|---|
리눅스 명령어 {2023년05월12일, 15일} (1) | 2023.05.15 |
윈도우 공부하기-03{2023년05월09일} (0) | 2023.05.09 |
윈도우 공부하기-02 {2023년05월09일} (0) | 2023.05.09 |
윈도우 공부하기-01{2023년05월09일} (0) | 2023.05.09 |