Fundamentals 10 min read

Master Essential Linux Commands: Poweroff, User Switching, File Management, and Text Processing

This guide presents a comprehensive collection of essential Linux shell commands, covering system power management, user switching, directory navigation, file operations, text processing tools, and powerful search and editing utilities, providing clear syntax and practical options for everyday command‑line tasks.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Essential Linux Commands: Poweroff, User Switching, File Management, and Text Processing

1. Login and Power Management

halt

, poweroff, init 0 – shut down the system. reboot, init 6 – restart. shutdown – schedule shutdown; examples: shutdown -r (reboot), shutdown -h (halt), shutdown -c (cancel), shutdown +0 (immediate), shutdown +1 (in one minute), shutdown -X (in X minutes), shutdown 20:00 (at 20:00). whoami – display current username. who am i – show username, terminal, login time. who – list all logged‑in users. w – detailed info about logged‑in users and their activities.

2. Switch User and Working Directory

su username

– switch to another user and go to that user’s home directory. su username (without login) – switch user without loading login environment. cd [path] – change directory; cd -P follows physical directory when encountering symlinks. .. – parent directory; cd or cd ~ – home directory; cd - – previous directory. pwd – print current working directory.

3. Basic Common Commands

date

– show system time; date -s "2018-1-20 13:50:11" – set system time. hwclock or clock – read hardware clock; -s writes hardware time to system, -w writes system time to hardware. cal – display calendar. history – command history. hostname – show host name.

Interrupt commands: Ctrl+C (force), Ctrl+D (normal).

4. Help and Documentation

type

– determine command type. enable / enable -n – manage internal commands. help – internal command help. command –help – external command help. whereis command – locate binary and manual. which command – locate executable. man command – view manual page.

5. File Listing

ls

– list directory contents; options: -a, -A, -l, -R, -ld, -1. stat filename – detailed file attributes. file filepath – determine file type; -b – brief output; -f filelist – test each file. cat filename – view file. vim filename – edit file.

6. Create, Move, Copy, Delete Files

touch newfile

– create empty file; touch -a, touch -m, touch -t, touch -c – modify timestamps. mkdir -p – create parent directories; -v – verbose; -m mode – set permissions. rmdir – remove empty directory. cp src dst – copy files; options: -i, -r, --preserve=mode,owner,timestamp, -p, -d, -v, -a, -f. mv src dst – move/rename; -i, -f. rm filename – delete; -i, -f, -r; use ls | xargs rm -rf for many files; --no-preserve-root to override safety.

7. Text Processing Commands

tr [set1] [set2]

– translate characters; -d delete, -c complement, -s squeeze repeats. cut -d delim -f list filename – extract fields; --output-delimiter=delim sets output separator. sort – sort lines; -t delim, -k, -n, -r, -u, -f. uniq – remove duplicate lines; -c, -d, -u.

8. Regular Expressions with grep and sed

grep

options: --color=auto, -v, -n, -c, -i, -q, -A n, -B n, -C n, -e, -w, -E, -F. sed options: -i (in‑place), -i.bak (backup), -n (suppress output), -e (script), -f file (script file), -r (extended regex); commands: p, d, a, i, c, w, r, =, !.

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.

Linuxcommand-line
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.