LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   permissions waked (https://www.linuxquestions.org/questions/linux-general-1/permissions-waked-677223/)

darthaxul 10-17-2008 07:49 PM

permissions waked
 
After copying fs to new partition the permissions wont work right at all. I cant use sudo, view virtual consoles, etc.
Is there any way to auto set the permissions like the installer does?

jschiwal 10-17-2008 08:20 PM

Which directories were copied over? Do you still have the originals files on the original partition?

If so, you could run:
find <dir>/ -printf "chown %u:%g %p && chmod %m %p\n" >fixperms.sh
in the base of the old partition, inspect it and if OK, move it to the base of the new partition and run it.
You may want to include only the directories you need, such as "find /bin /sbin /usr /lib /var ..." to skip /mnt/, /dev & /tmp.
Be sure to inspect the scripts to see that they look right.
This may give you an idea:
Code:

find Documents/ -printf "chown %u:%g %p && chmod %m %p\n" | head -n 10
chown jschiwal:jschiwal Documents/ && chmod 755 Documents/
chown jschiwal:jschiwal Documents/pewx.srt && chmod 644 Documents/pewx.srt
chown jschiwal:jschiwal Documents/crankygeeks.121.ogg && chmod 644 Documents/crankygeeks.121.ogg
chown jschiwal:jschiwal Documents/gbtv-n95-128176-10-9-2008.mp4 && chmod 644 Documents/gbtv-n95-128176-10-9-2008.mp4
chown jschiwal:jschiwal Documents/VLC - Features.war && chmod 644 Documents/VLC - Features.war
chown jschiwal:jschiwal Documents/Chapter 6. Containers.war && chmod 644 Documents/Chapter 6. Containers.war
chown root:root Documents/multiboot.pdf && chmod 644 Documents/multiboot.pdf
chown jschiwal:jschiwal Documents/PSerrata.txt && chmod 644 Documents/PSerrata.txt


You should put your disto and version in your user profile on this site. If you use an rpm based disto, you can use "rpm -qVa" to validate the packages. A debian based system my have a similar command to validate debian packages.
Code:

rpm -qlv gvim
-rw-r--r--    1 root    root            6048 Jun  6 21:23 /etc/gvimrc
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/egview -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/egvim -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/eview -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/evim -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/gex -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/gvi -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/gview -> gvim
lrwxrwxrwx    1 root    root                3 Jun  6 21:23 /usr/bin/gvim -> vim
-rwxr-xr-x    1 root    root          2450144 Jun  6 21:23 /usr/bin/gvim-normal
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/gvimdiff -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/rgview -> gvim
lrwxrwxrwx    1 root    root                4 Jun  6 21:23 /usr/bin/rgvim -> gvim
-rw-r--r--    1 root    root            4638 Jun  6 21:23 /usr/share/applications/gvim.desktop
drwxr-xr-x    2 root    root                0 Jun  6 21:23 /usr/share/doc/packages/gvim
-rw-r--r--    1 root    root              788 Jun  6 21:23 /usr/share/doc/packages/gvim/README.Japanese-XIM
-rw-r--r--    1 root    root              264 Jun  6 21:23 /usr/share/doc/packages/gvim/README.SuSE
-rw-r--r--    1 root    root            2064 Jun  6 21:23 /usr/share/doc/packages/gvim/gvimrc_example.vim
-rw-r--r--    1 root    root            6048 Jun  6 21:23 /usr/share/doc/packages/gvim/suse.gvimrc
-rw-r--r--    1 root    root              262 Jun  6 21:23 /usr/share/pixmaps/gvim.png

there may be a package called something like "base" or "filesystem" which is used to setup the directories and their permissions.

Most, but not all permissions in system directories will owned & group owned by root.

The permissions of these to files may prevent using sudo.
Code:

ls -ls /etc/sudoers /etc/shadow
4 -rw-r----- 1 root shadow 1006 2008-10-01 21:50 /etc/shadow
4 -r--r----- 1 root root  1977 2008-07-27 02:59 /etc/sudoers

---
The problem was probably caused by not using the archive option when using cp. Also, be careful which directories you copy. Some like /proc shouldn't be copied. Some like /tmp are a waste of time copying. Your system may create the /dev/ directory when you boot. And/or your distro may have a command to populate the /dev directory with the devices you need.

billymayday 10-17-2008 08:23 PM

What distro do you use? It could be an selinux issue.

jschiwal, I reckon distri would imply the plural (think gelato/gelati). I've been meaning to suggest that one out for a while ;).

darthaxul 10-17-2008 08:39 PM

It would indeed be easy if I had orig files and its permissions but i erased before verifying new copy. Reinstalling some packages helped a bit but some files are waked and doesnt operate right. Is there any other way to set default permissions on those files because it is impossible to do it manually.

darthaxul 10-18-2008 05:16 PM

Having copied it from a diffrent distro the /etc/passwd or /etc/group associations are misleading.
If I had a group with a value of 1000 on distro X then when I log into distro Y's group has a value of 1000 then it will be diffrent. so it doesnt matter what the name is, just the number.

jschiwal 10-18-2008 06:58 PM

You still haven't indicated which distribution you are using.
Most files outside of /home are owned by root and group owned by root. /etc/passwd needs to be world readable (i.e. "o" read bit set) but shadow must be only root readable. Otherwise, you may not be able to log in.

If you boot up with a live distro, you could use the live distro's permissions as the model and set the ones on the hard drive the same way. Then you may be able to boot and use your package systems verification to determine the permissions on other files and directories.

darthaxul 10-18-2008 07:13 PM

the problem
 
chown -R root /
chmod -R 755 /
that is a fool's way to mess up ur system then tell me how u gonna get it back?
even if the /etc/passwd and group membership numbers are same nobody is gonna do anything because ownership is lost.

jschiwal 10-20-2008 12:58 AM

You shouldn't do things with such broad strokes. For example, the programs in /bin/ will most likely be root:root owned with rwxr-xr-x.
In sbin,
Code:

jschiwal@qosmio:~/work> find /sbin/ -not -group root -exec ls -l '{}' \;
-rwsr-xr-x 1 root trusted 19488 2008-06-06 16:59 /sbin/pccardctl
-rwsr-xr-x 1 root shadow 11192 2008-06-06 17:32 /sbin/unix2_chkpwd
-rwsr-xr-x 1 root shadow 32272 2008-06-06 16:59 /sbin/unix_chkpwd

Non root owned files in /etc/.
Code:

sudo find /etc/ -not -user root -exec ls -l '{}' \;
total 0
-rw-r--r-- 1 lp sys 946 2008-06-06 20:29 /etc/cups/pstoraster.convs
-rw------- 1 lp lp 15614980 2008-07-31 11:12 /etc/cups/yes/ppds.dat
total 0
total 0
-rw-rw---- 1 mysql mysql 6250 2008-06-06 20:03 /etc/my.cnf

Many files in /etc/ are owned by system users.
Code:

sudo find /etc/ -not -group root -exec ls -ld '{}' \;
-rw-r----- 1 root shadow 947 2008-10-01 21:50 /etc/shadow.old
drwxr-x--- 5 root dialout 4096 2008-06-10 07:54 /etc/ppp
drwxr-x--- 2 uucp uucp 4096 2008-06-06 17:20 /etc/uucp
drwxr-xr-x 6 root lp 4096 2008-10-07 03:05 /etc/cups
-rw------- 1 root lp 373 2008-08-04 06:40 /etc/cups/printers.conf
-rw------- 1 root lp 373 2008-08-04 06:40 /etc/cups/printers.conf.O
-rw-r--r-- 1 lp sys 946 2008-06-06 20:29 /etc/cups/pstoraster.convs
drwxrwxr-x 2 root lp 4096 2008-07-31 11:12 /etc/cups/yes
-rw-r----- 1 root lp 75 2008-10-19 02:08 /etc/cups/yes/remote.cache
-rw------- 1 lp lp 15614980 2008-07-31 11:12 /etc/cups/yes/ppds.dat
-rw-r----- 1 root lp 2230 2008-10-19 02:08 /etc/cups/yes/job.cache
drwx------ 2 root lp 4096 2008-10-02 10:56 /etc/cups/ssl
drwxr-xr-x 2 lp lp 4096 2008-10-02 10:56 /etc/cups/interfaces
drwxr-xr-x 2 root lp 4096 2008-10-02 10:56 /etc/cups/ppd
-rw------- 1 root lp 82 2008-08-04 06:40 /etc/cups/classes.conf
-rw-r----- 1 root lp 2492 2008-06-06 19:39 /etc/cups/cupsd.conf.O
-rw------- 1 root lp 82 2008-07-31 11:27 /etc/cups/classes.conf.O
-rw-r----- 1 root lp 1592 2008-08-04 06:40 /etc/cups/cupsd.conf
drwxr-x--- 2 news news 4096 2008-06-06 17:20 /etc/news
-rw-rw---- 1 mysql mysql 6250 2008-06-06 20:03 /etc/my.cnf
-rw-r----- 1 root shadow 1006 2008-10-01 21:50 /etc/shadow
-rw-r----- 1 root ntp 2060 2008-09-01 21:03 /etc/ntp.conf
-rw-r----- 1 root ntp 12 2008-06-10 07:23 /etc/ntp.keys

Code:

ls /etc/init.d/ -l | sed -n '/^-rwxr-xr-x/!{ /^d/!p}'
total 716
-rwxr--r-- 1 root root  3734 2008-07-08 09:17 acpid
-rwxr--r-- 1 root root  778 2008-06-06 15:39 boot.device-mapper
-rwxr--r-- 1 root root  1228 2008-06-06 16:01 boot.dmraid
-rwxr--r-- 1 root root  395 2008-07-27 03:24 boot.local
-rwxr--r-- 1 root root  3241 2008-06-06 16:24 boot.multipath
-rwxr--r-- 1 root root  4294 2008-06-06 17:29 cron
-rwxr-xr-- 1 root root  1776 2008-06-06 15:36 earlysyslog
-rwxr--r-- 1 root root  360 2008-07-27 03:24 halt.local
-rwxr--r-- 1 root root  2723 2008-06-06 16:24 multipathd
-rwxr--r-- 1 root root  6056 2008-08-14 19:42 nfs
-rwxr--r-- 1 root root  8453 2008-08-14 19:42 nfsserver
-rwxr-xr-- 1 root root  2720 2008-08-27 12:35 nmb
-rwxr--r-- 1 root root  3667 2008-06-06 16:08 portmap
-rwxr--r-- 1 root root  1335 2008-06-06 16:14 powerd
-rwxr--r-- 1 root root  1241 2008-06-06 17:31 raw
-rw-r--r-- 1 root root  7827 2008-06-16 12:05 README
lrwxrwxrwx 1 root root    4 2008-07-27 03:24 reboot -> halt
-rwxr-xr-- 1 root root  2870 2008-08-27 12:35 smb
-rwxr-xr-- 1 root root  5203 2008-08-27 12:35 smbfs
-rwxr----- 1 root root  5115 2008-06-06 18:49 spamd
-rwxr-xr-- 1 root root  5485 2007-06-20 07:13 svnserve
-rwxr-xr-- 1 root root  4336 2008-06-06 15:36 syslog
-rwxr--r-- 1 root root  1818 2008-06-06 15:58 uuidd

Hopefully you can get the system bootable and then use your package system to learn the permissions of the installed files and fix the rest.

Your distro's install disk may have a repair option as well. There may also be a backup of the /etc/sysconfig files. Also if you have a full backup, you can restore the system that way.


All times are GMT -5. The time now is 08:12 PM.