Announcement

Collapse
No announcement yet.

I've stuffed up again

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    I've stuffed up again

    So. On my HTPC, I use a small palm size keyboard. I've made a mistake

    I accidentally typed
    Code:
    chown user /* -R
    for about 10seconds before i stopped it
    instead of
    Code:
    chown user DOT ./* -R
    I missed a DOT before the slash
    now when I do the command I get some stupid error that the permission is set to 1000 instead of 0

    so. How do I correct the permissions from this error. And please dont say wipe and re-install.
    There has to be another method of re-installing the system files.

    Please

    #2
    Unfortunately, recursively chowning / is one of the worst things you can do to a system (it's the reason why I never use the /-character when recursively chowning, typos are destroyers).

    Aside from restoring from backups or filesystem snaphots (if you have them), a reinstallation is probably the fastest and 100% working solution.

    You could probably get sudo functionality back with "pkexec chown root:root /usr/bin/sudo" (or chowning from recovery mode root console), but that doesn't really help you much, because not all files under the root system are owned by root (there are a lot of special system file ownerships in a linux system)...so you can't simply recursively rechown everything back to root ownership (well, you can, but there are going to be issues with everything owned by root).

    rpm based distros do have a trick to restore (at least the majority of) system file ownerships/permissions (rpm --setugids -a && rpm --setperms -a), but I'm not aware of an easy way to do this on a deb based system (if anyone knows, feel free to pitch in). But even that only restores the ownerships that are set by packages (and not those that might be created after installation).
    Last edited by kubicle; Apr 21, 2021, 12:01 AM.

    Comment


      #3
      As kubicle said, I think there is little hope for your system. Even if you get most of the permissions set correctly, you'll probably be plagued by weird permissions issues indefinitely.

      chown and chmod both have a --preserve-root option that protects against operating recursively on /. You could set up an alias to both chown and chmod to set the --preserve-root flag by default.
      Code:
      alias chown="chown --preserve-root "
      alias chmod="chmod --preserve-root "

      Comment


        #4
        For moral support - I've done this too in the past. I tried to fix it for weeks. Eventually gave up and reinstalled.

        There's literally tens of thousands of files with varied permissions and ownership. If you took a parallel install and compared folder-to-folder though the entire install you might get it eventually get close enough to use it again. However, in 1% or less of the time it takes to do that, you can reinstall and start over.

        Please Read Me

        Comment


          #5
          Originally posted by kubicle View Post
          Unfortunately, recursively chowning / is one of the worst things you can do to a system (it's the reason why I never use the /-character when recursively chowning, typos are destroyers).
          So what do you do when you install a new HDD, and it's formated to ROOT

          Originally posted by kubicle View Post
          Aside from restoring from backups or filesystem snaphots (if you have them)
          No but I would love to know 'filesystem snapshots' how! Hint hint PLEASE

          Originally posted by kubicle View Post
          You could probably get sudo functionality back with "pkexec chown root:root /usr/bin/sudo" (or chowning from recovery mode root console), but that doesn't really help you much, because not all files under the root system are owned by root (there are a lot of special system file ownerships in a linux system)...so you can't simply recursively rechown everything back to root ownership (well, you can, but there are going to be issues with everything owned by root).
          Yeah. I figured that. I was hoping for a miracle like ctrl-Z or undo last cmd. Guess it's the same for winning a lotto jackpot

          Thanks for your reply Kubicle
          Last edited by CharlieDaves; Apr 21, 2021, 12:13 PM.

          Comment


            #6
            Originally posted by whatthefunk View Post
            chown and chmod both have a --preserve-root option that protects against operating recursively on /. You could set up an alias to both chown and chmod to set the --preserve-root flag by default.
            Code:
            alias chown="chown --preserve-root "
            alias chmod="chmod --preserve-root "
            So I would do these cmds when I rebuild the PC, and they are set for "The rest of it's natural life" ?
            Thanks for your reply

            Comment


              #7
              Originally posted by oshunluvr View Post
              For moral support - I've done this too in the past. I tried to fix it for weeks. Eventually gave up and reinstalled.

              There's literally tens of thousands of files with varied permissions and ownership. If you took a parallel install and compared folder-to-folder though the entire install you might get it eventually get close enough to use it again. However, in 1% or less of the time it takes to do that, you can reinstall and start over.
              So when I am crying into my beer, I'll think of you.. Thanks for your reply

              Comment


                #8
                Considering most of this started because of problems with Samba, and me possible following 'older' guides and tweaks. Any suggestions on something to read regarding using kubuntu 20.04 and future versions Not one of those dummies guides that explain the system setup and how to install 'games' for the first 7 chapters. Not interest in a book that I want to chop and burn the first half or three-quarters.
                And as I have asked before. Any decent guides or support forums for Samba ? besides reading through all the settings and thinking "Oh. This might work, I'll try this" there must be something I can read and follow.
                2 computers, both now running 20.04, one with virtualbox, and other useful things, the other with 'other useful' things removed (basically everything but firefox & media player), KDE connect for my tablet. I must be doing something wrong if I am constantly not getting things to work

                Comment


                  #9
                  FYI. Exact error is
                  sudo: /etc/sudoers is owned by uid 1000, should be 0
                  sudo: no valid sudoers sources found, quitting
                  sudo: unable to initialise policy plugin

                  Comment


                    #10
                    Originally posted by CharlieDaves View Post
                    FYI. Exact error is
                    Sudo is also very picky about the ownership/permissions (and syntax) of it's config file, so you'd need to chown /etc/sudoers and possibly also /etc/sudoers.d (and it's contents) back to root as well (with pkexec or recovery root console)...but like I said, it won't help you much.
                    Originally posted by CharlieDaves View Post
                    So what do you do when you install a new HDD, and it's formated to ROOT
                    I assume you mean adding a new hdd to an existing installation, and one that you'd want to not be owned by root?
                    Mount it somewhere, cd to the parent of the mount point and chown the mount point *by name* (if it is a fresh filesystem, you don't even need recursion because it's empty)...tab completion is also a good way to prevent typos.
                    Or cd into the filesystem and use just the "." to refer to the current workdir (and not "./*" to avoid using the /-character)...although I always refer to directories by name (and tab completion) when doing something potentially hazardous like recursive rm, chown or chmod.

                    The aliases whatthefunk mentioned can also be a good additional safeguard, but I've learnt not to rely on aliases alone (I've messed with a lot of systems that are not mine, or one's that I haven't fully configured yet...it's better to learn to be safe than relying just on aliases (that might not be there) to save you. Good to have them, yet better to never need them to save you.

                    Originally posted by CharlieDaves View Post
                    No but I would love to know 'filesystem snapshots' how! Hint hint PLEASE
                    Modern filesystems (like btrfs and zfs) support snapshots that can help restore a filesystem to a previous state (or revert individual file changes etc). Technically not backups, but can be really useful in many cases involving "Damn, I wish I could take that back" moments.

                    There are plenty of good howtos and even automated tools for snapshotting (but you of course need to have them before catastrophe strikes...and they are not replacements for backups, which one also needs to have...but backups are obviously more important for data that is irreplacable, a system is usually easy enough to reinstall, although you are usually better of if you have backups of your own system configuration changes).
                    Last edited by kubicle; Apr 21, 2021, 04:00 PM.

                    Comment


                      #11
                      Originally posted by CharlieDaves View Post
                      No but I would love to know 'filesystem snapshots' how! Hint hint PLEASE
                      You seem to be asking about TimeShift, see https://github.com/teejee2008/timeshift.

                      But I use, and recommend using, btrfs, and learning what it can do. (TimeShift will use btrfs snapshots if the system is on a btrfs.) TimeShift only works on the system, which would have been just what you needed, but I don't understand why it only does the system; other solutions are needed for your other stuff.

                      So, I use a regular snapshotting tool called "snapper". Btrfs and snapper are now standard on OpenSUSE. Other posters here don't like snapper and use their own scripts or cron jobs to make snapshots. Being able to get back a file you've just screwed up or deleted, because it was snapshotted an hour ago, by a few clicks in dolphin, is so good, IMO.

                      It seems you don't have a good backup... Btrfs makes backups quick, too, doing incremental backups. (Other approaches can do incremental, too, but not as quickly.) This encourages one to backup; while making this post I realized this system should be backed up, and did so, the commands took a couple of minutes to run (to a hard disc in the same system).
                      Regards, John Little

                      Comment


                        #12
                        I'm one of those who prefers my own script to manage snapshots and backups automatically.

                        [warning, shameless plug ahead]

                        I also wrote some BTRFS Dolphin service menus that make manual snapshot management easier.


                        Please Read Me

                        Comment


                          #13
                          Ditto, Oshunluver!
                          But I've got a hybrid BTRFS system -- it has no @home subvolume. So, I only have to snapshot @ and I've captured my entire system. It would be nice if Ubuntu made that an option during the install, but, it is easy to change from @ & @home to just @, so :shrug:.

                          Here's my "shameless plug" for my script, titled "make_snapshot.sh", which creates both a snapshot and does an incremental backup to my third HD, mounted as /backup.
                          I run it from my account using "sudo /ma -->", where --> is the tab key to autocomplete. After entering my password the script runs:
                          Code:
                          #!/bin/bash
                          #
                          # script to create backup snapshots to /mnt/snapshots and a differential backup to /backup
                          # To be run as root from /
                          #
                          echo "Mounting drives"
                          eval "mount /dev/disk/by-uuid/ce2b5741-c01e-4b3d-b6ba-401ad7f7fcdf /mnt"
                          eval "mount /dev/disk/by-uuid/e84e2cdf-d635-41c5-9f6f-1d0235322f48 /backup"
                          
                          NOW=$(date +%Y%m%d%H%M)
                          echo "Making today's snapshot"
                          MKSNAP='btrfs su snapshot -r /mnt/@ /mnt/snapshots/@'$NOW
                          eval $MKSNAP
                          eval 'sync'
                          eval 'sync'
                          
                          echo "Finding previous snapshot as parent "
                          PREVSNAP=""
                          list=($(ls /mnt/snapshots/))
                          PREVSNAP=${list[-2]}
                          NOW=${list[-1]}
                          echo "Attempting incremental backup"
                          if [[ -s "/mnt/snapshots/"$PREVSNAP ]]; 
                          then
                              MKINC='btrfs send -p /mnt/snapshots/'$PREVSNAP
                              MKINC=$MKINC' /mnt/snapshots/'$NOW
                              MKINC=$MKINC' | btrfs receive /backup'
                              echo $MKINC
                              eval $MKINC
                              eval 'sync'
                              eval 'sync'
                              eval "sync"
                              DELSNAP='btrfs subvol delete -C /mnt/snapshots/'${list[0]}
                              eval $DELSNAP
                              eval 'sync'
                              eval 'sync'
                              eval 'sync'
                              list=''
                              list=($(ls /backup))
                              DELSNAP='btrfs subvol delete -C /backup/'${list[0]}
                              eval $DELSNAP
                              eval 'sync'
                              eval 'sync'
                              eval 'sync'
                              echo "Snapshots completed, oldest snapshots deleted"
                              eval 'umount /backup'
                              eval 'umount /mnt'
                              eval 'sync'
                              eval 'sync'
                              eval 'sync'
                              echo "Drives unmounted and 3 syncs done"
                          else
                              echo 'Incremental backup failed using '$PREVSNAP' and '$NOW
                              echo 'Drives still mounted, ready to clean up'
                          fi
                          However many snapshots that already exist in /mnt/snapshots will be the number of snapshots maintained, unless the user manually adds or removes snapshots to establish a new number of them.
                          "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                          – John F. Kennedy, February 26, 1962.

                          Comment

                          Working...
                          X