한 폴더에서 다른 폴더로 파일을 복사할 수 있는 권한을 얻으려면 어떻게 해야 합니까?

한 폴더에서 다른 폴더로 파일을 복사할 수 있는 권한을 얻으려면 어떻게 해야 합니까?

그래서 해당 명령을 사용하여 일부 파일을 한 폴더에서 다른 폴더로 복사하려고 시도했지만 cp시도했을 때 다음 오류가 발생했습니다.

debian@OCR-1:/mnt/rootfs/boot$ ls
MLO             omap3-overo-storm-arbor43c.dtb  uEnv.txt  zImage-3.18-20150915
initrd-ubi.img  u-boot.img   zImage
debian@OCR-1:~$ cp /mnt/rootfs/boot/MLO /var/log/MLO
cp: can't create '/var/log/MLO': Permission denied

그래서 동일한 명령을 실행해 보았 sudo으나 작동하지 않았습니다.

debian@OCR-1:~$ sudo cp /mnt/rootfs/boot/MLO /var/log/MLO
-bash: sudo: command not found

각 폴더의 권한을 보려고 시도한 후:

debian@OCR-1:/var$ ls -l
total 5
drwxr-xr-x  9 root root 4096 May 16  2018 archive
drwxr-xr-x  4 root root    0 Jan  1 00:00 lib
drwxrwxr-x  2 root root    0 Jan  1 00:56 lock
drwxr-xr-x 11 root root 1024 Jan  1 00:00 log
drwxrwxr-x  4 root root    0 Jan  1 00:01 run
drwxrwxr-x  3 root root    0 Jan  1 00:00 spool
drwxr-xr-x  3 root root    0 Jan  1 00:00 www

debian@OCR-1:/mnt/rootfs/boot$ ls -l
total 11160
-rwxr-xr-x 1 root root   59148 Jan 24  2014 MLO
-rwxr-xr-x 1 root root 1220219 Jan  1 00:16 initrd-ubi.img
-rwxr-xr-x 1 root root   69463 Jan 24  2014 omap3-overo-storm-arbor43c.dtb
-rwxr-xr-x 1 root root  470632 Jan 24  2014 u-boot.img
-rwxr-xr-x 1 root root    2038 Jan  1 00:16 uEnv.txt
-rwxr-xr-x 1 root root 4798000 Jan  1 00:20 zImage
-rwxr-xr-x 1 root root 4798000 Jan 24  2014 zImage-3.18-20150915

그런데 데이터를 어떻게 이해해야 할지 모르기 때문에 다음에 무엇을 해야 할지 모르겠습니다. 누구든지 이 문제를 해결하도록 도와줄 수 있나요?

[편집하다]

그래서 루트 액세스 권한이 있는지 확인하려고 했지만 다음과 같은 결과가 나타났습니다.

debian@OCR-1:~$ id
uid=1000(debian) gid=1002(debian) groups=4(adm),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev),108(i2c),1000(admin),1001(spi),1002(debian)
debian@OCR-1:~$ whoami
debian
debian@OCR-1:~$ su -
su: must be suid to work properly

그런 다음 설치를 시도했지만 sudo실패했습니다.

debian@OCR-1:~$ apt update && apt install -y sudo
-bash: apt: command not found

답변1

데비안에서 사용 하려면 sudo먼저 설치하고 구성해야 합니다.


설치하다 sudo:

먼저 루트 계정에 로그인해야 합니다.

그런 다음 다음 명령을 실행하여 sudo패키지를 설치합니다.

apt update && apt install -y sudo

구성 sudo:

설치가 오류 없이 완료되면 sudo사용자가 권한을 에스컬레이션할 수 있도록 구성할 수 있습니다. 데비안은 일반적으로 sudo 그룹의 사용자가 sudo를 통해 명령을 실행할 수 있도록 기본적으로 구성됩니다. 루트 계정에 로그인한 상태에서 실행 하고 다음 줄을 찾아 visudo이를 확인할 수 있습니다.

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

#앞에 하나가 있으면 %sudo제거하여 선이 위와 똑같이 보이도록 하세요. 시스템을 사용할 수 없게 만들 수 있으므로 이 파일을 함부로 다루지 않도록 주의하세요!


sudo 그룹에 사용자를 추가합니다.

이 줄이 있으면 일반 사용자(귀하의 경우)를 debiansudo 그룹에 추가할 수 있습니다. 당신은 이것을 할 수 있습니다 usermod:

usermod -aG sudo debian

여기서 -aG"그룹에 연결"을 의미합니다.

-a, --append
           Add the user to the supplementary group(s). Use only with the -G option.

-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
           A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same
           restrictions as the group given with the -g option.

           If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via the -a option, which appends the user to the current
           supplementary group list.

이제 루트 계정에서 로그아웃하고 데비안 사용자 계정으로 로그인하세요. 이제 루트로 명령을 실행할 수 있습니다 sudo.

노트:이 디렉터리는 /var/log/일반적으로 자동으로 생성된 로그 파일에만 사용됩니다.

관련 정보