• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • 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
    • Bash Scripts
  • 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
15
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:

ADVERTISEMENT
pwd

To navigate directories and change the current working directory:

cd directory_name

List of Files and Directories: ls

List content fo directories:

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:

ADVERTISEMENT
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.

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

Related Posts

Check Disk Usage on the Linux with du Command
Commands

Check Disk Usage on the Linux with du Command

Linux Process, List all Running Services with ps Command
Commands

Linux Process, List all Running Services with ps Command

Descripton for kill command on Ubuntu
Commands

Linux Process Management, kill Command

Linux Files Operation: chwon (Change Ownership of The Files)
Commands

Linux Files Operation: chown (Change Ownership of the Files)

Linux Files Operation: grep, Efficient Text Search
Commands

Linux Files Operation: grep, Efficient Text Search

Linux Files Operation: find Temp Files and Execute Commands on Found Files
Commands

Linux Files Operation: find Temp Files and Execute Commands on Found Files

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

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

Recommended

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

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

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Docker Command Cheat Sheet (2025 Edition)

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Categories

  • 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
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

Recent News

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

  • 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
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.