0

So i was trying to copy some files from one folder to another using the cp command, but when tried it gave me this error:

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 

so then i tried to execute the same command with sudo but it didn't work either:

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

After i tried to see the permissions of each folder:

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 

but then i don't know what to do next because i don't know how to understand the data. Can somebody help me solve this problem?

[EDIT]

So i tried to see if i had root access, but is shows me this:

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 

And then i tried to install sudo, but i can't:

debian@OCR-1:~$ apt update && apt install -y sudo -bash: apt: command not found 
11
  • What is the result of ls -ld /var/log/MLO? Commented Mar 21, 2022 at 12:11
  • Do you have root access? Commented Mar 21, 2022 at 12:36
  • @RomeoNinov that was the name of the copy of the file that was supposed to be created by the cp command, so it doen't exist Commented Mar 21, 2022 at 14:18
  • @iLuvLogix how can i know if i have root access? Commented Mar 21, 2022 at 14:18
  • 2
    What you need to do is talk to whoever is the sysadm on this machine to give you the desirded permissions. Have you setup this machine (physically or via VM/container etc..)? Commented Mar 21, 2022 at 15:02

1 Answer 1

0

In order to be able to use sudo on debian, you first need to install and configure it.


install sudo:

First you need to login to your root account.

Then run the following to install the sudo package:

apt update && apt install -y sudo 

configure sudo:

If the installation completes without errors, you can configure sudo to allow your user to escalate privileges. Debian usually is by default configured to allow users which are in the sudo group to run commands via sudo. You can check that by, while still logged into the root account, running visudo and look for the following line:

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

If there is a # in front of %sudo remove it so that the line looks exactly as above. Be very careful to not mess up the file, as it could render your system unusable!


add your user to the sudo group:

If the line is present, you can add your normal user, in your case debian to the sudo group. You can do that with usermod:

usermod -aG sudo debian 

Where -aG means "append to group"

-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. 

Now logout of the root account and login to your debian user account. You should now be able to run commands as root via sudo.

Note: that the directory /var/log/ usually is only for automatically generated log files.

2
  • I can't install sudo, i updated my question, doesn't have apt command Commented Mar 21, 2022 at 14:40
  • @JoãoSousa It is expected that you don't have access to apt if you are not root. Commented Mar 21, 2022 at 20:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.