Linux 폴더 이름 바꾸기 명령

저는 새로운 Linux 시스템 사용자입니다. 명령 줄을 사용하여 Linux 운영 체제에서 폴더 이름을 바꾸려면 어떻게합니까? bash 명령 줄 옵션을 통해 디렉터리 이름을 바꾸려면 어떻게해야합니까?
파일 및 디렉터리 / 폴더의 이름을 바꾸고 이동하려면 mv 명령을 사용해야합니다. 모든 것은 폴더를 포함하여 Linux 또는 Unix와 유사한 운영 체제의 파일입니다.

Linux 폴더 이름 바꾸기 명령

Linux에서 폴더 또는 디렉토리 이름을 바꾸는 절차 :

  1. 터미널 응용 프로그램을 엽니 다.
  2. foo 이름을 바꾸려면 다음 명령을 입력합니다. 폴더에서 막대로 :
    mv foo bar
    전체 경로도 사용할 수 있습니다.
    mv / home / vivek / oldfolder / home / vivek / newfolder

보자 자세한 예제와 구문.

Linux에서 폴더 이름을 바꾸는 방법

pwd 명령은 현재 작업 디렉토리를 보여줍니다.
pwd
샘플 출력 :

/home/vivek/

mv 명령 구문 형식은 다음과 같습니다.
mv old-name new-name
mv old-name new-name
mv source target

현재 디렉토리의 mypictures에 pics라는 디렉토리 :
pwd
ls -l
mv pics mypictures

ls 명령을 사용하여 확인합니다.
ls -l
mypictures 폴더가 pics f와 같은 디렉토리에있는 경우 이전에는 pics 폴더의 이름 만 바꿀 수 있습니다. 따라서 항상 pwd 명령과 ls 명령을 사용하여 현재 작업 디렉토리를 찾습니다.

Linux에서 폴더를 이동하는 방법

다음 명령은 이름을 변경하지 않고 현재 폴더에서 accounts라는 폴더를 이동합니다. / mnt / backups / :
mv accounting /mnt/backups/
전체 경로도 지정할 수 있습니다.
mv /home/vivek/accounting/ /mnt/backups/
여러 파일 / 폴더를 이동하겠습니다. 다음 mv 명령은 해당 디렉토리의 모든 내용을 포함하여 모든 파일과 디렉토리를 현재 디렉토리에서 / raid / home / new / vivek / :
mv * /raid/home/new/vivek/ 디렉토리로 이동합니다.
별표는 현재 디렉토리의 일부 또는 모든 파일을 나타내는 와일드 카드 문자입니다. 폴더 이름을 바꾸거나 폴더를 이동할 때 확인을 받으려면 -i too mv 명령을 전달하여 파일 / 폴더 덮어 쓰기를 방지하려면 :
mv -i file.doc ~/Documents/
또는
mv -i ExcelFiles ~/Documents/
샘플 출력 :

mv: overwrite "/home/vivek/Documents/ExcelFiles"? 

도움말 얻기

man을 읽으려면 CLI에서 다음 명령을 실행하십시오. 모든 옵션에 대한 mv 페이지 :
man mv
또는
mv --help
샘플 출력 :

Usage: mv ... SOURCE DEST or: mv ... SOURCE... DIRECTORY or: mv ... -t DIRECTORY SOURCE...Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. Mandatory arguments to long options are mandatory for short options too. --backup make a backup of each existing destination file -b like --backup but does not accept an argument -f, --force do not prompt before overwriting -i, --interactive prompt before overwrite -n, --no-clobber do not overwrite an existing fileIf you specify more than one of -i, -f, -n, only the final one takes effect. --strip-trailing-slashes remove any trailing slashes from each SOURCE argument -S, --suffix=SUFFIX override the usual backup suffix -t, --target-directory=DIRECTORY move all SOURCE arguments into DIRECTORY -T, --no-target-directory treat DEST as a normal file -u, --update move only when the SOURCE file is newer than the destination file or when the destination file is missing -v, --verbose explain what is being done -Z, --context set SELinux security context of destination file to default type --help display this help and exit --version output version information and exit The backup suffix is "~", unless set with --suffix or SIMPLE_BACKUP_SUFFIX.The version control method may be selected via the --backup option or throughthe VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups

이름 바꾸기 명령에 대한 참고 사항

많은 Linux 배포판에는 이름에서 처음 나타나는 표현식을 대체하여 지정된 파일의 이름을 바꾸는 이름 바꾸기 명령이 있습니다. 교체로. 예를 들어 다음 명령은 pl 파일의 확장자를 수정합니다. 즉, 모든 * .perl의 이름을 * .pl 파일로 변경합니다.
rename .perl .pl *.perl
더 많은 예제와 사용법은 “Linux가 쉘 프롬프트에서 여러 파일 이름 바꾸기”를 참조하십시오.

결론

mv 명령을 사용하여 Linux에서 디렉토리 이름을 바꾸는 방법을 배웠습니다. 자세한 내용은 여기에서 mv 명령 문서를 참조하십시오.

🐧 지원하십시오 제 작업은 Patreon 또는 기부입니다.
🐧 RSS 피드 또는 주간 이메일 뉴스 레터를 통해 Linux, 오픈 소스 & DevOps에 대한 최신 자습서를 받으세요.
🐧 댓글 0 개. .. 하나 추가 ↓
카테고리 Unix 목록 및 Linux 명령
파일 관리 고양이
방화벽 Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
네트워크 유틸리티 dig • 호스트 • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
패키지 관리자 apk • apt
프로세스 관리 bg • chroot • cron • disown • fg • 작업 • killall • kill • pidof • pstree • pwdx • 시간
검색 중 grep • whereis • 어느
사용자 정보 그룹 • id • lastcomm • 마지막 • lid / libuser- lid • logname • 구성원 • 사용자 • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • 방화벽 • Ubuntu 20.04

Leave a Reply

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다