Warning: Undefined array key "HTTP_REFERER" in /hosting/xtmci/inc/lib.inc.php on line 82
xtmci.com
xtmci

Linux: The leading open-source free operating system

Thu May 14 4:53 pm EDT 2026
xtmci@atomicmail.io

Table of Contents

Adding a user to the Linux system

You can add a user to the system using useradd command. For example:

sudo useradd -m username
  • The -m switch ensures that a new home directory for the user is created.

After creating a new user, you must set a password for it:

sudo passwd username

Optionally to grant administrative privileges to the user, use the following command:

sudo usermod -aG sudo username
  • -aG sudo Appends the user to the sudo group. The members in this group are granted special privileges required for doing administrative tasks.

Changing the owner and group of files or directories

Use the chown command to change both the owner and the group of a file at the same time:

sudo chown ownername:groupname filename

Of course, you can change them separately. In the case of changing a group, use the chgrp command:

sudo chown ownername filename
sudo chgrp groupname filename

The -R switch is very useful when applying changes recursively to a directory and all the files and subdirectories inside it:

sudo chown -R ownername:groupname directory

How to backup and restore data using tar

To save the files and directories you want to backup into an archive, use the tar command and -cvf switch:

tar -cvf backupfile.tar directory1 directory2 ...
  • -c Creates a new archive file.
  • -v Prints detailed information on screen during the archiving process.
  • -f Specifies the name of an archive file.

In the case of restoring files and directories from the archive file, use -x switch to extract it:

tar -xvf backupfile.tar

If you want to extract the archive into a specific directory, use the -C switch:

tar -xvf backupfile.tar -C directory

Another switch -t is useful when just listing and verifying the contents of an archive file without actually extracting it:

tar -tvf backupfile.tar

Changing the default shell for a user

Use the usermod command. Before changing the shell, check which shells are available on your system:

cat /etc/shells

The -s switch of usermod command specifies the shell for a user:

sudo usermod -s /bin/bash username

The change will take effect when the user logs in the next time.

How to add a user to the sudoers file in Linux

Use the visudo command to add a user to the /etc/sudoers file.

The visudo command works with several editors available in the system. To designate a specific editor, use the command syntax like this:

EDITOR=editor_name visudo

For example, the following command opens the /etc/sudoers file in the vim editor:

EDITOR=vim visudo

Add the following line at the end of the file:

username ALL=(ALL:ALL) ALL

Save and exit the file.
Now, switch to the user account and run some commands for testing:

su -l username
sudo apt update