Operations 39 min read

Essential Linux Installation and Login Commands Explained

This guide walks through the most frequently used Linux installation and login commands—such as login, shutdown, halt, reboot, install, mount, umount, chsh, exit, last, file, mkdir, grep, dd, find, mv, ls, diff, cmp, cat, and ln—detailing their purpose, syntax, key options, and practical examples for effective system administration.

ITPUB
ITPUB
ITPUB
Essential Linux Installation and Login Commands Explained

Introduction

Linux provides a rich set of commands for disk operations, file access, directory handling, process management, and permission settings. Mastering these commands is essential for understanding and working efficiently on any Linux system.

Login Command

Purpose: Logs a user into the system; available to all users.

Syntax: login [name] [-p] [-h hostname] Key Options: -p: Preserve the current environment variables. -h: Specify the remote host name for network logins.

Typical console output when logging in as root:

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

After successful authentication, the prompt changes to [root@localhost root]# and displays the last login time.

Shutdown Command

Purpose: Safely powers off the computer; requires superuser privileges.

Syntax: shutdown [-h] [-i] [-k] [-m] [-t] Important Options: -t: Delay before changing runlevel. -k: Send warning signal without actually shutting down. -h: Halt after shutdown (power off). -c: Cancel a pending shutdown. -F: Force fsck on reboot. -m: Switch to single‑user mode. -i: Display system information during shutdown.

Example: shutdown -h 3:40 – schedule shutdown at 3:40.

Halt Command

Purpose: Stops the system; superuser only.

Syntax: halt [-n] [-w] [-d] [-f] [-i] [-p] Key Options: -n: Skip sync system call. -w: Write to /var/log/wtmp only. -f: Force halt without invoking shutdown. -i: Deactivate network interfaces before halt. -p: Power off after halt. -d: Halt without leaving a record.

Effectively equivalent to shutdown -h.

Reboot Command

Purpose: Restarts the computer; requires system administrator rights.

Syntax: reboot [-n] [-w] [-d] [-f] [-i] Key Options: -n: Do not write memory to disk before reboot. -w: Record the reboot in /var/log/wtmp only. -d: Do not write to /var/log/wtmp (implied by -n). -i: Deactivate network interfaces before reboot.

Install Command

Purpose: Installs or upgrades software and can copy files; available to all users.

Syntax:

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

Key Options: --backup[=CONTROL]: Backup existing destination files. -b: Shortcut for --backup without arguments. -d, --directory: Treat arguments as directories and create missing parent directories. -m, --mode=MODE: Set permission mode (like chmod). -p, --parents: Create parent directories as needed. -v, --verbose: Show each file created.

Mount Command

Purpose: Attaches a filesystem to the directory tree; requires superuser or permitted user.

Syntax: mount -a [-fv] [-t vfstype] [-n] [-rw] [-F] device dir Key Options: -a: Mount all filesystems listed in /etc/fstab. -t vfstype: Specify filesystem type (e.g., ext2, vfat, iso9660). -F: Run mount helper for each mount point (useful for many NFS mounts). -f: Simulate mount without performing actual mount (debugging). -v: Verbose output.

Example: Mount a Windows FAT partition with Chinese filename support:

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

Umount Command

Purpose: Detaches a mounted filesystem; superuser or permitted user.

Syntax: umount -a [-fFnrsvw] [-t vfstype] [-n] [-rw] [-F] device dir It is the inverse of mount. If a CD‑ROM is mounted, umount will lock it, preventing the physical eject button from working until the filesystem is unmounted.

chsh Command

Purpose: Changes a user's default shell; available to all users (users can change only their own shell, superuser can change any).

Syntax: chsh [-s shell] [-list] [--help] [-v] [username] Key Options: -l: List all available shells. -v: Show shell version.

After entering the password, the new shell is confirmed with a “Shell change” message.

exit Command

Purpose: Exits the current shell session; available to all users.

Syntax: exit No parameters; returns to the login prompt.

last Command

Purpose: Shows recent login sessions; available to all users.

Syntax:

last [-n] [-f file] [-t tty] [-h host] [-I IP] [-1] [-y] [-D]

Key Options: -n: Limit number of records displayed. -f file: Use an alternate log file. -t tty: Show entries for a specific terminal. -h host: Show entries for a specific host. -I IP: Show entries for a specific IP address. -1: Display IP addresses instead of hostnames. -y: Show year, month, and day. -D: Show system shutdown, login, and logout history.

file Command

Purpose: Determines file type by examining its contents; available to all users.

Syntax: file [options] filename Key Options: -v: Show version information. -z: Detect compressed file types. -L: Follow symbolic links. -f name: Read a list of filenames from name.

Example: file grapgrap: English text.

mkdir Command

Purpose: Creates a new directory; available to all users.

Syntax: mkdir [options] directory_name 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 creates tsk with full read/write/execute permissions for everyone.

grep Command

Purpose: Searches files for lines matching a pattern; available to all users.

Syntax: grep [options] pattern [file...] Key Options: -c: Output only the count of matching lines. -i: Case‑insensitive search. -h: Suppress filename prefix when searching multiple files. -l: List only names of files with matches. -n: Show line numbers. -s: Suppress error messages for nonexistent files. -v: Invert match (show non‑matching lines).

Regular‑expression basics are also described (e.g., ^, $, ., *).

dd Command

Purpose: Copies and converts raw data between files or devices.

Syntax: dd [options] Key Options: bs=BYTES: Set both input and output block size. count=BLOCKS: Copy only the specified number of blocks. if=FILE: Input file (default is stdin). of=FILE: Output file (default is stdout). skip=BLOCKS: Skip blocks at start of input. seek=BLOCKS: Skip blocks at start of output.

Common use: writing a bootable kernel to a floppy: dd if=vmlinuz of=/dev/fd0.

find Command

Purpose: Searches for files in a directory hierarchy; available to all users.

Syntax: find [path] [options] [expression] Key Options: -depth: Process contents of a directory before the directory itself. -maxdepth N: Descend at most N levels. -mindepth N: Descend at least N levels. -name PATTERN: Match filename (supports * and ?). -size N: Match files of size N blocks. -mtime N: Files modified N days ago. -print: Output matching paths.

Example: find / -name lilo.conf searches the entire filesystem for lilo.conf.

mv Command

Purpose: Moves or renames files and directories; available to all users.

Syntax: mv [options] source target Key Options: -i: Prompt before overwriting. -f: Force overwrite without prompting.

Examples: mv /usr/cbu/* . – move all files from /usr/cbu to the current directory. mv cjh.txt wjz.txt – rename a file.

ls Command

Purpose: Lists directory contents; similar to Windows dir.

Syntax: ls [options] [file] Key Options: -a, --all: Show all entries, including those starting with .. -l: Long format with permissions, owner, size, and timestamps. -h: Human‑readable sizes. -R: Recursive listing. -t: Sort by modification time. -S: Sort by size.

Color coding indicates file types (e.g., blue for directories, green for executables).

diff Command

Purpose: Compares two files and reports differences; available to 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: Context output format. -i: Ignore case differences.

cmp Command

Purpose: Reports the first difference between two files; available to all users.

Syntax: cmp [options] file1 file2 Key Option: -l – list differing bytes in octal and decimal.

cat Command

Purpose: Concatenates and displays file contents; available to all users.

Syntax: cat [options] file1 [file2 ...] Key Options: -n: Number all output lines. -b: Number non‑blank lines only. -s: Squeeze multiple blank lines into one.

Examples: cat README – display a file. cat README INSTALL > File1 – combine files into File1.

ln Command

Purpose: Creates hard or symbolic links between files; available to all users.

Syntax: ln [options] source [link_name] Key Options: -s: Create a symbolic (soft) link. -f: Remove existing destination files. -d: Allow hard linking of directories (superuser only).

Hard links share the same inode; deleting one does not remove the data until the last link is removed. Symbolic links are special files that contain the path to the target.

Small Exercises

1. Run multiple commands in one line: Separate commands with a semicolon, e.g., last -x; halt to display login history and then shut down.

2. Mount a Windows partition: mount -t vfat /dev/hda1 /mnt/winc (add -o iocharset=cp936 for Chinese filenames).

3. Mount a USB flash drive: mount /dev/sda1 /usb.

4. Create a symbolic link for quick access: ln -s /usr/local/httpd/htdocs gg – then cd gg jumps directly to the web server document root.

5. Use dd to write an initrd image to RAM: dd if=root.ram of=/dev/ram0.

6. Use grep in pipelines: ls -l | grep '^d' lists only directories; ls -l | grep '^.[^d]' lists non‑directory files.

7. Combine find and grep :

find /src -name '*.c' -exec grep -q -s 'Chinput' {} \\; -print

finds C source files containing “Chinput”.

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.

LinuxTutorialInstallationfile management
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.