Fundamentals 55 min read

Master Linux Basics: Essential Commands and Tips for Beginners

This comprehensive guide walks you through the fundamentals of Linux, covering operating system concepts, core commands, file management, user permissions, process monitoring, networking, package management, compression, backup, and Vim editing, empowering beginners to confidently navigate and administer Linux environments.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux Basics: Essential Commands and Tips for Beginners

Foreword

Learning Linux is essential for programmers. Front‑end developers have fewer opportunities to work with Linux, so it is easy to overlook, but mastering it is a vital skill for any developer.

Linux Basics

Operating System

An operating system (OS) is the software layer that sits on top of hardware, providing basic services and managing resources. The OS kernel (e.g., Linux kernel) handles hardware abstraction, file systems, and multitasking.

What Is Linux?

The Linux kernel is maintained by Linus Torvalds. A Linux distribution combines the kernel with a collection of software packages (e.g., Ubuntu, CentOS, Debian). The kernel provides the core, while the distribution adds tools, libraries, and a package manager.

Linux vs. Windows

Stable and efficient

Free (or low‑cost)

Quick security patches

Multi‑user, multitasking

Strong permission model

Suitable for embedded systems

Resource‑light

Linux Distributions

Red Hat Enterprise Linux (RHEL)

Fedora (upstream of RHEL)

CentOS (binary‑compatible with RHEL)

Deepin (Chinese distro)

Debian (stable, widely used)

Ubuntu (Debian‑based, desktop and server)

Connecting to an Alibaba Cloud Server

ssh [email protected]

Enter the password to log in and start using the remote server.

Shell

The shell (e.g., Bash) is a command‑line interpreter that provides a prompt, reads user input, and passes commands to the OS. It also supports scripting, variables, conditionals, and loops.

Common Shells

Bourne Shell (sh)

Bourne Again Shell (bash) – default on most Linux systems

C Shell (csh)

TC Shell (tcsh)

Korn Shell (ksh)

Z Shell (zsh)

Friendly Interactive Shell (fish)

Use echo $SHELL to see the current shell.

Basic Commands

Command Prompt

The prompt usually ends with $ for regular users or # for root.

Common Commands

pwd

– show current directory which – locate the executable of a command ls – list files (common options: -a, -l, -h, -t, -i) cd – change directory (e.g., cd /, cd ~, cd ..) du – display directory size (options: -h, -a, -s) cat – display file contents less – paginate file view (navigation keys: space, b, q, /, n, N, etc.) head / tail – show beginning or end of a file (options: -n, -f) touch – create an empty file mkdir – create a directory ( -p for parent directories) cp – copy files ( -r for recursive) mv – move or rename files rm – delete files ( -i, -f, -r) ln – create links (hard link or symbolic link with -s)

Permissions

Permissions are expressed as rwx for read, write, execute. They are shown as three groups: owner, group, others (e.g., drwxr-xr-x). Use chmod to modify them (numeric mode like chmod 740 file or symbolic mode like chmod u+rx,g+r file).

Searching Files

locate

Fast database‑based search. Update the database with updatedb.

find

find /path -name "pattern" -type f -exec chmod 600 {} \;

Powerful recursive search with actions.

Package Management

yum (CentOS/RHEL)

yum update

/

yum upgrade
yum search pkg
yum install pkg
yum remove pkg

Switching CentOS Mirrors

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

Manual Pages

Use man command to read documentation. Sections include user commands, system calls, libraries, files, games, miscellaneous, system administration, and kernel.

Process Management

Viewing Processes

w

– who is logged in and what they are doing ps – snapshot of processes (options: -ef, -aux) top – dynamic view of CPU usage

Controlling Processes

kill PID

– terminate a process kill -9 PID – force kill & – run a command in the background nohup cmd & – run command immune to hangups bg %1 – resume a stopped job in background jobs – list background jobs fg %1 – bring a job to the foreground

Daemons

System services run as daemons (process ID 1 is systemd). Manage them with systemctl start|stop|restart|status|enable|disable service.

File Compression

tar

tar -cvf archive.tar file1 file2
tar -xvf archive.tar

gzip / gunzip

gzip archive.tar
gunzip archive.tar.gz

tar + gzip

tar -zcvf archive.tar.gz folder/
 tar -zxvf archive.tar.gz

zip / unzip

zip -r archive.zip folder/
unzip archive.zip

Building Software from Source

Download source (e.g., wget https://example.com/htop-3.0.0.tar.gz)

Extract: tar -zxvf htop-3.0.0.tar.gz Enter directory: cd htop-3.0.0 Configure: ./configure Compile: make Install:

sudo make install

Networking

ifconfig

Show network interfaces (install net-tools if missing).

host

host github.com

SSH

ssh user@host   # default port 22
ssh -p 2222 user@host

Configure ~/.ssh/config for shortcuts and enable key‑based authentication with ssh-keygen and ssh-copy-id.

wget

wget -c http://example.com/file.zip

Backup

scp

scp local.txt user@host:/remote/path/
scp user@host:/remote/file.txt ./

rsync

rsync -arv source/ destination/
rsync -arv source/ user@host:/remote/

System Control

halt

– shut down (requires root) reboot – restart (requires root) poweroff – power off

Vim Editor

Modes

Normal (command) mode – navigation, delete, copy, paste

Insert mode – press i, a, o etc.

Command‑line mode – press : then type commands (e.g., :wq)

Visual mode – press v, V, or Ctrl‑v to select text

Basic Editing

Move cursor: h j k l or arrow keys

Delete character: x Delete line: dd Copy line: yy Paste: p Undo: u, redo:

Ctrl‑r

Search & Replace

/pattern   # search forward
?pattern   # search backward
:n,m s/old/new/g   # replace in lines n‑m

Splits

:sp file   # horizontal split
:vsp file  # vertical split
Ctrl‑w w   # cycle windows
Ctrl‑w + / -   # resize
Ctrl‑w q   # close window

.vimrc Example

set number          " show line numbers
syntax on           " enable syntax highlighting
set showcmd         " display incomplete commands
set ignorecase      " case‑insensitive search
set mouse=a         " enable mouse support

Conclusion

By following this guide you should now have a solid foundation in Linux fundamentals, command‑line usage, system administration, and Vim editing, enabling you to work confidently in Linux environments.

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.

Linuxbasics
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.