Operations 61 min read

Essential Linux Commands: Installation and Login Basics Explained

This article introduces the most frequently used Linux commands, grouped into installation/login, file handling, system management, network operations, security, and miscellaneous categories, providing purpose, syntax, key options and practical examples for each command.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Essential Linux Commands: Installation and Login Basics Explained

Introduction

Linux provides a large set of commands that allow you to perform disk operations, file access, directory manipulation, process management, and permission settings; mastering these commands is essential for understanding the Linux system.

Command Categories

The most important and frequently used commands are divided into six groups:

Installation and login commands

File handling commands

System management commands

Network operation commands

System security commands

Other useful commands

Installation and Login Commands

login

Purpose: log in to the system (available to all users).

Syntax: login [name] [-p] [-h hostname] Key options: -p: preserve the current environment. -h: specify the remote host name.

Example:

Mandrake Linux release 9.1 (Bamboo) for i586
renrel 2.4.21-0.13mdk on i686 / tty1
localhost login:root
password:

After entering the username and password you are logged in; the password is not echoed for security.

shutdown

Purpose: safely shut down the computer (super‑user only).

Syntax: shutdown [-h] [-i] [-k] [-m] [-t] Key options: -t: time before changing runlevel. -k: send warning signal only, do not actually shut down. -h: halt and power off after shutdown. -c: cancel a pending shutdown. -F: force fsck on reboot. -i: display system information during shutdown.

Example: # shutdown -h now halt

Purpose: halt the system (super‑user only).

Syntax: halt [-n] [-w] [-d] [-f] [-i] [-p] Key options: -n: prevent sync system call. -w: write wtmp record only. -f: force halt without calling shutdown. -i: bring down network interfaces before halt. -p: power off after halt. -d: halt without leaving a record.

Example: # halt -p reboot

Purpose: restart the computer (system administrator only).

Syntax: reboot [-n] [-w] [-d] [-f] [-i] Key options: -n: do not write memory to disk before reboot. -w: write to wtmp only. -d: do not write to wtmp (implied by -n). -i: stop network interfaces before reboot.

Example: # reboot -f install

Purpose: copy files, set permissions, or create directories (all users).

Syntax:

install [options] source destination
install [options] source... directory
install -d [options] directory...

Key options: --backup[=CONTROL]: backup existing destination files. -b: backup without arguments. -c: (no effect). -d, --directory: treat arguments as directories and create parents. -D: create missing parent directories before copying. -g, --group=GROUP: set group ownership. -m, --mode=MODE: set permission bits. -o, --owner=OWNER: set file owner (super‑user only). -p, --preserve-timestamps: preserve access/modification times. -s, --strip: strip symbols (for binaries). -S, --suffix=SUFFIX: set backup suffix. -v, --verbose: show each file processed. --help, --version mount

Purpose: mount a filesystem (super‑user or users allowed in /etc/fstab).

Syntax: mount [-a] [-fv] [-t vfstype] [-n] [-rw] [-F] device dir Key options: -a: mount all filesystems listed in /etc/fstab. -F: fork a helper process for each mount (useful for many NFS mounts). -f: fake mount (debug mode). -v: verbose output. -t vfstype: specify filesystem type. -n: do not write to /etc/mtab.

Example (mount a Windows FAT partition): # mount -t vfat /dev/hda1 /mnt/winc To display Chinese filenames on the mounted partition:

# mount -t vfat -o iocharset=cp936 /dev/hda1 /mnt/winc

umount

Purpose: unmount a filesystem (super‑user or allowed users).

Syntax:

umount [-a] [-fFnrsvw] [-t vfstype] [-n] [-rw] [-F] device dir

Example: # umount /cdrom chsh

Purpose: change a user's login shell (all users).

Syntax: chsh [-s shell] [-list] [--help] [-v] [username] Key options: -l: list all available shells. -v: show shell version.

Example:

Changing login shell for cao
Password:
New shell [/bin/bash]: /bin/tcsh

exit

Purpose: exit the current shell (all users).

Syntax: exit last

Purpose: show recent login sessions (all users).

Syntax: last [-n] [-f file] [-t tty] [-h] [-I IP] [-1] [-y] [ID] Key options: -n: limit number of records. -f file: specify log file. -t tty: show records for a specific virtual console. -h: filter by hostname. -I IP: filter by IP address. -1: display IP instead of hostname. -y: show year, month, day. -ID: filter by username. -x: show system shutdown, login and logout history.

File Handling Commands

file

Purpose: determine file type (all users).

Syntax: file [options] filename Key options: -v: show version. -z: test compressed files. -L: follow symlinks. -f name: read file names from name.

Example:

$ file grap
grap: English text

mkdir

Purpose: create a directory (all users).

Syntax: mkdir [options] dirname Key options: -m, --mode=MODE: set permission bits. -p, --parents: create parent directories as needed. -v, --verbose: report each created directory.

Example: $ mkdir -m 777 tsk grep

Purpose: search for patterns in files (all users).

Syntax: grep [options] pattern [file...] Key options: -c: count matching lines. -i: ignore case. -h: suppress filename prefix. -l: list only matching filenames. -n: show line numbers. -s: suppress error messages. -v: invert match.

Example (find IP‑like strings): $ grep '[0-9]\{3\}\.[0-9]\{3\}' ipfile dd

Purpose: convert and copy files at low level (all users).

Syntax: dd [options] Key options: bs=BYTES: set both input and output block size. cbs=BYTES: convert BYTES at a time. conv=KEYWORDS: conversion flags. count=BLOCKS: copy only BLOCKS input blocks. ibs=BYTES: input block size. if=FILE: input file. obs=BYTES: output block size. of=FILE: output file. seek=BLOCKS: skip BLOCKS on output. skip=BLOCKS: skip BLOCKS on input.

Example (write a Linux kernel to a floppy): # dd if=vmlinuz of=/dev/fd0 find

Purpose: search for files in a directory hierarchy (all users).

Syntax: find [path] [options] [expression] Key options: -depth: process contents before the directory itself. -maxdepth N: descend at most N levels. -mindepth N: descend at least N levels. -mount: stay on the same filesystem. -name PATTERN: match filename (supports * and ?). -atime N: files accessed N days ago. -ctime N: files changed N days ago. -user USER: files owned by USER. -group GROUP: files belonging to GROUP. -size N: files of size N blocks. -print: output the found path.

Example (find a file named lilo.conf on the whole system): # find / -name lilo.conf mv

Purpose: move or rename files and directories (all users).

Syntax: mv [options] source target Key options: -i: interactive, ask before overwriting. -f: force, do not ask.

Example (rename a file): $ mv cjh.txt wjz.txt ls

Purpose: list directory contents (all users).

Syntax: ls [options] [file...] Key options (selected): -a, --all: do not ignore entries starting with . -l: long format. -h: human‑readable sizes. -R, --recursive: list subdirectories recursively. -S: sort by size. -t: sort by modification time. -r: reverse order.

Example (long listing): $ ls -l diff

Purpose: compare two files line by line (all users).

Syntax: diff [options] file1 file2 Key options: -a: treat all files as text. -b: ignore changes in the amount of whitespace. -B: ignore blank lines. -c: produce context diff. -H: speed up search on large files. -I: ignore case. -n, --rcs: RCS format.

cmp

Purpose: compare two files byte by byte (all users).

Syntax: cmp [options] file1 file2 Key option: -l: output differing byte numbers in octal and decimal.

cat

Purpose: concatenate and display files (all users).

Syntax: cat [options] file1 [file2 ...] Key options: -n: number all output lines. -b: number non‑blank lines. -s: squeeze multiple blank lines.

Example (display a README file): $ cat README ln

Purpose: create hard or symbolic links (all users).

Syntax: ln [options] source [linkname] Key options: -s: create a symbolic link. -f: remove existing destination files. -d: allow hard‑linking directories (super‑user). -b: backup existing files before linking.

Example (create a shortcut to a web‑server document root):

$ ln -s /usr/local/httpd/htdocs gg

System Management Commands

df

Purpose: report filesystem disk space usage (all users).

Syntax: df [options] Key options: -h: human‑readable sizes. -T: show filesystem type. -i: display inode usage. -k: show sizes in kilobytes. -a: include pseudo, duplicate, and inaccessible filesystems.

Example:

# df -T
Filesystem   Type   1K-blocks   Used   Available   Use%   Mounted on
/dev/hda7    reiserfs   5.2G   1.6G   3.7G   30%   /
/dev/hda1    vfat       2.4G   1.6G   827M   66%   /windows/C

top

Purpose: display running processes and system load (all users).

Syntax: top [-] [-d delay] [-q] [-c] [-S] [-s] [-i] [-n] Key options: -d: update interval in seconds. -q: no delay, run with highest priority if super‑user. -c: show full command line. -S: cumulative mode. -i: hide idle and zombie processes. -n: number of updates before exiting.

Interactive keys:

Space: immediate refresh.

P: sort by CPU usage.

M: sort by memory usage.

T: sort by time.

c: toggle command line/full path.

q: quit.

free

Purpose: display memory usage (all users).

Syntax: free [options] Key options: -b, -k, -m: display in bytes, kilobytes, megabytes. -s SECONDS: repeat every SECONDS. -t: show total line. -o: omit the buffer/cache line.

Example (continuous monitoring every 5 seconds): # free -b -s5 quota

Purpose: display disk usage limits (super‑user).

Syntax: quota [-g] [-u] [-v] [-p] user Key options: -g: show group limits. -u: show user limits. -v: show limits for filesystems without quotas. -p: display a concise report.

Example:

# quota caojh
Disk quotas for user caojh (uid 502):
Filesystem  blocks  quota  limit  grace  files  quota  limit  grace
/dev/hda3   58    200000 400000  41    500   1000

at

Purpose: schedule a command to run once at a specified time (all users).

Syntax: at [options] time Key options: -f file: read commands from file. -m: mail you when the job finishes. -q queue: select a queue. -V: verbose.

Example (run data two days later at 15:30): # at -f data 15:30 +2 days lp

Purpose: print files (all users).

Syntax: lp [options] file... Key options: -c: copy before printing. -d: specify printer queue. -m: mail when done. -n: number of copies. -p: set priority (0‑100, default 50).

Example: # lp -d LaserJet -p 90 /etc/aliases useradd

Purpose: create a new user account (super‑user).

Syntax: useradd [options] username Key options: -c comment: GECOS field. -d home: home directory. -s shell: login shell. -m: create home directory. -u UID: specify user ID. -g GID: primary group. -G groups: supplementary groups. -e date: account expiration date. -f days: days after password expiry before disabling. -r: create a system account.

Example: # useradd caojh -u 544 groupadd

Purpose: add a new group to the system (super‑user).

Syntax: groupadd [options] groupname Key options: -g GID: specify group ID. -o: allow non‑unique GID. -r: create a system group (GID < 500). -f: exit silently if the group already exists.

Example: # groupadd -g 344 cjh kill

Purpose: send a signal to a process (all users).

Syntax: kill [-s signal | -p] [-a] pid... Key options: -s signal: specify the signal to send. -l: list signal names. -p: simulate sending a signal.

Example (force kill PID 324): # kill -9 324 Kill can also be used to reload configuration files, e.g. after editing /etc/inetd.conf:

# ps -ef | grep inetd   # find PID, assume 1426
# kill -HUP 1426          # make inetd reread its config

crontab

Purpose: maintain a table of periodic commands (all users).

Syntax: crontab [options] file or crontab -e|-l|-r Key options: -e: edit the current crontab with the default editor. -l: list the current crontab. -r: remove the current crontab. -u user: operate on another user's crontab (super‑user).

Crontab entry format: M H D m d command (minute, hour, day of month, month, day of week).

Example (run antivir every day at 09:05): 05 09 * * * antivir After saving, the job will be stored in /var/spool/cron/username.

Practice Exercises

1. Combine multiple commands on one line using a semicolon, e.g. # last -x; halt to display login history and then shut down.

2. Mount a Windows partition on /mnt/winc: # mount -t vfat /dev/hda1 /mnt/winc To display Chinese filenames:

# mount -t vfat -o iocharset=cp936 /dev/hda1 /mnt/winc

3. Mount a USB flash drive: # mount /dev/sda1 /usb 4. Create symbolic links for quick access, e.g. # ln -s /usr/local/httpd/htdocs gg.

5. Use dd to write a kernel image to a floppy: # dd if=vmlinuz of=/dev/fd0.

6. Use grep together with ls to list only directories: $ ls -l | grep '^d'.

7. Use kill together with top to observe system performance changes after terminating a process.

8. Schedule a shutdown with at:

# at 17:35
at> halt -i -p
at> ^D

9. Use crontab to schedule a daily virus scan at 09:05.

10. After editing /etc/inetd.conf, reload it with kill -HUP $(pidof inetd).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxShellcommand-lineUnixSystem Administration
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.