Skip to content

8.1 Basics

1. Installing Packages

1.1 Automatic Installation

In Linux-based systems (like Ubuntu or Debian), the commands sudo update and sudo upgrade are used with the package manager (usually apt) to keep your system’s software up to date.

🔹 sudo apt update

  • What it does: Downloads the latest list of available packages and versions from the configured software repositories.
  • Does it install anything? ❌ No. It only updates the package list, not the software itself.
  • Think of it as: Checking if newer versions of your software exist.

🔹 sudo apt upgrade

  • What it does: Installs the newer versions of the software packages that are already installed on your system.
  • Uses the list from: The most recent apt update.
  • Think of it as: Actually downloading and installing the updates.

🔹 Why use sudo?

  • sudo means “SuperUser DO” — it runs the command with admin/root privileges, which is required for modifying system software.

✅ Typical usage:

Terminal window
sudo apt update
sudo apt upgrade

This sequence:

  1. Refreshes the package list.
  2. Installs available updates for your current software.

1.2 Manual Installation

To install package by manually retrieving the source code and installation files. We will try to install tcc (Tiny C Compiler). First, we try to download the source code and extract it:

Terminal window
wget http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.26.tar.bz2
tar jvxf

We then move into the extracted directory, and install tcc:

Terminal window
cd tcc-0.9.26
./configure
sudo make install

Let us test it with a simple hello world program, and compile/run with command

Terminal window
tcc -run hello.c

2. User Management

The commands useradd, usermod, and userdel are used to manage user in the system. We will need administrator privilege for this.

Terminal window
sudo useradd -m -d /home/test -s /bin/bash -g student -e 2020-12-31 -c "Test Account" test

In order to setup the password for the user test, we can manually set it up:

Terminal window
sudo passwd test

OR we can write a simple script to update the password with:

Terminal window
echo 'test:u-74*Sx*#R' | sudo chpasswd

To change the configuration of user test, we can do:

Terminal window
sudo usermod -aG wheel test
sudo usermod -g wheel test
sudo usermod -G wheel test
sudo usermod -e 2021-12-31 test

🔹 sudo usermod -aG wheel test

  • Adds the user test to the wheel group (commonly used for admin privileges).
  • -a = append to supplementary groups.
  • -G = list of groups to add to.
  • Use this to add a user to a group without removing them from others.
  • Safe and common for giving sudo rights on systems where wheel is the sudo group.

🔹 sudo usermod -g wheel test

  • Sets the primary (login) group of user test to wheel.
  • -g = primary group (not supplementary).
  • ⚠️ Only one primary group allowed per user.
  • Use when you want all the user’s new files to default to being owned by the wheel group.

🔹 sudo usermod -G wheel test

  • Sets the supplementary groups for user test to just wheel.
  • Unlike -aG, this replaces all existing groups.
  • ⚠️ Dangerous if the user is in other groups (like sudo, audio, docker) — they’ll be removed from them.

🔹 sudo usermod -e 2021-12-31 test

  • Sets the expiration date of the user account to December 31, 2021.
  • After that date, the user can’t log in.
  • Useful for temporary accounts (e.g. contractors or test users).

✅ Summary Table

CommandWhat it doesSafe to use?
usermod -aG wheel testAdds test to wheel without removing others✅ Yes
usermod -g wheel testSets wheel as the primary group✅ Yes
usermod -G wheel testSets wheel as only group (removes others)⚠️ Be careful
usermod -e 2021-12-31 testSets account to expire on Dec 31, 2021✅ Yes

If we want to remove the user ’test’, we can run the command:

Terminal window
sudo userdel -r test

We can verify it with:

Terminal window
id test
ls /home