Shell Customization

Shell Customization

Concepts

Shell Startup Files

When Bash starts, it reads configuration files — but which files depend on how the shell was started.

Login vs Non-Login Shell

Type When Example
Login shell First shell after authentication SSH session, TTY login, su - user
Non-login shell Shells opened inside an existing session Opening a terminal in the desktop, running bash

Interactive vs Non-Interactive Shell

Type When Example
Interactive You type commands at a prompt Terminal window, SSH session
Non-interactive Runs a script, no prompt bash script.sh, cron jobs

Which Files Are Read?

Login shell (interactive):
  /etc/profile → ~/.bash_profile OR ~/.bash_login OR ~/.profile (first found)

Non-login shell (interactive):
  /etc/bash.bashrc → ~/.bashrc

Non-interactive shell (scripts):
  $BASH_ENV (if set)

In practice, on Ubuntu and Debian, ~/.profile sources ~/.bashrc:

[Read more]

Signals

Signals

Concepts

What Is a Signal?

A signal is a software notification sent to a process. Signals tell processes to do something: stop, terminate, reload configuration, or respond to a user action. They are the kernel’s way of communicating with processes.

When you press Ctrl + C, you are sending a signal. When you run kill 1234, you are sending a signal.

Common Signals

Signal Number Default Action Sent By
SIGHUP 1 Terminate Terminal closes, or kill -1. Many daemons reload config.
SIGINT 2 Terminate Ctrl + C
SIGQUIT 3 Terminate + core dump Ctrl + \
SIGKILL 9 Kill immediately kill -9. Cannot be caught or ignored.
SIGTERM 15 Terminate gracefully kill (default signal). Process can clean up.
SIGSTOP 19 Suspend process Cannot be caught or ignored.
SIGTSTP 20 Suspend process Ctrl + Z. Can be caught by the process.
SIGCONT 18 Resume a stopped process kill -CONT or fg/bg
SIGUSR1 10 User-defined Application-specific
SIGUSR2 12 User-defined Application-specific

SIGTERM vs SIGKILL

This is the most important distinction:

[Read more]

Snap, Flatpak, and AppImage

Snap, Flatpak, and AppImage

Concepts

Beyond APT — Universal Package Formats

APT and .deb packages are the traditional way to install software on Debian/Ubuntu. But they have a limitation: packages are built for a specific distribution version. A .deb built for Ubuntu 24.04 may not work on Debian 12 or Ubuntu 22.04.

Universal package formats solve this by bundling the application with its dependencies, running in a sandbox, and working across distributions:

[Read more]

Sorting, Cutting, and Counting

Sorting, Cutting, and Counting

Concepts

The Unix Philosophy in Action

These small, specialized tools each do one thing well. Their power comes from combining them with pipes. This lesson covers the remaining essential text-processing commands.

sort — Sort Lines

sort file.txt                    # alphabetical sort
sort -r file.txt                 # reverse order
sort -n file.txt                 # numeric sort (1, 2, 10 not 1, 10, 2)
sort -h file.txt                 # human-readable numbers (1K, 2M, 3G)
sort -k2 file.txt                # sort by 2nd field
sort -k2,2n file.txt             # sort by 2nd field numerically
sort -t: -k3 -n /etc/passwd      # sort by UID (field 3, delimiter :)
sort -u file.txt                 # sort and remove duplicates
sort -f file.txt                 # case-insensitive sort

The -k flag specifies which field to sort by. Fields are separated by whitespace by default (change with -t).

[Read more]

Special Permissions

Special Permissions

Concepts

Beyond rwx

The standard read/write/execute permissions cover most scenarios. But Linux has three special permission bits that handle specific situations:

Bit Name On Files On Directories
SUID Set User ID Runs as the file’s owner, not the user who executes it No effect
SGID Set Group ID Runs with the file’s group, not the user’s group New files inherit the directory’s group
Sticky Sticky Bit No modern effect Only file owner (or root) can delete files

SUID — Set User ID

When SUID is set on an executable, the program runs with the permissions of the file’s owner instead of the user who runs it.

[Read more]