DEV Community

Cover image for Linux Filesystem and Navigation for DevOps (With Practical Demo)
Chetan Tekam
Chetan Tekam

Posted on

Linux Filesystem and Navigation for DevOps (With Practical Demo)

Introduction

As someone preparing for a DevOps role, I’m learning Linux with a lean approach — focusing only on what’s required to operate and debug real servers.

This post covers Linux Filesystem and navigation and hands-on demonstrations on Youtube, from a DevOps perspective.


Practical demonstration

YouTube Demo:

In this video, I demonstrate:

  • Filesystem - /, /etc, /var, /var/log, /home, /opt, /tmp
  • Navigation command - ls, cd, pwd, tree, pushd, popd, dirs
  • What are absolute and relative paths
  • Operation on files and directories - cp, mv, rm, mkdir, ln -s, touch, file

Linux directory structure (DevOps view)

/        → root of everything
/etc     → configuration files
/var     → variable data (logs, runtime)
/var/log → application & system logs
/home    → user home directories
/tmp     → temporary files
Enter fullscreen mode Exit fullscreen mode

Commands Overview

Navigation commands:

# print working directory - return absolute path
~$ pwd
/home/username
# change directory to /
~$ cd /
# to list directory contents
/$ ls
# to add directory to stack
/$ pushd etc/alternatives/ # path not start with / i.e relative path
# to check stack
/etc/alternatives$ dirs -v
# to remove directory to stack
/etc/alternatives$ popd
# to go back to home directory
/$ cd
# to list contents of directories in a tree-like format.
~$ tree [dirctory ...]
Enter fullscreen mode Exit fullscreen mode

Operation on directory:

# To make directory
/tmp$ mkdir DIRNAME
# To make directory along with subdirectory
/tmp$ mkdir -p DIRNAME/SUB-DIR/SUB-SUB-DIR
# To copy the directory
/tmp$ cp -r DIRNAME/ OTHERDIR/
# To make duplicate directory with different name
/tmp$ cp -r DIRNAME/ NEW_DIR/
# To move directory
/tmp$ mv TARGET_DIR/ DEST_DIR/
# To rename directory
/tmp$ mv DIRNAME/ RENAMED_DIR/
# To remove/delete directory
/tmp$ rm -r DIRNAME
Enter fullscreen mode Exit fullscreen mode

Operation on file:

# To make file
/tmp$ touch FILE
# To copy the file
/tmp$ cp FILE DEST
# To make duplicate file with different name
/tmp$ cp FILE NEW_FILE
# To move file
/tmp$ mv TARGET_FILE DEST
# To rename file
/tmp$ mv FILE RENAMED_FILE
# To remove/delete file
/tmp$ rm FILE
Enter fullscreen mode Exit fullscreen mode

Common mistakes

  • Confusing relative and absolute paths
  • Deleting files without checking path
  • Deleting and copy directory without flag

Validation test

If you:

  • Can find current directory path.
  • Can list files of current directory.
  • Able to change directory.
  • Can use the tree command.
  • Know put stack for change directories.
  • Understand the distinction between absolute and relative paths.
  • Can operate on files and directories.
  • Know directories on the filesystem which follows DevOps methodologies.

Then this topic is DONE.


What’s next

Next, I’m learning Linux permissions & ownership, which causes most deployment failures.

Top comments (0)