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:
sudo apt updatesudo apt upgrade
This sequence:
- Refreshes the package list.
- 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:
wget http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.26.tar.bz2tar jvxf
We then move into the extracted directory, and install tcc
:
cd tcc-0.9.26./configuresudo make install
Let us test it with a simple hello world program, and compile/run with command
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.
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:
sudo passwd test
OR we can write a simple script to update the password with:
echo 'test:u-74*Sx*#R' | sudo chpasswd
To change the configuration of user test
, we can do:
sudo usermod -aG wheel testsudo usermod -g wheel testsudo usermod -G wheel testsudo usermod -e 2021-12-31 test
🔹 sudo usermod -aG wheel test
- Adds the user
test
to thewheel
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
towheel
. -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 justwheel
. - ❌ 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
Command | What it does | Safe to use? |
---|---|---|
usermod -aG wheel test | Adds test to wheel without removing others | ✅ Yes |
usermod -g wheel test | Sets wheel as the primary group | ✅ Yes |
usermod -G wheel test | Sets wheel as only group (removes others) | ⚠️ Be careful |
usermod -e 2021-12-31 test | Sets account to expire on Dec 31, 2021 | ✅ Yes |
If we want to remove the user ’test’, we can run the command:
sudo userdel -r test
We can verify it with:
id testls /home