[SOLVED] How to get permissions to copy-paste or write files to directories outside /home?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

[SOLVED] How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

I want to know how I can get permission to copy-paste or move files from /home to other directories like /usr Image

Similarly, I can't write files and save them in the /etc directory. What should I do?
Image
Last edited by LockBot on Sun May 12, 2024 10:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
deepakdeshp
Level 21
Level 21
Posts: 12639
Joined: Sun Aug 09, 2015 10:00 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by deepakdeshp »

There is a reason you can't write to these directories. There are system files here and user data should not be here.
The advice is don't do it. You should run the commands with sudo if you want to disregard the advice, Like

Code: Select all

sudo vim
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 22 Cinnamon 0U/8gb
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

deepakdeshp wrote: Sun Nov 12, 2023 4:03 am There is a reason you can't write to these directories. There are system files here and user data should not be here.
The advice is don't do it. You should run the commands with sudo if you want to disregard the advice, Like

Code: Select all

sudo vim
Thank you for replying. I understand there is a reason for restrictions on permissions but I had downloaded a theme from GitHub which needed to be moved to the /usr/share/themes directory to make it available on my system. I also wanted to install mpv following the instructions outlined here: https://fruit.je/apt. One of the steps there wanted me to write something to /etc/apt/sources.list.d/fruit.list.
Image

Similarly, following on instructions listed here: https://www.jamescoyle.net/how-to/3116- ... unt-script for creating an rclone mount service I need to create a script with vi /etc/systemd/system/rclone.service.
Image

I was wondering if there was a way to do these things without messing up my OS.
deepakdeshp
Level 21
Level 21
Posts: 12639
Joined: Sun Aug 09, 2015 10:00 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by deepakdeshp »

instead of vi use sudo vi to edit the file and you can write to the system folders like /etc
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 22 Cinnamon 0U/8gb
billyswong
Level 9
Level 9
Posts: 2630
Joined: Wed Aug 14, 2019 1:02 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by billyswong »

The Fruit repository website is providing a less than ideal practice to add 3rd party repository. The correct dirctory to saving 3rd party gpg keys should have been either /etc/apt/keyrings or /usr/share/keyrings. Then the source list should point itself to use that added key. Overall the modified instruction will be:

Code: Select all

sudo curl --output-dir /usr/share/keyrings -O https://apt.fruit.je/fruit.gpg

Code: Select all

deb [signed-by=/usr/share/keyrings/fruit.gpg] http://apt.fruit.je/ubuntu jammy mpv
assuming you are running LM 21.x.

Then for the creation of fruit.list, one way to create/edit system config files in Linux Mint is

Code: Select all

sudo touch /etc/apt/sources.list.d/fruit-mpv.list
xed admin:///etc/apt/sources.list.d/fruit-mpv.list
This will let you edit system config file in our usual GUI text editor. The difference from this versus sudo xed <usual-file-path> is, when one sudo xed, the text editor is opened as root. Meanwhile {c]xed admin:///[/c] open the text editor normally so it takes your existing text editor preferences and can open the file as a tab inside the text editor if you already have other text files opened (this works even if the other text files is just "unsaved document 1"). It can even be listed as a "recent file" in File > Recents too.

touch creates a file if that file doesn't exist. The second line of command can't work if the file hasn't existed.

----

Similar procedure can be applied for /etc/systemd/system/rclone.service
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

billyswong wrote: Sun Nov 12, 2023 6:00 am The Fruit repository website is providing a less than ideal practice to add 3rd party repository. The correct dirctory to saving 3rd party gpg keys should have been either /etc/apt/keyrings or /usr/share/keyrings. Then the source list should point itself to use that added key. Overall the modified instruction will be:

Code: Select all

sudo curl --output-dir /usr/share/keyrings -O https://apt.fruit.je/fruit.gpg

Code: Select all

deb [signed-by=/usr/share/keyrings/fruit.gpg] http://apt.fruit.je/ubuntu jammy mpv
assuming you are running LM 21.x.

Then for the creation of fruit.list, one way to create/edit system config files in Linux Mint is

Code: Select all

sudo touch /etc/apt/sources.list.d/fruit-mpv.list
xed admin:///etc/apt/sources.list.d/fruit-mpv.list
This will let you edit system config file in our usual GUI text editor. The difference from this versus sudo xed <usual-file-path> is, when one sudo xed, the text editor is opened as root. Meanwhile {c]xed admin:///[/c] open the text editor normally so it takes your existing text editor preferences and can open the file as a tab inside the text editor if you already have other text files opened (this works even if the other text files is just "unsaved document 1"). It can even be listed as a "recent file" in File > Recents too.

touch creates a file if that file doesn't exist. The second line of command can't work if the file hasn't existed.

----

Similar procedure can be applied for /etc/systemd/system/rclone.service
Thank you for a detailed response! But I already followed the previous advice of using sudo with the commands I found in the above-mentioned instructions. Do you reckon I might face some problems because of this?
billyswong
Level 9
Level 9
Posts: 2630
Joined: Wed Aug 14, 2019 1:02 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by billyswong »

linuxmintforumsuser wrote: Sun Nov 12, 2023 9:23 am Thank you for a detailed response! But I already followed the previous advice of using sudo with the commands I found in the above-mentioned instructions. Do you reckon I might face some problems because of this?
sudo vi is okay. The gpg key shall be fixed. Some background story of why the fruit repository instruction in their website is not ideal
https://medium.com/@glegoux/ubuntu-22-0 ... bbee8aec84

TLDR: A gpg key given by a 3rd party repository shall be used only for authenticating software downloaded from that repository. However, the old key installation approach (or the way "fruit" circumvented the recent deprecation) let the key authenticates any software packages downloaded from any servers or any other actions that may ask for signature check. This is placing too much a trust to a 3rd party repository key.
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

billyswong wrote: Sun Nov 12, 2023 11:37 am
linuxmintforumsuser wrote: Sun Nov 12, 2023 9:23 am Thank you for a detailed response! But I already followed the previous advice of using sudo with the commands I found in the above-mentioned instructions. Do you reckon I might face some problems because of this?
sudo vi is okay. The gpg key shall be fixed. Some background story of why the fruit repository instruction in their website is not ideal
https://medium.com/@glegoux/ubuntu-22-0 ... bbee8aec84

TLDR: A gpg key given by a 3rd party repository shall be used only for authenticating software downloaded from that repository. However, the old key installation approach (or the way "fruit" circumvented the recent deprecation) let the key authenticates any software packages downloaded from any servers or any other actions that may ask for signature check. This is placing too much a trust to a 3rd party repository key.
So should I delete the gpg key and add it again in the way you suggested. Would this mess with my installed mpv package? Or any other installs made using the Fruit repository during mpv's installation?
billyswong
Level 9
Level 9
Posts: 2630
Joined: Wed Aug 14, 2019 1:02 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by billyswong »

To smooth the process, you can fix thing in the following order:
1. Add / copy the key to the correct place
2. Edit the list file(s), add the "signed-by" tag
3. Remove the key in old location
4. sudo apt update
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

billyswong wrote: Mon Nov 13, 2023 9:43 am To smooth the process, you can fix thing in the following order:
1. Add / copy the key to the correct place
2. Edit the list file(s), add the "signed-by" tag
3. Remove the key in old location
4. sudo apt update
How can I find the location of the key and determine the correct location to add/copy it? Additionally, how can I edit the list file, add the "signed-by" tag, and remove the key in old location?
billyswong
Level 9
Level 9
Posts: 2630
Joined: Wed Aug 14, 2019 1:02 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by billyswong »

linuxmintforumsuser wrote: Mon Nov 13, 2023 11:07 am How can I find the location of the key and determine the correct location to add/copy it? Additionally, how can I edit the list file, add the "signed-by" tag, and remove the key in old location?
In https://fruit.je/apt the command line given for key installation is

Code: Select all

sudo curl --output-dir /etc/apt/trusted.gpg.d -O https://apt.fruit.je/fruit.gpg
So assuming you did run that command, you can go to "/etc/apt/trusted.gpg.d" and see the key created there, as it is the "output directory". now for copying files, the command will be

Code: Select all

sudo cp /etc/apt/trusted.gpg.d/fruit.gpg /usr/share/keyrings/fruit.gpg
For editing the list file, assuming you followed the instruction in fruit.je, the file is at "/etc/apt/sources.list.d/fruit.list". So you can just run

Code: Select all

xed admin:///etc/apt/sources.list.d/fruit.list
as well.

At the end, you can remove the old key by

Code: Select all

sudo rm /etc/apt/trusted.gpg.d/fruit.gpg
linuxmintforumsuser
Level 1
Level 1
Posts: 38
Joined: Fri Nov 10, 2023 10:11 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by linuxmintforumsuser »

billyswong wrote: Mon Nov 13, 2023 2:43 pm In https://fruit.je/apt the command line given for key installation is

Code: Select all

sudo curl --output-dir /etc/apt/trusted.gpg.d -O https://apt.fruit.je/fruit.gpg
So assuming you did run that command, you can go to "/etc/apt/trusted.gpg.d" and see the key created there, as it is the "output directory". now for copying files, the command will be

Code: Select all

sudo cp /etc/apt/trusted.gpg.d/fruit.gpg /usr/share/keyrings/fruit.gpg
For editing the list file, assuming you followed the instruction in fruit.je, the file is at "/etc/apt/sources.list.d/fruit.list". So you can just run

Code: Select all

xed admin:///etc/apt/sources.list.d/fruit.list
as well.

At the end, you can remove the old key by

Code: Select all

sudo rm /etc/apt/trusted.gpg.d/fruit.gpg
Thank you very much! Just to make sure I did everything right, /etc/apt/sources.list.d/fruit.list should look like this:

Code: Select all

deb [signed-by=/usr/share/keyrings/fruit.gpg] https://apt.fruit.je/ubuntu jammy mpv
billyswong
Level 9
Level 9
Posts: 2630
Joined: Wed Aug 14, 2019 1:02 am

Re: How to get permissions to copy-paste or write files to directories outside /home?

Post by billyswong »

linuxmintforumsuser wrote: Mon Nov 13, 2023 3:00 pm Thank you very much! Just to make sure I did everything right, /etc/apt/sources.list.d/fruit.list should look like this:

Code: Select all

deb [signed-by=/usr/share/keyrings/fruit.gpg] https://apt.fruit.je/ubuntu jammy mpv
Yes.
Locked

Return to “Beginner Questions”