System Administration

Add a user to a group

Price range: €18.64 through €26.12

Command:

bash
sudo usermod -aG {group_name} {username}

Explanation:

  • sudo: Runs the command with superuser privileges, as modifying user groups typically requires root access.
  • usermod: A command used to modify a user’s account settings.
  • -aG: The -a option appends the user to the specified group(s), and the -G option specifies the group(s) to which the user will be added.
  • {group_name}: The name of the group you want to add the user to (e.g., sudodevelopers).
  • {username}: The username of the user you want to add to the group (e.g., johnalice).

Example:

To add the user john to the group sudo, the command would be:

bash
sudo usermod -aG sudo john

Result:

This command will add the user john to the sudo group, allowing them to execute commands with elevated privileges if required.


Additional Notes:

  • After adding a user to a group, the user will typically need to log out and back in for the group changes to take effect.
  • To verify that the user has been added to the group, you can use the groups command:
    bash
    groups {username}

    For example:

    bash
    groups john
Select options This product has multiple variants. The options may be chosen on the product page

Change file permissions

Price range: €15.22 through €18.33

Command:

bash
chmod 755 filename

Explanation:

  • chmod: The command used to change file permissions.
  • 755: The permission set for the file:
    • 7 (Owner): Read (4), Write (2), Execute (1) — Total: 7
    • 5 (Group): Read (4), Execute (1) — Total: 5
    • 5 (Others): Read (4), Execute (1) — Total: 5
  • filename: The name of the file whose permissions you want to modify.

Result:

This command will grant the owner read, write, and execute permissions (rwx), while the group and others will only have read and execute permissions (rx).

If you need to set different permissions, replace 755 with the appropriate numeric value (e.g., 644 for read/write for owner and read-only for group and others).

Select options This product has multiple variants. The options may be chosen on the product page

Kill a process

Price range: €14.78 through €19.10

Command:

bash
kill PID

Explanation:

  • kill: A command used to terminate processes in Linux.
  • PID: The Process ID of the process you want to kill. Replace PID with the actual process ID number (e.g., 1234).

Example:

If you want to kill the process with PID 1234, the command would be:

bash
kill 1234

Result:

This will send a termination signal (SIGTERM) to the specified process, instructing it to terminate gracefully. If the process does not terminate, you can forcefully kill it using the following command:

Force Kill Command:

bash
kill -9 PID
  • -9: This option sends a SIGKILL signal, which forcefully terminates the process without allowing it to clean up resources. This should be used when the process does not respond to a normal termination request.

Additional Notes:

  • You must have the appropriate permissions to kill a process. If you are not the owner of the process or a superuser, you may need to prepend the command with sudo:
bash
sudo kill 1234
Select options This product has multiple variants. The options may be chosen on the product page

Unmount a filesystem

Price range: €15.11 through €19.85

Command:

bash
sudo umount /path/to/mount_point

Explanation:

  • sudo: Runs the command with superuser privileges, as unmounting a filesystem typically requires root access.
  • umount: The command used to unmount a filesystem from a mount point.
  • /path/to/mount_point: The directory where the filesystem is currently mounted. Replace this with the actual path of the mount point you wish to unmount (e.g., /mnt/data/media/usb).

Example:

To unmount the filesystem that is mounted at /mnt/data, you would use the following command:

bash
sudo umount /mnt/data

Result:

This command will unmount the filesystem from /mnt/data, making the data no longer accessible at that location until it is mounted again.


Additional Notes:

  • If the mount point is in use (e.g., a file within the filesystem is open or in use), you may receive a “device is busy” error. In such cases, you can use the lsof or fuser commands to check which processes are using the mount point:
    bash
    lsof /mnt/data

    or

    bash
    fuser -m /mnt/data
  • To force the unmounting (use cautiously), you can add the -f flag:
    bash
    sudo umount -f /mnt/data
Select options This product has multiple variants. The options may be chosen on the product page