3 ways to change user home directory in Linux

Changing a users home directory is probably one of the most common system administration tasks out there. linuxconf or other tools can be used to manage home directories after logging into a shell account using command line mode. The below example shows how to change the home directory of some common Linux users.

Why would you want to change user home directory in Linux?

There are several reasons why you might want to change your default home directory:

You have multiple users on the same machine and need each user to have their own private storage space.

The current location of your home directory is not supported by your filesystem or file system permissions, and it’s causing problems.

You’re planning on moving your machine to another location and need to relocate everything before doing so.

Change user home directory using usermod command.

To change the home directory of a user, use the usermod command. The usermod command is used to modify the properties of a user account.

The format for changing the home directory is:

usermod -m /home/username

For example, to change the home directory of a user named sarah to /home/sarah, enter:

usermod -m /home/sarah

Change user home directory using GUI tools

There are many GUI tools available to change user home directory. Some of these tools are listed below:

1. FileZilla (File Transfer Protocol Client)

2. WinSCP (Windows Secure Copy)

3. Cyberduck (Mac OS X Secure FTP Client)

4. Filezilla (File Transfer Protocol Client)

Change user home directory using chsh command to change login shell.

Manage user login shells using the chsh command. Chsh is part of the util-linux package and is installed by default on most Debian and Ubuntu Linux systems.

Change Login Shell Using Chsh Command

To change a user’s login shell, use the chsh command:

chsh -s /bin/bash username

This will change your shell to /bin/bash.

How to check user home directory in Linux

There are several ways to find the home directory of a user, the most common ones are:

1.Using whoami command

whoami is a built-in command that returns your user name. It’s very simple to use, just type whoami and press Enter.

2.Using id command

The id command displays the real and effective user and group IDs of the current user, as well as all other users on your system. The syntax is very simple: id username (where username is the username of the user whose data you want to check).

3.Using pwd command

The pwd command prints an absolute pathname for the current working directory, which can be a relative pathname or full pathname as well. To display this information about your current working directory, simply run pwd without any arguments.

Categories

Leave a Reply

Your email address will not be published. Required fields are marked *