← Linux from ScratchCheat sheet
M2Linux from Scratch

M2 — Accounts, login, and first commands

Module brief#

Learn how accounts and home directories work, how to read command syntax (command, options, arguments), and how to get help from man without guessing.


Learning objectives#

  • Change your own password safely with passwd
  • Switch user context with su / su - (when permitted)
  • Navigate to home with cd, cd ~, and cd ~username
  • Break a command line into command, options, and arguments
  • Use man, man -k, and section numbers to learn a utility
  • Run everyday status commands: uname, date, cal, clear, ls

1. Accounts and your home directory#

After you log in — whether through a graphical greeter, a virtual console, WSL, or SSH — you land in a shell as some user. Examples in this course use student or labuser. Your real name may differ.

Each ordinary user normally has a home directory under /home. Shortcuts:

cd          # go to your home directory
cd ~        # same idea — tilde means your home
cd ~student # go to student\'s home (if you have permission)

Check who you are and where home is:

whoami
id
echo $HOME

Example:

box
uid=1000(box) gid=1000(box) groups=1000(box)
/home/box

2. Changing your password#

Use passwd with no username to change your own password. You will be prompted for the current password, then the new one twice. Nothing echoes as you type — that is normal.

passwd

Administrators can reset other accounts’ passwords; that needs privilege and is outside day-one practice. Never paste real passwords into chat, tickets, or screenshots.


3. Switching users with su#

su means “substitute user”.

Form Typical effect
su student Switch to student, keep much of your current environment
su - student Switch to student as a login shell (loads that user’s environment, starts in their home)
su - or su - root Become root as a login shell (requires root password or sudo policy)

On many modern desktops, day-to-day admin work uses sudo instead of a root password. If su asks for a password you do not have, stop and use the method your admin documented.


4. Command syntax: command, options, arguments#

A typical line looks like:

command  [options…]  [arguments…]

Example:

ls -l /tmp/linux-lab-pushpjeet
  • command: ls — the program to run
  • option: -l — modify behaviour (long listing)
  • argument: /tmp/linux-lab-pushpjeet — what to operate on

Options often start with - (short) or -- (long). Many commands accept both (-a and --all).

Try a few safe “status” commands:

uname -a
date
cal
clear    # clears the terminal screen; no output to paste
ls
ls -l

Sample outputs from a practice host:

uname -a
Linux grok-bot-vm-270875175 6.12.94+ #1 SMP PREEMPT_DYNAMIC Wed Sep 23 20:54:12 UTC 2026 x86_64 GNU/Linux
date
Sat Sep 26 11:04:52 IST 2026
cal
   September 2026
Su Mo Tu We Th Fr Sa
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

If cal is missing on a minimal image, install the calendar package for your distro (ncal / bsdmainutils on Debian/Ubuntu, or the equivalent on RHEL-family) — or simply rely on date for now.


5. Getting help with man#

Manual pages are the built-in textbook. Try:

man ls

The pager opens. Useful keys in less (the usual pager):

Key Action
Space / f Forward a page
b Back a page
/text Search forward for text
n Next search hit
q Quit

The top of man ls looks like:

LS(1)                        User Commands                       LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs (the current directory by default).
…
       -a, --all
              do not ignore entries starting with .

Read the SYNOPSIS and DESCRIPTION first. Skim options when you need a flag.

Sections#

Manual pages are grouped by section number. You will see LS(1) — section 1 is user commands. Other common sections: 5 file formats, 8 admin commands.

man 1 ls          # section 1 explicitly
man -k list       # keyword search (apropos)
man -f ls         # whatis-style short description

Examples:

man -f ls
ls (1)               - list directory contents
man -k list | head
dir (1)              - list directory contents
ls (1)               - list directory contents
…

If man says “nothing appropriate,” the pages may not be installed on a slim container image. On a normal Ubuntu or RHEL-family desktop/server install they are usually present. You can also try ls --help for a short option list:

ls --help | head -15
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
…
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..

6. A first look at ls -l#

ls -l /tmp/linux-lab-pushpjeet

You will see permissions, link count, owner, group, size, timestamp, and name. Module 3 goes deeper on paths and listing flags; Module 12 covers permissions in detail. For now, treat ls -l as “tell me more about each entry.”


Practice: MCQs#

Q1. In ls -l /etc, what is the argument?

  • A) ls
  • B) -l
  • C) /etc
  • D) The Enter key
Answer

C. -l is an option; /etc is the path argument; ls is the command.

Q2. What does man -k passwd do?

  • A) Changes your password
  • B) Searches man page short descriptions for the keyword passwd
  • C) Deletes the passwd database
  • D) Opens section 8 only
Answer

B. -k is keyword search (like apropos). Changing passwords uses the passwd command itself.

Q3. Why does passwd show no stars while you type?

  • A) The keyboard is broken
  • B) Linux never accepts passwords
  • C) Hiding keystrokes is normal; type carefully and confirm when asked
  • D) You must be root for any password change
Answer

C. Lack of echo is a security habit. Ordinary users change their own password without being root.

Q4. su - labuser is preferred over plain su labuser when you want:

  • A) A faster prompt colour
  • B) A login-style environment for labuser (home and profile scripts)
  • C) To delete labuser
  • D) To avoid entering any password ever
Answer

B. The dash requests a login shell for the target account.

Q5. You see BASH(1) in a man page header. The (1) means:

  • A) Version 1 of bash only
  • B) Manual section 1 (user commands)
  • C) One matching file on disk
  • D) Priority level 1 for the CPU
Answer

B. Section numbers classify man pages. User commands are typically section 1.


Practice: Flashcards#

Front Back
passwd Change your account password interactively
su - user Switch user with a login shell
cd ~ Change to your home directory
Option vs argument Option changes behaviour (-l); argument is the target (/etc)
man cmd Open the manual page for cmd
man -k word Keyword search across man short descriptions
man -f cmd Short one-line description (whatis)
uname -a Print detailed system/kernel information
cal Display a calendar
Pager key q Quit man / less

Practice: Fill in the blank#

  1. To open the manual for ls, type: ________ ls
  2. Keyword search for manuals mentioning “directory”: man ___ directory
  3. Long listing of /tmp: ls ___ /tmp
  4. Go to your home directory using a tilde: cd ___
  5. Print a full system identifier string: uname ___
Answers
  1. man
  2. -k
  3. -l
  4. ~
  5. -a

Practice: Mini terminal challenge#

Challenge: Learn one new ls flag from man#

Goal: Use the manual instead of a search engine for one flag.

Setup: Terminal with man available.

Tasks:

  1. Run man ls and quit with q once you can navigate.
  2. Search inside the page for human or read about -h / --human-readable if present.
  3. Run ls -lh /tmp (or your lab directory) and note how sizes appear.
  4. Run man -f date and date itself; confirm the short description matches the behaviour.

Verify: You can explain one ls option you did not know before this challenge.

Stretch: Run man man and find how to force a section number.


Hands-on lab#

Goal: Comfort with accounts, syntax, and man.

Steps:

  1. Record whoami, id, and $HOME in your lab notes.
  2. If allowed on your personal account, run passwd and set a strong password you will remember (skip on shared demo accounts you do not own).
  3. Run three commands that each use at least one option: e.g. uname -a, ls -l, date -u (UTC time).
  4. Open man ls, find the option for showing hidden files, then run it.

Verify: ls -a shows . and .. (and other dotfiles if any). Your notes list command / option / argument for one example line.

Stretch: Compare su student vs su - student on a VM where you have a second account — observe $HOME and pwd after each.


Common mistakes#

  • Typing passwords into the shell prompt by accident (password prompts look similar — read carefully)
  • Closing man with Ctrl+C instead of q (Ctrl+C may work but q is the intended pager exit)
  • Assuming --help and man always exist on every minimal container (install docs packages when needed)
  • Using su to become root for ordinary file practice

Summary#

You can navigate home, reason about command syntax, change your password, and learn tools from man. Those habits unlock every later module.

Continue

← Linux from Scratch hub · Cheat sheet · All tutorials