Tony-d
Posts: 140
Joined: Mon Jun 02, 2014 11:54 pm

I can not rename a file.

Sun Dec 03, 2023 12:04 am

Hi guys, I am very confused here. I have a web page running on a raspberry Pi under word press.
It has just started giving 403 errors. This seems simple enough to fix but I no longer seems to have access to rename files on my pi?
I only have one account on the Pi and it has SUDO privileges. When I do an lslogins -u I get back

uuid user proc
0 root 146
1000 Tony 34

I am user Tony and I can not rename a file or change access rights?
I don’t wish to re build the complete system if I can just fix this.
Thank You all.

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 12:18 am

With the information you have provided all we can do is guess.

If you provide at least the following you'll improve your chances:
  • Pi model
  • OS including major release name (Buster, Bullseye, Bookworm, etc)
  • Which web server you're using (wordpress runs on top of a web server)
  • The output from

    Code: Select all

    ls -l
    on the problem file
  • The output from

    Code: Select all

    ls -ld
    on the directory containing the problem file
  • Whether the directory containing the problem file is in your root partition or some other partition/device.
  • If it's on a different partition/device:
    • How are you mounting it (include any commands or fstab entry)
    • What file system has it been formatted with? (not all file systems support changing owner, group, and permissions)
    • Has it been mounted read only?
    • Has the device failed and gone into a read only mode? (check by creating a new file, rebooting and checking if that file still exists)
  • If it's on your root partition/device: Has the device failed and gone into a read only mode? (check by creating a new file, rebooting and checking if that file still exists)
You may have created only one user, but believe me there are multiple "system" users that are unable to login adn that don't have home directories.

Edited for tpyos.
Last edited by thagrol on Sun Dec 03, 2023 12:21 am, edited 2 times in total.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
kerry_s
Posts: 7103
Joined: Thu Jan 30, 2020 7:14 pm

Re: I can not rename a file.

Sun Dec 03, 2023 12:20 am

all that and nothing we can use to help you.

what's the path to file

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 12:23 am

kerry_s wrote:
Sun Dec 03, 2023 12:20 am
all that and nothing we can use to help you.

what's the path to file
Knowing just the path isn't likely to be of any use in debugging this. Well, not unless we have shell access to the OP's Pi.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
kerry_s
Posts: 7103
Joined: Thu Jan 30, 2020 7:14 pm

Re: I can not rename a file.

Sun Dec 03, 2023 12:45 am

thagrol wrote:
Sun Dec 03, 2023 12:23 am
kerry_s wrote:
Sun Dec 03, 2023 12:20 am
all that and nothing we can use to help you.

what's the path to file
Knowing just the path isn't likely to be of any use in debugging this. Well, not unless we have shell access to the OP's Pi.
if had the path just give him the command.

Code: Select all

mv /path/to/file /path/to/file.new
of course sudo if needed.

everything else is useless info, just file name and new name.

hortimech
Posts: 910
Joined: Wed Apr 08, 2015 5:52 pm

Re: I can not rename a file.

Sun Dec 03, 2023 9:01 am

kerry_s wrote:
Sun Dec 03, 2023 12:45 am

if had the path just give him the command.

Code: Select all

mv /path/to/file /path/to/file.new
of course sudo if needed.

everything else is useless info, just file name and new name.
Not sure about that, the OP said 'I no longer seems to have access to rename files on my pi', so he might have tried that and failed.

User avatar
DougieLawson
Posts: 42848
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: I can not rename a file.

Sun Dec 03, 2023 9:10 am

kerry_s wrote:
Sun Dec 03, 2023 12:45 am

if had the path just give him the command.

Code: Select all

mv /path/to/file /path/to/file.new
of course sudo if needed.
The important thing is to know what directory you're sitting in. Use a pwd command to discover that.

If the file is in the same directory you can use

Code: Select all

mv file.name file.name.new
sudo mv.file.name file.name,new
Or move a file in

Code: Select all

mv /path/to/file/file.name file.name.new
sudo mv /path/to/file/file.name file.name.new
Or if in current directory and going to another

Code: Select all

mv file.name /newpath/to/newfile/file.name.new
sudo mv file.name /newpath/to/newfile/file.name.new
You ONLY need sudo if the file doesn't belong to you, your group or the world. Check the permission bits with an ls -la file.name command. That shows up like

Code: Select all

dougie@apollo:~$ ls -la /etc/hosts
-rw-r--r-- 1 root root 126 Jul  7  2019 /etc/hosts
dougie@apollo:~$
That shows it's a file (not a directory), it's owned by root and root's group and has r+w for root, r for root's group and r for the world. That's from -rw-r--r-- Yellow is the directory/file/stream marker. Red is owner's permissions. Blue is group permissions. Green is the world permissions
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 10:54 am

kerry_s wrote:
Sun Dec 03, 2023 12:45 am
thagrol wrote:
Sun Dec 03, 2023 12:23 am
kerry_s wrote:
Sun Dec 03, 2023 12:20 am
all that and nothing we can use to help you.

what's the path to file
Knowing just the path isn't likely to be of any use in debugging this. Well, not unless we have shell access to the OP's Pi.
if had the path just give him the command.

Code: Select all

mv /path/to/file /path/to/file.new
of course sudo if needed.

everything else is useless info, just file name and new name.
And when that fails as it most likely will? You'll be asking for most/all of that information in dribs and drabs until you hit the one piece of information that actually reveals the cause. Or will you just walk away?

This isn't a phone call or web chat. Getting answers to question takes hours or days. It's better to ask for everything up front.

The issue appears to be something other than not knowing the mv command.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 11:04 am

DougieLawson wrote:
Sun Dec 03, 2023 9:10 am
kerry_s wrote:
Sun Dec 03, 2023 12:45 am

if had the path just give him the command.

Code: Select all

mv /path/to/file /path/to/file.new
of course sudo if needed.
The important thing is to know what directory you're sitting in.

Again, nope. We don't know what method(s) the OP has tried. They might be using a GUI file manager, they might be using mv with full paths, they might be using mv with relative paths, they might be using some other method. For some of those methods the cwd is irellevant.

I probably should have asked for that information too.
ls -la file.name command.

The a is unnecessary and file permissions might look fine bt be blocked by directory permissions.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Tony-d
Posts: 140
Joined: Mon Jun 02, 2014 11:54 pm

Re: I can not rename a file.

Sun Dec 03, 2023 1:53 pm

Thank you for your help and apologize for my lack of input.
I am running a Pi 4 with 4 gig
it boots from a S.S.D vea USB hub.
The os is bullseye ver 11
The sever set up is L.A.M.P.

I can add a file in my documents but I can not add a file in /var/www/html With tells me I am no longer the owner? This system did work for years. I have backups and can rebuild it but I would like to understand and fix it.
Thank You

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 2:06 pm

Tony-d wrote:
Sun Dec 03, 2023 1:53 pm
The sever set up is L.A.M.P.

That doesn't tell us much more. It suggests you have Linux, Apache, MySQl and PHP installed but doesn't provide any details. They may not be necessary in this case though.

I can add a file in my documents but I can not add a file in /var/www/html With tells me I am no longer the owner?

Does whatever command/application you're using tell you that or are you making an assumption?
This system did work for years. I have backups and can rebuild it but I would like to understand and fix it.

So what changed between it working and not?
Thank You

So everything is in the same root partition on on the SSD?

What about
thagrol wrote:
Sun Dec 03, 2023 12:18 am
  • The output from

    Code: Select all

    ls -l
    on the problem file
  • The output from

    Code: Select all

    ls -ld
    on the directory containing the problem file
And tell us exactly what command or application you're using and exactly what messages it is giving. None of our crystal balls are working.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
DougieLawson
Posts: 42848
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: I can not rename a file.

Sun Dec 03, 2023 2:06 pm

Tony-d wrote:
Sun Dec 03, 2023 1:53 pm

I can add a file in my documents but I can not add a file in /var/www/html With tells me I am no longer the owner? This system did work for years. I have backups and can rebuild it but I would like to understand and fix it.
So who is the owner of /var/www/html?

You can ALWAYS use sudo some-command-here to elevate privileges for some-command-here.
You can change the ownership of /var/www/html with sudo chown xx.xx /var/www/html
You can change the permission bits for /var/www/html with sudo chmod r+w gr+w or+w /var/www/html/some.file.name or sudo chmod 666 /var/www/html/some.file.name (or any other bits, it's three sets of octal numbers).
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 3:04 pm

DougieLawson wrote:
Sun Dec 03, 2023 2:06 pm
You can change the ownership of /var/www/html with sudo chown xx.xx /var/www/html

Surely you mean sudo chown xx:xx /var/www/html

Changing owner, group and permissiosn on /var/www and it's contents may not be advisable. Web servers can be picky about this and even if they're not you could still end up breaking things further.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Tony-d
Posts: 140
Joined: Mon Jun 02, 2014 11:54 pm

Re: I can not rename a file.

Sun Dec 03, 2023 3:19 pm

Thank You, and I am sorry that I was not able to provide enough info. I'm learning every day.
I am grateful for the help.
I'm going to rebuild the system.

User avatar
DougieLawson
Posts: 42848
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: I can not rename a file.

Sun Dec 03, 2023 3:40 pm

thagrol wrote:
Sun Dec 03, 2023 3:04 pm
DougieLawson wrote:
Sun Dec 03, 2023 2:06 pm
You can change the ownership of /var/www/html with sudo chown xx.xx /var/www/html

Surely you mean sudo chown xx:xx /var/www/html
No, I meant exactly what I wrote. Go and try it. Your version also works.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

BigRedMailbox
Posts: 516
Joined: Sat Aug 20, 2022 10:37 pm

Re: I can not rename a file.

Sun Dec 03, 2023 3:49 pm

I see no mention of using "." instead of ":" in "man 1 chown".

But it seems to work (the same as ":"). Is there any point to using it?
My posts may be "controversial" and/or out-of-sync with the party line.

Nothing I write should in any way be taken as an official statement by any organization connected with (any branch of) RPi and/or any of its funding sources.

User avatar
thagrol
Posts: 10952
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: I can not rename a file.

Sun Dec 03, 2023 4:08 pm

DougieLawson wrote:
Sun Dec 03, 2023 3:40 pm
thagrol wrote:
Sun Dec 03, 2023 3:04 pm
DougieLawson wrote:
Sun Dec 03, 2023 2:06 pm
You can change the ownership of /var/www/html with sudo chown xx.xx /var/www/html

Surely you mean sudo chown xx:xx /var/www/html
No, I meant exactly what I wrote. Go and try it. Your version also works.

So it does.

On Bookworm it works but throws a warning:

Code: Select all

pi@devpi:~ $ touch baz
pi@devpi:~ $ sudo chown root.root baz
chown: warning: '.' should be ':': ‘root.root’
Given that and that that is not mentioned in man 1 chown nor in chown --help I would not recomend your syntax to an obvious beginner. It would appear that while your version works (which I was unaware of) it is undocumented and incorrect or deprecated.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
rpdom
Posts: 23334
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: I can not rename a file.

Sun Dec 03, 2023 4:15 pm

BigRedMailbox wrote:
Sun Dec 03, 2023 3:49 pm
I see no mention of using "." instead of ":" in "man 1 chown".

But it seems to work (the same as ":"). Is there any point to using it?
It's deprecated in Bookworm. It still works, but you get a warning. It will disappear eventually.

Code: Select all

rpdom@raspberrypi:~ $ chown rpdom.rpdom fred
chown: warning: '.' should be ':': ‘rpdom.rpdom’
The man page shows a colon in use and no mention of using a dot.

Code: Select all

NAME
       chown - change file owner and group

SYNOPSIS
       chown [OPTION]... [OWNER][:[GROUP]] FILE...
       chown [OPTION]... --reference=RFILE FILE...
Unreadable squiggle

BigRedMailbox
Posts: 516
Joined: Sat Aug 20, 2022 10:37 pm

Re: I can not rename a file.

Sun Dec 03, 2023 5:20 pm

The man page shows a colon in use and no mention of using a dot.
Exactly as I said.
My posts may be "controversial" and/or out-of-sync with the party line.

Nothing I write should in any way be taken as an official statement by any organization connected with (any branch of) RPi and/or any of its funding sources.

Return to “Beginners”