• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Linux Tutorials Commands

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

neo by neo
May 27, 2025
in Commands
0
Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

0
SHARES
5
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Directories: Change Directory, Print Working Directory, Make Directory

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory) are a fundamental skill for any user. Whether you’re a beginner or someone looking to brush up on the basics, understanding how to move between directories, check your current location, and create new directories is crucial.

Introduction

In the world of Linux, navigating the filesystem and managing directories is very imporant skill. In this tutorial, we’ll cover three essential Linux commands: cd, pwd, and mkdir. These commands form the foundation of directory navigation and organization in a Linux environment, and mastering them will help you become more comfortable working with the terminal. Let’s dive into how each command works and how you can use them effectively.

Navigate directories: pwd / cd

To print current directory:

pwd

To navigate directories and change the current working directory:

cd directory_name

List of Files and Directories: ls

List content fo directories:

ADVERTISEMENT
ls

Output:

appl  bin  boot  dev  etc  home  install  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

Long listing:

ls -l

Output:

root@nginx:/# ls -l
total 2097236
lrwxrwxrwx   1 root root          7 Apr 22  2024 bin -> usr/bin
drwxr-xr-x   2 root root       4096 Feb 26  2024 bin.usr-is-merged
drwxr-xr-x   4 root root       4096 Jan 15 13:21 boot
dr-xr-xr-x   2 root root       4096 Apr 23  2024 cdrom
drwxr-xr-x  20 root root       4100 Jan 16 13:19 dev
drwxr-xr-x 113 root root       4096 Jan 15 13:20 etc
drwxr-xr-x   3 root root       4096 Aug  8 09:05 home
lrwxrwxrwx   1 root root          7 Apr 22  2024 lib -> usr/lib
lrwxrwxrwx   1 root root          9 Apr 22  2024 lib64 -> usr/lib64
drwxr-xr-x   2 root root       4096 Feb 26  2024 lib.usr-is-merged
drwx------   2 root root      16384 Aug  8 07:14 lost+found
drwxr-xr-x   2 root root       4096 Apr 23  2024 media
drwxr-xr-x   2 root root       4096 Apr 23  2024 mnt
drwxr-xr-x   2 root root       4096 Apr 23  2024 opt
dr-xr-xr-x 220 root root          0 Jan 16 13:19 proc
drwx------   4 root root       4096 Sep 13 12:37 root
drwxr-xr-x  27 root root        860 Jan 16 13:20 run
lrwxrwxrwx   1 root root          8 Apr 22  2024 sbin -> usr/sbin
drwxr-xr-x   2 root root       4096 Apr  3  2024 sbin.usr-is-merged
drwxr-xr-x   2 root root       4096 Aug  8 09:05 snap
drwxr-xr-x   2 root root       4096 Apr 23  2024 srv
-rw-------   1 root root 2147483648 Aug  8 07:30 swap.img
dr-xr-xr-x  13 root root          0 Jan 16 13:19 sys
drwxrwxrwt  12 root root       4096 Jan 16 13:20 tmp
drwxr-xr-x  12 root root       4096 Apr 23  2024 usr
drwxr-xr-x  14 root root       4096 Sep 13 10:54 var

If you need to check hidden files execute the following command:

ADVERTISEMENT
ls -a

mkdir (make directory)

The basic syntax of the mkdir command is as follows:

mkdir [OPTION]... DIRECTORY...
  • OPTION: Represents various flags that alter the command’s behavior.
  • DIRECTORY: Specifies the name(s) of the directory(ies) you wish to create.

Basic Usage

Create directory:

mkdir directory_name

Useful Options with mkdir

  • -p (Parents)
mkdir -p parent/child/grandchild

This command creates the parent, child, and grandchild directories in one go.

  • -v (Verbose)
mkdir -v newdir

Output:

mkdir: created directory 'newdir'
  • –m (Mode)
mkdir -m 755 newdir

This command creates newdir with permissions set to 755 (rwxr-xr-x).

rm directory (remove directory)

The basic syntax of the rm command is as follows:

rm [OPTION]... FILE...
  • OPTION: Represents various flags that alter the command’s behavior.
  • FILE: Specifies the name(s) of the file(s) or directory(ies) you wish to delete.

Basic Usage

rm file.txt

Useful options with rm

  • -r (Recursive)
# Remove directory and content
rm -r directory
  • -f (Force)
rm -f file.txt

The -f option forces the removal of files or directories without prompting for confirmation. This is useful for scripts or automated tasks.

  • -i (Interactive)

The -i option prompts for confirmation before each file is deleted. For example:

rm -i file1.txt file2.txt

This command prompts you before deleting each file.

ADVERTISEMENT

defencedev.com

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Install Ubuntu 22.04 on Oracle VM Virtual Box

Next Post

Linux Files Operation: touch, cat, less – Read Content of Files

neo

neo

Next Post
Linux Files Operation: touch, cat, less - Read Content of Files

Linux Files Operation: touch, cat, less - Read Content of Files

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Browse by Category

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.