LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-14-2023, 07:57 AM   #1
sag2662
Member
 
Registered: Sep 2022
Posts: 74

Rep: Reputation: 0
Home directory of user


Hi all,

I accidentally deleted the home directory of user and looks like the user profile or bash profile is deleted. Is there anyway to restore it ? I cannot run bash scripts anymore

-bash-4.2$

Last edited by sag2662; 12-14-2023 at 07:58 AM.
 
Old 12-14-2023, 08:22 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,699

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by sag2662 View Post
Hi all,
I accidentally deleted the home directory of user and looks like the user profile or bash profile is deleted. Is there anyway to restore it ? I cannot run bash scripts anymore

-bash-4.2$
Yes; get it from your backups. If you don't have those, most probably not at this point, since you're still using the system. A .bashrc or .profile isn't difficult to rebuild, and it should definitely not prevent you from running anything. Unless, of course, you had aliases pointing to scripts, and don't have a correct path any longer. What are you typing that won't run any longer?
 
Old 12-14-2023, 08:29 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,333
Blog Entries: 3

Rep: Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730Reputation: 3730
If you do not have a backup copy then the data is gone.

You can reconstruct the directory hierarchy though by copying from /etc/skel/ which is where the default files with their default contents are stored.

Code:
sudo mkdir /home/sag2662/
sudo chown sag2662:sag2662 /home/sag2662/
sudo -u sag2662 rsync -av /etc/skel/ /home/sag2662/
The creation of the home directory, if it is gone, has to be done by root. Then the permissions have to be set. However the copying of the files has to be done as the account which owns that home directory.
 
Old 05-01-2024, 10:35 AM   #4
murugesandins
Member
 
Registered: Apr 2024
Location: Bangalore Karnataka India
Distribution: CYGWIN_NT
Posts: 75

Rep: Reputation: 1
if no backup taken(including trash), we cannot retrieve the deleted items.
Hence create a cron to take a backup by end of each day and move the backup files(tgz/zip) to backup system.
Remove oldest backup files when the backup system having less or no memory.
<<
I have added my comment to help sag2662.

Last edited by murugesandins; 05-01-2024 at 07:30 PM.
 
Old 05-01-2024, 11:10 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,699

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by murugesandins View Post
if no backup taken(including trash), we cannot retrieve the deleted items.
Hence create a cron to take a backup by end of each day and move the backup files(tgz/zip) to backup system.
Remove oldest backup files when the backup system having less or no memory.
This is what the OP was told before, last year. Is there a reason you're posting to old threads with either duplicate or questionable advice?
 
2 members found this post helpful.
Old 05-10-2024, 02:53 AM   #6
_blackhole_
Member
 
Registered: Mar 2023
Distribution: FreeBSD
Posts: 93

Rep: Reputation: 78
Account is clearly a bot - reported.
 
  


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
Login Error- Could not chdir to home directory /home/UserID: No such file or directory abhi_jais Linux - Newbie 1 03-24-2018 12:01 PM
User shown as "already exist" when there is no user directory shown on home directory Sharpeye Linux - Newbie 3 03-18-2009 01:17 AM
"Home directory already exists. Please enter another home directory path." Daravon Ubuntu 2 02-15-2009 10:26 PM
contents of 'home' directory found at sda5: mounted as /home, and also on sda6:/home leswatson Linux - Newbie 4 04-18-2008 04:02 PM
home directory under a home directory GEEXTER Linux - General 4 04-03-2003 09:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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