Fundamentals 8 min read

Master Linux Basics: 8 Essential Commands from ls to rm

This tutorial walks you through eight fundamental Linux commands—ls, cd, mkdir, touch, cp, mv, rm, and cat/less—explaining key options, practical examples, and safety tips so you can navigate, manage files, and work efficiently from the terminal.

AI Agent Super App
AI Agent Super App
AI Agent Super App
Master Linux Basics: 8 Essential Commands from ls to rm

When you log into a server and see the black‑on‑white terminal, you may want to type a few commands to show off, but often end up pasting with the mouse. This guide introduces eight essential Linux commands with detailed options, examples, and screenshots to help you become proficient.

1. ls – view files with useful options

The basic ls lists filenames, but adding options provides richer information. -l shows permissions, owner, size, and timestamp; -a includes hidden files; -h makes sizes human‑readable; -t sorts by modification time. Combining them as ls -lth sorts by newest first and displays sizes in a readable format, which is handy for logs and large directories.

[root@VM-0-4-centos ~]# ls -lth

The screenshot shows the largest access.log and the newest nginx_conf/ at the top, eliminating the need to scroll.

2. cd – navigate directories

Use cd <path> to change directories. Handy shortcuts include cd .. (parent), cd ~ (home), and cd - (previous directory), which is especially useful when hopping between two locations. After changing directories, running pwd confirms your current location.

3. mkdir – create directories

mkdir new_folder

creates a single directory. The -p option creates parent directories as needed, so a single command like mkdir -p project/src/main/java builds a four‑level hierarchy instantly.

4. touch – create empty files or update timestamps

Running touch filename creates an empty file instantly. If the file already exists, touch updates its modification time, which some build tools rely on.

5. cp – copy files and directories

Basic syntax is cp source target. Use -r to copy directories recursively and -i for interactive prompts before overwriting. A typical use case is backing up a configuration directory: cp -r project/ project_backup/.

[root@VM-0-4-centos ~]# cp -r project/ project_backup/

6. mv – move or rename files

mv

moves files, but when the source and destination are in the same directory it effectively renames the file, which is faster than using a GUI rename. Example: mv app-v1.0.jar app-latest.jar updates a versioned filename.

[root@VM-0-4-centos ~]# mv app-v1.0.jar app-latest.jar

7. rm – remove files and directories safely

rm file.txt

deletes a file. Add -r to delete directories recursively and -f to force deletion without prompts. The combination rm -rf is common for cleaning logs or temporary files, but you must double‑check the path, especially when using wildcards like *, to avoid catastrophic data loss.

8. cat & less – view file contents efficiently

cat

is suitable for short files; adding -n shows line numbers, which helps locate configuration entries. For large files (hundreds of megabytes), less streams content page by page, using the space bar to advance and q to quit. Avoid using cat on huge files, as it can freeze the terminal.

Summary

Linux is not scary; the barrier is hesitation to type commands. Master these eight basic commands, combine them with Tab auto‑completion and the up/down arrow history, and your efficiency on a Linux server will far exceed mouse‑driven Windows workflows. The next episode will cover file permission management (chmod/chown) and user management (useradd/groupadd).

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 LineSystem AdministrationFile Management
AI Agent Super App
Written by

AI Agent Super App

AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning

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.