Computer >> 컴퓨터 >  >> 프로그램 작성 >> BASH 프로그래밍

Linux cd 명령:디렉토리 변경

이 튜토리얼은 Linux에서 cd ​​명령을 사용하여 쉘 내에서 현재 있는 디렉토리를 변경하는 방법을 설명합니다.

우리는 이전에 ls를 사용하여 디렉토리를 둘러보는 방법을 다루었습니다. 그러나 이제 디렉토리 탐색을 시작해야 합니다. cd를 사용하면 쉽게 할 수 있습니다. , 디렉토리를 변경합니다. 간단한 것부터 시작하겠습니다. cd와 같은 간단한 베이크 인 유틸리티에 대해 자세히 알아보려면 ? 시도하는 경우:

man cd

"CD에 대한 수동 입력 없음"이 보고됩니다. 대부분의 가능성이 있습니다. 구운 유틸리티 대신 도움말을 사용하세요.

help cd

CD 구문

이제 유용한 도움말 유틸리티를 실행했습니다. 우리는 다음과 같은 결과를 얻었습니다.

cd: cd [-L|[-P [-e]] [admin@wsxdn.com]] [dir]
Change the shell working directory.


Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.


The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.


If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.


Options:
-L force symbolic links to be followed: resolve symbolic
links in DIR after processing instances of `..'
-P use the physical directory structure without following
symbolic links: resolve symbolic links in DIR before
processing instances of `..'
-e if the -P option is supplied, and the current working
directory cannot be determined successfully, exit with
a non-zero status
admin@wsxdn.com on systems that support it, present a file with extended
attributes as a directory containing the file attributes


The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.


Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.

솔직히? CD 도움말 인쇄물을 본 것은 처음입니다. 기본적인 사용법을 알아보겠습니다.

cd ~

물결표는 현재 홈 디렉토리를 참조하는 특수 문자입니다. cd ~를 사용하시면 집으로 보내드립니다. 그것이 무엇인지 알고 싶다면:

echo $HOME

홈 디렉토리를 인쇄합니다.

cd ..

.. 또한 특별한 참조입니다. 현재 작업 디렉토리의 상위 디렉토리를 참조합니다. cd .. 입력 위의 디렉토리로 이동합니다. 다음을 입력하여 더 높은 레벨을 추가할 수 있습니다.

cd ../..

두 번 진행됩니다.

cd /

/ 시스템의 루트를 나타냅니다. "cd /" 입력 액세스 권한이 있는 경우 루트로 이동합니다.

결론

그게 다야! 쉘 사용을 위한 멋지고 간단한 작업 팁.