LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-17-2008, 07:49 PM   #1
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Rep: Reputation: 19
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?
 
Old 10-17-2008, 08:20 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 10-18-2008 at 06:33 PM.
 
Old 10-17-2008, 08:23 PM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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 .
 
Old 10-17-2008, 08:39 PM   #4
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Original Poster
Rep: Reputation: 19
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.
 
Old 10-18-2008, 05:16 PM   #5
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Original Poster
Rep: Reputation: 19
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.
 
Old 10-18-2008, 06:58 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 10-18-2008, 07:13 PM   #7
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 236

Original Poster
Rep: Reputation: 19
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.
 
Old 10-20-2008, 12:58 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 10-20-2008 at 01:58 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM
permission ... permissions .... permissions alaios Linux - General 1 05-31-2005 04:16 AM
No permissions herjoc Linux - General 4 06-10-2004 02:54 AM
permissions ? ben_build#2.1.0 Fedora 4 04-23-2004 12:08 PM
getting a directory's permissions and creating a new one with the same permissions newbie1000101 Programming 1 04-10-2004 12:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration