Fundamentals 9 min read

Master Essential Linux Commands: From pwd to du with Real Examples

This tutorial introduces the most frequently used Linux commands—including pwd, cd, ls, touch, mkdir, cp, rm, mv, find, and du—explaining their purpose, options, and providing concrete shell examples to help beginners confidently navigate and manage files and directories.

Open Source Linux
Open Source Linux
Open Source Linux
Master Essential Linux Commands: From pwd to du with Real Examples

Foreword

Previously we covered how to install a Linux operating system and its boot process.

Today we will study common Linux commands with practical usage examples.

Basic Operations on Directories and Files

1. pwd

Description: pwd displays the current working directory.
Usage: pwd [options]...
Options:
 -P  Show the physical (real) path of a symbolic link.
[root@qll ln-test]# pwd
/root/ln-test
[root@qll ln-test]# pwd -P
/root/test
# /root/ln-test is a symbolic link to /root/test
[root@qll ln-test]# ll -h /root/ln-test
lrwxrwxrwx. 1 root root 4 Feb 8 17:55 /root/ln-test -> test

2. cd

Description: cd changes the current working directory.
Usage:
 cd ..   Move to the parent directory.
 cd -    Return to the previous directory.
 cd      Change to the current user's home directory.
[root@qll opt]# cd /root/test   # switch to /root/test
[root@qll test]# cd ..          # go up one level
[root@qll ~]# cd -               # return to previous directory (/root/test)
[root@qll test]# cd               # go to home directory

3. ls

Description: ls lists directory and file information.
Usage: ls [options]... [file/dir]
Options:
 -a  Show all files, including hidden ones.
 -d  Show information about the directory itself, not its contents.
 -h  Human‑readable sizes.
 -l  Long format with detailed info.
 -i  Show inode numbers.
 -S  Sort by size.
 -u  Show last access time.
[root@qll ~]# ls               # list names in current directory
[root@qll ~]# ls /usr          # list /usr contents
[root@qll ~]# ls -a            # include hidden files
[root@qll ~]# ls -l            # detailed list
[root@qll ~]# ls -lh           # human‑readable sizes
[root@qll ~]# ls -lu /etc/passwd   # show last access time of /etc/passwd

4. touch

Description: Create a new file or update the timestamps of an existing file.
Example:
 [root@qll ~]# touch test.txt   # creates test.txt if it does not exist; otherwise updates its timestamps.

5. mkdir

Description: Create directories.
Usage: mkdir [options]... directory...
Options:
 -p  Create parent directories as needed (multi‑level).
[root@qll ~]# mkdir data
[root@qll ~]# mkdir -p /home/123/456

6. cp

Description: Copy files and directories.
Usage: cp [options] source destination
Options:
 -r  Recursively copy directories.
 -a  Preserve all attributes (permissions, timestamps, etc.).
[root@qll ~]# cp /etc/passwd /opt               # copy passwd to /opt
[root@qll ~]# cp /etc/passwd /opt/passwd.bat   # copy and rename
[root@qll ~]# cp -r /var/log /tmp/            # recursive copy of /var/log

7. rm

Description: Delete files or directories.
Usage: rm [options]... file...
Options:
 -f  Force deletion without prompts.
 -r  Recursively delete directories and their contents.
[root@qll ~]# rm test.txt          # delete a file
[root@qll ~]# rm -rf /tmp/data    # delete a directory tree without confirmation

8. mv

Description: Move or rename files and directories.
[root@qll ~]# mv red.txt red2.txt          # rename file
[root@qll ~]# mv red2.txt /tmp/           # move file to /tmp

9. find

Description: Search for files or directories.
Usage: find [options] [path] [expression]
Common options:
 -name   Search by exact name.
 -iname  Search by name, case‑insensitive.
 -mtime  Search by modification time.
 -group  Search by group.
 -user   Search by owner.
 -size   Search by size.
 -type   Search by type (f=file, d=directory, l=link, b=block, c=character).
 -exec   Execute a command on each matched file.
 -a      Logical AND.
 -o      Logical OR.
[root@qll ~]# find -name "pa.txt"                     # exact name in current dir
[root@qll ~]# find -iname "Pa.txt"                    # case‑insensitive
[root@qll ~]# find /etc -name "*.deny"                # files ending with .deny in /etc
[root@qll ~]# find / -mtime -1                        # modified within last day
[root@qll ~]# find / -mtime +3                        # modified more than 3 days ago
[root@qll ~]# find / -group qll                       # files owned by group qll
[root@qll ~]# find / -user qll                        # files owned by user qll
[root@qll ~]# find /opt -size +50M                    # files larger than 50 MiB
[root@qll ~]# find / -size +500M -exec ls -lh {} \;   # list details of files >500 MiB
[root@qll ~]# find / -size +1M -a -type f             # files >1 MiB that are regular files

10. du

Description: Estimate file and directory space usage.
Usage: du [options]... [file/dir]...
Options:
 -h  Human‑readable output.
 -s  Show only the total size.
[root@qll ~]# du -h /etc          # human‑readable sizes for /etc and sub‑dirs
[root@qll ~]# du -sh /etc         # total size of /etc only
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.

LinuxTutorialfile management
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.