FR FieldReady Academy
Unit 3OSObjective 1.912 min read

Linux Commands, Configuration Files, and Components

Unit 3: macOS and Linux. Lesson 12 of 41 in APlus Academy Core 2.

Linux support on the exam is a list of commands and files. Learn each by its job, and the handful of switches and rules that come with it.

The shell and the rules

Commands are case-sensitive, and so are file names. ~ is your home directory, / the root of the filesystem, . the current directory, .. the parent. Options start with a dash: ls -la. Anything that changes the system needs root rights through sudo.

File management

  • ls lists files; ls -l long form with permissions, owner, size, date; -a includes hidden files (names starting with a dot).
  • pwd prints the working directory. cd changes it.
  • mv moves or renames; cp copies (cp -r for directories); rm removes (rm -r recursive, -f without asking; there is no recycle bin).
  • chmod changes permissions. Each file has read, write, and execute for owner, group, and others. Numerically r is 4, w is 2, x is 1, so chmod 755 script.sh gives the owner everything and others read and execute, chmod 644 file gives the owner read and write and others read only; symbolically chmod +x script.sh adds execute.
  • chown changes the owner and group: chown user:group file, with -R for a tree.
  • grep searches text: grep -i error /var/log/syslog (case-insensitive), -r recursive through directories.
  • find locates files: find / -name "*.conf", by size, age, or owner.

Filesystem management

  • fsck checks and repairs a filesystem, run on an unmounted volume (from recovery or on a data disk), like chkdsk.
  • mount attaches a filesystem to a directory: mount /dev/sdb1 /mnt/usb; umount detaches it; mount alone lists what is mounted.

Administrative

  • su switches to another user, by default root, with that account's password; the whole shell becomes root, which is risky.
  • sudo runs one command as root using your own password, logs it, and is the preferred method: sudo apt update. Users must be in the sudo (or wheel) group.
  • The root account has unlimited power (user ID 0); many distributions disable its direct login and expect sudo.

Package management

  • apt on Debian, Ubuntu, and their relatives: sudo apt update refreshes the package lists, sudo apt upgrade installs updates, sudo apt install package, sudo apt remove package.
  • dnf on Fedora, Red Hat, and relatives (successor to yum): sudo dnf install package, sudo dnf update.

Packages come from the distribution's repositories, signed and dependency-resolved; that is Linux's app store.

Network

  • ip replaced ifconfig: ip addr (or ip a) shows addresses, ip route the routes and gateway, ip link the interfaces.
  • ping as in Windows, but continuous by default (Ctrl+C stops; -c 4 sends four).
  • curl fetches a URL from the command line; tests web services and downloads files.
  • dig queries DNS in detail (answer, server, timing); nslookup exists too.
  • traceroute lists the hops (tracert's cousin).

Informational

  • man command opens the manual page; q quits.
  • cat file prints a file; less pages through it.
  • top shows live processes with CPU and memory (htop is friendlier); ps lists processes, ps aux for everything; kill PID ends one.
  • du -sh folder shows how much space a directory uses; df -h shows free space per mounted filesystem. "Disk full" starts with df, then du to find the culprit.

Text editors

nano is the beginner-friendly editor: Ctrl+O saves, Ctrl+X exits, the shortcuts are on screen. vi and vim are everywhere but modal (press i to insert, Esc then :wq to save and quit).

Common configuration files

  • /etc/passwd: one line per user account: name, user ID, group ID, home directory, shell. World-readable.
  • /etc/shadow: the hashed passwords and aging rules; readable only by root.
  • /etc/hosts: static name-to-address mappings checked before DNS; the place a manual override or a malware redirect hides.
  • /etc/fstab: filesystems to mount at boot, with mount points and options; a typo here can stop the boot.
  • /etc/resolv.conf: the DNS servers and search domain (often managed by a service such as systemd-resolved or NetworkManager).

OS components

  • The kernel is the core that manages hardware, memory, and processes; its version shows with uname -r.
  • The bootloader (GRUB on most distributions) loads the kernel; its menu lets you pick a kernel or recovery mode.
  • systemd is the init system and service manager: systemctl status service, systemctl start, stop, restart, enable (start at boot), disable; journalctl reads its logs.
Exam tip: chmod 755 and 644; sudo runs one command as root and is preferred to su; apt for Debian and Ubuntu, dnf for Fedora and Red Hat; ip addr for addresses; df for free space, du for usage; fsck on an unmounted filesystem; /etc/passwd users, /etc/shadow password hashes, /etc/hosts name overrides, /etc/fstab mounts at boot, /etc/resolv.conf DNS; systemd manages services, GRUB is the bootloader, the kernel is the core.
Remember
ls -la, pwd, cd, mv, cp -r, rm -rf. chmod (r4 w2 x1; 755, 644), chown user:group. grep -i, find -name. fsck (unmounted), mount and umount. su (become root) versus sudo (one command, logged, preferred); root is UID 0. apt (Debian, Ubuntu), dnf (Fedora, RHEL). ip addr, ip route, ping -c, curl, dig, traceroute. man, cat, top, ps aux, du -sh, df -h. nano (Ctrl+O, Ctrl+X). /etc/passwd, /etc/shadow, /etc/hosts, /etc/fstab, /etc/resolv.conf. kernel, GRUB bootloader, systemd (systemctl).
Deeper explanation

Linux Commands, Configuration Files, and Components, explained slowly

Linux as a toolbox

A Linux session is a set of small tools chained together. The exam lists the tools and asks what each does, plus the files and components that hold the system together. Organize them by category and keep the quirks (case sensitivity, no recycle bin, numeric permissions) next to them.

Files and directories

command   does                             example
ls        list                             ls -la  (long, all)
pwd       print working directory
cd        change directory                 cd ~  home;  cd ..  up
mv        move or rename                   mv old.txt new.txt
cp        copy                             cp -r dir backup  (recursive)
rm        remove                           rm -rf dir  (recursive, forced; no undo)
chmod     change permissions               chmod 755 run.sh;  chmod +x run.sh
chown     change owner and group           chown -R alice:staff project
grep      search text                      grep -ri "error" /var/log
find      find files                       find / -name "*.conf" 2>/dev/null
cat       print a file                     cat /etc/hosts

Permissions decoded

-rwxr-xr--  1 alice staff  1234 Sep  7 file.sh
 ^^^^^^^^^
 owner rwx = 7;  group r-x = 5;  others r-- = 4   ->  chmod 754
r = 4, w = 2, x = 1; add them per class; owner, group, others in that order
755: owner everything, everyone else read and execute (scripts, programs)
644: owner read and write, everyone else read (documents)
700: owner only (private keys)

A directory needs x to be entered. chown user:group changes ownership; only root (via sudo) can give files away.

Disks and mounts

fsck checks and repairs a filesystem and must run on an unmounted volume (boot to recovery for the root filesystem). mount attaches a device to a directory (mount /dev/sdb1 /mnt/usb); umount detaches; mount with no arguments lists everything mounted. df -h shows free space per mounted filesystem; du -sh path shows what a directory consumes. /etc/fstab lists what mounts at boot.

Root, su, sudo

tool     what happens                                         when
root     the superuser, UID 0, can do anything                never log in as root for daily work
su       switch user; su alone becomes root with root's password; the whole shell is root   rare; many distributions lock root's password
sudo     run one command as root with your own password; logged; membership in sudo or wheel group   the normal way: sudo apt update

Packages

apt (Debian, Ubuntu, Mint): sudo apt update refreshes the index, sudo apt upgrade applies updates, sudo apt install name, sudo apt remove name. dnf (Fedora, RHEL, Rocky; yum's successor): sudo dnf install name, sudo dnf update. Packages are signed and dependencies resolved from repositories; snap and flatpak are cross-distribution alternatives.

Network

command      does
ip addr      addresses (ip a);  ip route  gateway and routes;  ip link  interfaces up or down
ping         reachability; continuous by default; -c 4 for four packets
curl         fetch a URL: curl https://example.com; test an API; download with -O
dig          DNS query with full detail: dig example.com;  dig @8.8.8.8 example.com MX
traceroute   hops to a destination

Processes and space

top shows live processes sorted by CPU (q quits); ps aux lists all; kill PID ends one (kill -9 forces). du and df as above; a full disk stops logins and services, so df -h is the first command on a sick server.

Editors and files

nano: arrow keys, Ctrl+O write out, Ctrl+X exit, Ctrl+W search; the shortcuts are printed at the bottom. vi/vim: i to insert, Esc, :wq to save and quit, :q! to abandon.

file                 holds                                                     note
/etc/passwd          users: name:x:uid:gid:comment:home:shell                  readable by all; the x means the hash is in shadow
/etc/shadow          hashed passwords and aging                                root only
/etc/hosts           static name-to-IP mappings                                checked before DNS; malware and overrides live here
/etc/fstab           filesystems to mount at boot                              a bad line can stop the boot
/etc/resolv.conf     DNS servers (nameserver lines) and search domain           may be generated by a resolver service

Components

The kernel manages hardware, memory, and processes (uname -r shows the version). The bootloader, GRUB on most systems, loads the kernel and offers a menu (older kernels, recovery mode). systemd starts and supervises services: systemctl status sshd, systemctl restart sshd, systemctl enable sshd (start at boot), systemctl disable; journalctl -u sshd reads its log.

Worked examples

  • "A script will not run: Permission denied." chmod +x script.sh, then ./script.sh.
  • "A web server on Ubuntu needs a package." sudo apt update && sudo apt install nginx; sudo systemctl enable --now nginx.
  • "The server is out of space." df -h to find the full filesystem, du -sh /var/log/* to find the culprit, then rotate or delete.
  • "A hostname resolves to the wrong address only on this machine." cat /etc/hosts; remove the stale line; cat /etc/resolv.conf to confirm the DNS server.
  • "A service is down after reboot." systemctl status name; journalctl -u name; systemctl enable name if it was never enabled.

How the exam asks it

  • "Which command changes file permissions?" chmod. "Which changes the owner?" chown.
  • "Which command lets a user run one command as root?" sudo.
  • "Which package manager is used on Ubuntu?" apt. "On Fedora?" dnf.
  • "Which command shows IP addresses on a Linux system?" ip (ip addr).
  • "Which command shows free disk space?" df. "Disk usage of a folder?" du.
  • "Which file contains hashed passwords?" /etc/shadow.
  • "Which file defines filesystems mounted at boot?" /etc/fstab.
  • "Which component manages services on modern Linux?" systemd.

What to memorize

  • The command tables and the chmod numbers.
  • su versus sudo versus root; apt versus dnf.
  • The five /etc files; kernel, bootloader (GRUB), systemd and systemctl.