리눅스 / 명령어 / cd / 다른 디렉토리로 이동하는 명령어
cd
cd는 change directory의 약자로, 다른 디렉토리로 이동하는 명령어입니다.
cd
- 현재 로그인한 사용자의 홈 디렉토리로 이동합니다.
- 일반적으로 root 계정이라면 /root로, 사용자 jb 계정이라면 /home/jb로 이동합니다.
cd ~user
- user의 홈 디렉토리로 이동합니다.
- 다음과 같이 명령하면 jb 사용자의 홈 디렉토리로 이동합니다.
cd ~jb
cd 디렉토리명
- 지정한 디렉토리로 이동합니다. 절대경로, 상대경로 다 사용할 수 있습니다.
- 다음과 같이 명령하면 /etc 디렉토리로 이동합니다.
cd /etc
- 현재 디렉토리에 속한 디렉토리 중 abc 디렉토리로 이동합니다.
cd abc
cd ..
- 상위 디렉토리로 이동합니다.
- 예를 들어 현재 위치가 /a/b라면, /a로 이동합니다.
cd -
- 이전에 위치했던 디렉토리로 이동합니다.
- 예를 들어 /root에서 /var 디렉토리로 이동한 다음 'cd -'를 명령하면 /root로 이동합니다.
기타
- 'cd .'은 현재 디렉토리로 이동합니다. 에러는 나지 않지만, 의미가 없습니다.
- 현재 디렉토리를 확인하는 명령어는 pwd입니다.
같은 카테고리의 다른 글
리눅스 / 그룹 / 그룹 조회, 그룹 추가, 그룹 삭제, 그룹 수정
그룹 조회 그룹 목록은 /et/group 파일에 있습니다. cat 명령어로 전체를 조회하거나... cat /etc/group tail 명령어로 마지막 부분을 조회할 수 있습니다. # tail -n 5 /etc/group avahi:x:70: slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: X:Y:Z 형식으로 나오는데, X는 그룹 이름, Y는 그룹 비밀번호, Z는 그룹 ID입니다. 그룹 추가 groupadd 명령으로 그룹을 추가합니다. # groupadd group-1 # tail -n 5 /etc/group slocate:x:21: rngd:x:974: tcpdump:x:72: vboxsf:x:973: group-1:x:1000: 그룹 삭제 groupdel 명령으로 그룹을 삭제합니다. # ...
리눅스 / 사용자 / 사용자 조회, 사용자 추가, 사용자 삭제, 사용자 수정
사용자 조회 모든 사용자를 출력합니다. # cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin ... root과 useradd 또는 adduser를 통해 생성한 사용자 계정을 출력합니다. # grep /bin/bash /etc/passwd root:x:0:0:root:/root:/bin/bash jb:x:1000:1000:JB:/home/jb:/bin/bash 사용자 추가 useradd jb 사용자를 만듭니다. useradd jb 사용자 홈 디렉토리도 같이 만들고 싶다면 -d 옵션을 사용합니다. useradd jb -d /home/jbdir jb 사용자의 비밀번호를 만듭니다. passwd jb adduser adduser 명령어로 사용자를 추가할 수 있습니다. useradd와는 달리 사용자 홈 디렉토리를 자동으로 만들고, 비밀번호 ...
리눅스 / 명령어 / rdate / 타임서버의 시간과 동기화해주는 명령어
rdate는 서버의 시간과 타임서버의 시간을 동기화해주는 명령어입니다. rdate는 설치되어있지 않는 경우가 많으므로, 필요하다면 설치를 해야 합니다. CentOS라면 yum install rdate Ubuntu라면 apt install rdate 와 같이 명령하여 설치할 수 있습니다. 타임서버의 시간을 확인할 때는 -p 옵션을 사용합니다. 현재 서버의 시간을 변경하지 않습니다. rdate -p time.bora.net 현재 서버의 시간을 타임서버의 시간으로 맞출 때에는 -s 옵션을 붙입니다. rdate -s time.bora.net CentOS ...
리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기
명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있습니다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용합니다. 각 명령어로 find 명령어를 찾아보겠습니다. # which find /usr/bin/find # whereis find find: /usr/bin/find /usr/share/man/man1/find.1.gz # locate find /usr/bin/find /usr/bin/find2perl /usr/bin/findmnt /usr/bin/nl-link-ifindex2name /usr/bin/nl-link-name2ifindex /usr/bin/oldfind /usr/lib64/python2.7/modulefinder.py /usr/lib64/python2.7/modulefinder.pyc /usr/lib64/python2.7/modulefinder.pyo /usr/sbin/btrfs-find-root /usr/sbin/findfs /usr/share/bash-completion/completions/findmnt /usr/share/doc/findutils-4.5.11 /usr/share/doc/findutils-4.5.11/AUTHORS /usr/share/doc/findutils-4.5.11/COPYING /usr/share/doc/findutils-4.5.11/ChangeLog /usr/share/doc/findutils-4.5.11/NEWS /usr/share/doc/findutils-4.5.11/README /usr/share/doc/findutils-4.5.11/THANKS /usr/share/doc/findutils-4.5.11/TODO /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_find.py /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_stop_find.py /usr/share/info/find-maint.info.gz /usr/share/info/find.info.gz /usr/share/locale/be/LC_MESSAGES/findutils.mo /usr/share/locale/bg/LC_MESSAGES/findutils.mo /usr/share/locale/ca/LC_MESSAGES/findutils.mo /usr/share/locale/cs/LC_MESSAGES/findutils.mo /usr/share/locale/da/LC_MESSAGES/findutils.mo /usr/share/locale/de/LC_MESSAGES/findutils.mo /usr/share/locale/el/LC_MESSAGES/findutils.mo /usr/share/locale/eo/LC_MESSAGES/findutils.mo /usr/share/locale/es/LC_MESSAGES/findutils.mo /usr/share/locale/et/LC_MESSAGES/findutils.mo /usr/share/locale/fi/LC_MESSAGES/findutils.mo /usr/share/locale/fr/LC_MESSAGES/findutils.mo /usr/share/locale/ga/LC_MESSAGES/findutils.mo /usr/share/locale/gl/LC_MESSAGES/findutils.mo /usr/share/locale/hr/LC_MESSAGES/findutils.mo /usr/share/locale/hu/LC_MESSAGES/findutils.mo /usr/share/locale/id/LC_MESSAGES/findutils.mo /usr/share/locale/it/LC_MESSAGES/findutils.mo /usr/share/locale/ja/LC_MESSAGES/findutils.mo /usr/share/locale/ko/LC_MESSAGES/findutils.mo /usr/share/locale/lg/LC_MESSAGES/findutils.mo /usr/share/locale/lt/LC_MESSAGES/findutils.mo /usr/share/locale/ms/LC_MESSAGES/findutils.mo /usr/share/locale/nl/LC_MESSAGES/findutils.mo /usr/share/locale/pl/LC_MESSAGES/findutils.mo /usr/share/locale/pt/LC_MESSAGES/findutils.mo /usr/share/locale/pt_BR/LC_MESSAGES/findutils.mo /usr/share/locale/ro/LC_MESSAGES/findutils.mo /usr/share/locale/ru/LC_MESSAGES/findutils.mo /usr/share/locale/rw/LC_MESSAGES/findutils.mo /usr/share/locale/sk/LC_MESSAGES/findutils.mo /usr/share/locale/sl/LC_MESSAGES/findutils.mo /usr/share/locale/sr/LC_MESSAGES/findutils.mo /usr/share/locale/sv/LC_MESSAGES/findutils.mo /usr/share/locale/tr/LC_MESSAGES/findutils.mo /usr/share/locale/uk/LC_MESSAGES/findutils.mo /usr/share/locale/vi/LC_MESSAGES/findutils.mo /usr/share/locale/zh_CN/LC_MESSAGES/findutils.mo /usr/share/locale/zh_TW/LC_MESSAGES/findutils.mo /usr/share/man/man1/find.1.gz /usr/share/man/man1/find2perl.1.gz /usr/share/man/man1/oldfind.1.gz /usr/share/man/man8/btrfs-find-root.8.gz /usr/share/man/man8/findfs.8.gz /usr/share/man/man8/findmnt.8.gz locate 명령어는 -n 옵션으로 출력 개수를 정할 수 있습니다. # locate ...
리눅스 / 명령어 / rmdir / 빈 디렉토리 삭제하는 명령어
rmdir rmdir은 빈 디렉토리를 삭제하는 명령어입니다. Remove the DIRECTORY(ies), if they are empty. 사용법 rmdir directory a 디렉토리를 삭제합니다. rmdir a 비어있다면 삭제를 하고, 그렇지 않다면 다음을 출력합니다. rmdir: failed to remove ‘a’: Directory not empty rmdir --ignore-fail-on-non-empty directory 디렉토리가 비어있지 않아도 메시지를 출력하지 않습니다. rmdir -v directory 현재 디렉토리 안에 있는 모든 비어있는 디렉토리를 삭제합니다. v 옵션을 넣으면 작업 결과를 출력합니다. rmdir -v ...
명령어 개요 adduser 사용자 추가하는 명령어. alias 명령어 별칭을 만든다. cal calendar. 달력을 출력하는 명령어. cat concatenate. 파일 내용 출력하는 명령어. cd change directory. 다른 디렉토리로 이동하는 명령어. chmod 파일 또는 디렉토리의 읽기, 쓰기, 실행 권한 설정하는 명령어 chown 파일 또는 디렉토리의 소유자(그룹) 설정하는 명령어 clear 터미널 화면의 내용을 다 지운다. cp copy. 파일 또는 디렉토리 복사. du disk usage. 디스크 사용량 출력. file 파일의 종류를 출력하는 명령어 find 파일 또는 디렉토리를 검색하는 명령어 history 이전에 실행한 ...
리눅스 / 명령어 / ls / 디렉토리와 파일 목록 출력하는 명령어
ls는 list의 약어로, 디렉토리와 파일 목록을 출력하는 명령어이다. ls 디렉토리명 디렉토리에 속한 디렉토리와 파일 목록을 출력한다. 숨김 파일은 나오지 않는다. 디렉토리명을 생략하면 현재 디렉토리에 속한 디렉토리와 파일 목록을 출력한다. 예를 들어 다음과 같이 명령하면 /var 디렉토리에 속한 디렉토리와 파일 목록을 출력한다. ls /var ls -a, ls -l -a 옵션을 붙이면 숨김 파일도 출력한다. -l 옵션을 붙이면 소유자, 파일 크기 ...
리눅스 / 로그아웃 명령어, 재부팅 명령어, 종료 명령어
로그아웃 명령어 logout exit 재부팅 명령어 즉시 재부팅 reboot shutdown -r now init 6 일정 시간 또는 일정 시간 후 재부팅 10분 후 재부팅 shutdown -r 10 12시에 재부팅 shutdown -r 12:00 취소 shutdown -c 종료 명령어 즉시 종료 poweroff shutdown -h now shutdown -P now halt -p init 0 일정 시간 또는 일정 시간 후에 종료 10분 후에 종료 shutdown -P 10 13시에 종료 shutdown -P 13:00 취소 shutdown -c 기타 10분 후에 종료할 거라는 메시지를 사용자에게 보내지만, 종료하지는 ...
rsync는 동기화 프로그램이다. 백업할 때 유용하게 사용할 수 있다. 사용법 기본 rsync -avz /abc/def /xyz abc 디렉토리 안의 def 디렉토리를 xyz 디렉토리 안에 동기화시킨다. 처음 실행하는 것이라면 xyz 디렉토리 안에 def 디렉토리가 복사된다. 다시 실행시키면 /abc/def 디렉토리의 내용 중 수정되거나 추가된 것만 /xyz/def 디렉토리로 복사된다. /abc/def에서 삭제된 내용은 /xyz/def에 반영되지 않는다. rsync -avz /abc/def/ /xyz def 뒤에 /를 붙이면 ...
리눅스 / 명령어 / rm / 파일 또는 디렉토리 삭제하는 명령어
rm은 remove의 약자로, 파일 또는 디렉토리를 삭제하는 명령어입니다. 파일 삭제하기 abc.txt 파일을 삭제합니다. 삭제할 건지 다시 묻습니다. y 또는 yes를 입력하면 삭제합니다. rm abc.txt 확장자가 txt인 모든 파일을 삭제합니다. 각 파일에 대해서 삭제할 건지 묻습니다. rm *.txt 현재 디렉토리에 있는 모든 파일을 삭제합니다. 각 파일에 대해서 삭제할 건지 묻고, 디렉토리가 있다면 삭제할 수 없다는 메시지가 나옵니다. rm ...