LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-03-2015, 06:09 AM   #1
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Rep: Reputation: Disabled
Unhappy [SOLVED]cannot access my /home directory even though I am the owner


Recently I have restored my /home partition from my external HDD. Now my external HDD was NTFS formatted so after restoring the /home partition to an ext4 partition the permissions were all messed up so from Single User mode I had to restore the permissions using the following-:

Code:
cd /home
chown -R sreyan:sreyan sreyan
But when I try to switch my user from root to sreyan I get the following problem-:
Code:
su sreyan
bash: /home/sreyan/.bashrc: Permission denied
sreyan@debian:/root$
Notice that I have got my prompt even after permission denied has showed up.

Now I can't seem to access anything under my /home partition when I user sreyan.
s
Code:
reyan@debian:/root$ ls -la /home/sreyan
ls: cannot access /home/sreyan: Permission denied
Why is this happening ? I clearly changed my ownership why can't I still access it ?

Last edited by sreyan32; 01-04-2015 at 09:59 AM.
 
Old 01-03-2015, 11:42 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Have you checked permissions? Directories 0755, files 0644.
 
Old 01-03-2015, 12:59 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Use
Code:
ls -ld /home/sreyan
to see the permissions on the directory itself without trying to look inside it. (And yes, "ls -la" still needs to look inside the directory to see the entry for "." .)
 
Old 01-03-2015, 01:25 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
if you saved your LINUS /home partition on a MS NTFS drive
tit is mostly FUBAR

ntfs can not save the linux user permissions

it is NOT just the "owner" that was messed up
but the file settings
( 655,744,... )
and the ones that were executable like the *.desktop files

all that will have to be MANUALLY reset

-- on redhat yum can help
but on Debian using "apt-" ????????

start FRESH
rename EVERY!!! hidden "dot" folder and file to add a .bu at the end

and recreate them ALL by rebooting

then MANUALLY in a text editor edit the config files using the old NTFS saved files as a guide

this will TAKE time


well you leaned a lesson
you will NEVER EVER AGAIN save linux folders on a NTFS partition
 
Old 01-04-2015, 12:41 AM   #5
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Instead you should have saved a tar file. Which preserves permission, user, group and friends.
 
Old 01-04-2015, 04:58 AM   #6
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by veerain View Post
Instead you should have saved a tar file. Which preserves permission, user, group and friends.
Thanks. I will do that next time. Can you just show me how to do that for next time ?

Last edited by sreyan32; 01-04-2015 at 05:00 AM.
 
Old 01-04-2015, 08:25 AM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
Specific examples at the site below with an explanation.

http://mylinuxramblings.wordpress.co...ome-directory/

Below is an example which creates a tar file of the /home/user directory which has the current date as part of the file name.

Code:
tar cpvf Bkup-$(date +%m-%d-%Y).tar /home/user
 
Old 01-04-2015, 09:52 AM   #8
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
Specific examples at the site below with an explanation.

http://mylinuxramblings.wordpress.co...ome-directory/

Below is an example which creates a tar file of the /home/user directory which has the current date as part of the file name.

Code:
tar cpvf Bkup-$(date +%m-%d-%Y).tar /home/user
What happens if I want to make a backup of the entire /home folder ? (If there are multiple users)

Would this do ?

Code:
tar cpvf Bkup-$(date +%m-%d-%Y).tar /home/
[/QUOTE]
 
Old 01-04-2015, 09:59 AM   #9
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
if you saved your LINUS /home partition on a MS NTFS drive
tit is mostly FUBAR

ntfs can not save the linux user permissions

it is NOT just the "owner" that was messed up
but the file settings
( 655,744,... )
and the ones that were executable like the *.desktop files

all that will have to be MANUALLY reset

-- on redhat yum can help
but on Debian using "apt-" ????????

start FRESH
rename EVERY!!! hidden "dot" folder and file to add a .bu at the end

and recreate them ALL by rebooting

then MANUALLY in a text editor edit the config files using the old NTFS saved files as a guide

this will TAKE time


well you leaned a lesson
you will NEVER EVER AGAIN save linux folders on a NTFS partition

I beg to differ that its not all FUBAR.

I solved it, though I don't think its the most elegant solution.

Okay here is what I did-:

I went to my root account and changed the ownership for the home account to sreyan (thats my normal unpriveledged account)

Code:
chown -R sreyan:sreyan /home
And I changed the all the permissions for all files and directories under my /home folder to 744 using-:

Code:
chmod -R 744 /home
Now I woould like the opinions of other people regarding setting my permissions to 744. Is it okay, dangerous or perfect ?

Last edited by sreyan32; 01-04-2015 at 10:00 AM.
 
Old 01-04-2015, 10:20 AM   #10
Lsatenstein
Member
 
Registered: Jul 2005
Location: Montreal Canada
Distribution: Fedora 31and Tumbleweed) Gnome versions
Posts: 311
Blog Entries: 1

Rep: Reputation: 59
To change the ownership, you had to execute that command as root.

Did you do that?

Example sudo chown -R x:x chown -R sreyan:sreyan ~

The ~ represents /home/sreyan
 
Old 01-04-2015, 10:21 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by sreyan32 View Post
I went to my root account and changed the ownership for the home account to sreyan (thats my normal unpriveledged account)
Code:
chown -R sreyan:sreyan /home
That's nice but it's wrong.

Should be:
Code:
chown root:root /home
chmod 0755 /home
Quote:
Originally Posted by sreyan32 View Post
And I changed the all the permissions for all files and directories under my /home folder to 744 using-:
Code:
chmod -R 744 /home
And that should be:
Code:
chown -R sreyan:sreyan /home/sreyan
find /home/sreyan -type d -print0 | xargs -0 -iX chmod 0750 'X'
find /home/sreyan -type f -print0 | xargs -0 -iX chmod 0640 'X'
chmod 0700 /home/sreyan

Quote:
Originally Posted by sreyan32 View Post
Now I woould like the opinions of other people regarding setting my permissions to 744. Is it okay, dangerous or perfect ?
No, due to how one "reads" a directory it's useless, literally.
 
Old 01-04-2015, 11:13 AM   #12
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by sreyan32 View Post
Thanks. I will do that next time. Can you just show me how to do that for next time ?
tar -cf backup.tar directories files
 
Old 01-05-2015, 09:00 PM   #13
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,510

Rep: Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491Reputation: 2491
Quote:
tar cpvf Bkup-$(date +%m-%d-%Y).tar /home/
That should work to backup /home.
 
Old 01-06-2015, 10:07 PM   #14
sreyan32
Member
 
Registered: Jan 2015
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
Code:
chown -R sreyan:sreyan /home/sreyan
find /home/sreyan -type d -print0 | xargs -0 -iX chmod 0750 'X'
find /home/sreyan -type f -print0 | xargs -0 -iX chmod 0640 'X'
chmod 0700 /home/sreyan
Can you explain how you find commands work and what they do ? If so I will give a try. Still bit of a noob when it comes to commands.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Most convenient owner:group owner for directories in /home/regular_user? stf92 Slackware 2 10-26-2014 08:12 AM
Can't access /home directory catweasel28 Linux Mint 12 04-19-2010 08:34 AM
[SOLVED] access directory outside of home directory? runinguy Linux - Newbie 7 04-16-2010 01:13 AM
Owner of a directory different than file owner problems Guardian-Mage Linux - Server 4 04-24-2009 10:26 AM
Others should not access my home directory. u4u Linux - General 3 01-16-2005 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:37 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