How To Change The Home Directory Of A Linux User

By default a new user will have a directory created in the “/home” folder. This is the default home directory. Changing this is very simple.

If you create a new user called “test” there will be a directory created as the default home folder. e.g. “/home/test”. To change this to a different directory you will need to use the usermod function.

usermod -d /new/home/dir username

This usermod command is used for a lot of functions. Adding -d to this command makes it change the home directory. Provide the home directory path relative to the root directory. This means start the path with a forward slash “/”. Then specify the path from here to avoid any relative path issues.
Finally you must include the name of the user you want to change the home directory for. So in this instance we could use the name test.

The above command is best used on a new user or an existing user where you don’t need to keep the existing contents of the home directory. If you would like the copy the contents of the current home directory and copy them over to the new directory then add “-m” to the command. This will result in something like this.

usermod -d /new/home/dir username

 

 

Related Articles

Related Questions

Should I Be Concerned About No Tests at My New Job?

I just started working at a new company, and I've noticed they don't seem to write any tests for the code. Is this something...

Why are my AWS SNS messages getting cut off instead of sent as multi-part?

I'm experiencing an issue where my messages sent through AWS SNS are getting cut off. The documentation suggests that it should automatically handle multi-part...

Which RTX 5080 Should I Go For?

I'm trying to set up a new gaming rig and I'm considering the RTX 5080. I currently have a 3080 Ti and a Ryzen...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions