LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2020, 04:16 PM   #1
enzo-santos
LQ Newbie
 
Registered: May 2020
Posts: 1

Rep: Reputation: Disabled
How to remove a symlink and edit its system references?


When I bought this PC, the ~ folder that came with it was located in /home/user. After a while, I decided to change my username to new_user.

From the time I bought the computer until I decided to make the username change, I had already installed some programs, so I created a symlink called /home/user pointing to /home/new_user for backwards compatibility.

My question is: how to completely remove the symlink /home/user without breaking files that already depend on that folder? If I do

Code:
grep -rnw /home/new_user -e '/home/user'
there are still files that depend on this symlink. Any help is appreciated.
 
Old 05-02-2020, 08:40 PM   #2
WFV
Member
 
Registered: Apr 2012
Location: somehow, somewhere
Distribution: Arch
Posts: 197

Rep: Reputation: Disabled
rsync or otherwise copy them to their new file locations and then break the link is one method, there are probably many other means.
Code:
# rsync -aAXhv --delete --progress /home/user/ /home/new_user/
*note* do not blindly run this script! understand what rsync is doing first as this will overwrite everything in new_user with user written as is. Make sure you have a good restorable backup of your </home/...> too.
Break the link, make sure things work, then move on to the task of cleaning up users if that still applies. You can also dry-run rsync by appending an "n" to the operand
Code:
-aAXhvn
 
1 members found this post helpful.
Old 05-06-2020, 05:06 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by enzo-santos View Post
I had already installed some programs, so I created a symlink called /home/user pointing to /home/new_user for backwards compatibility.
Does this actually work as expected?
I wouldn't think so...
 
Old 05-06-2020, 05:25 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
@ondoho. Well, if the UID for the new user is the same as for the old one, why not?
 
  


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] symlink to symlink confusion, Reprovo Linux - Newbie 2 11-18-2014 02:17 PM
How to remove all references to files in CVS? johnnysmithson Linux - Software 1 10-06-2012 09:27 AM
Question How to get stat() of symlink and not of target of symlink ? ronbarak Programming 3 11-08-2010 12:14 PM
[SOLVED] BIND can't open its config file (via a symlink) Skaperen Linux - Software 2 01-26-2010 03:45 PM
Tip: How to copy a symlink and its target file in a script fotoguy Programming 4 08-05-2006 03:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:47 AM.

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