Basic Linux Commands for DevOps Engineers¶
Linux is the foundation of DevOps. Whether you are working on cloud servers, CI/CD pipelines, or Kubernetes nodes, these basic Linux commands are used daily.
This page covers basic navigation and file viewing commands that every DevOps engineer must know.
pwd – Print Working Directory¶
To check the current working directory.
[opc@new-k8s ~]$ pwd
/home/opc
NOTE: In Linux operating system, a folder is also called a directory.
ls – List Files and Directories¶
To show the files and folders in the current working directory in horizontal view.
[opc@new-k8s ~]$ ls
first-project hello.txt shellscript swapfile
ls -l – Long Listing Format¶
To show the files and folders in the current working directory in vertical view.
It also shows details of each file and folder such as permissions, owner, group, and size.
[opc@new-k8s ~]$ ls -l
total 3072004
drwxrwxr-x. 3 opc opc 65 May 18 12:50 first-project
-rw-rw-r--. 1 opc opc 14 Jun 18 03:53 hello.txt
drwxrwxr-x. 5 opc opc 70 May 13 12:56 shellscript
-rw-r--r--. 1 root root 3145728000 Jan 11 2022 swapfile
ls -la – List Including Hidden Files¶
To show normal files, folders, and also hidden files and folders in vertical view.
In Linux, hidden files or folders start with a dot (.).
Examples:
- .file_name → hidden file
- .folder_name → hidden folder
[opc@new-k8s ~]$ ls -la
total 3072060
drwxr-x---. 12 opc opc 4096 Jun 18 03:54 .
drwxr-xr-x. 4 root root 32 Apr 13 12:25 ..
-rw-------. 1 opc opc 18412 Jun 15 12:46 .bash_history
-rw-r--r--. 1 opc opc 18 Nov 22 2019 .bash_logout
-rw-r--r--. 1 opc opc 193 Nov 22 2019 .bash_profile
-rw-r--r--. 1 opc opc 232 Apr 15 13:02 .bashrc
drwxrwxr-x. 4 opc opc 30 Nov 26 2021 .cache
drwxrwxr-x. 4 opc opc 30 Nov 26 2021 .config
drwxrwxr-x. 4 opc opc 82 Jan 11 2022 .docker
drwxrwxr-x. 3 opc opc 65 May 18 12:50 first-project
-rw-rw-r--. 1 opc opc 57 May 18 12:42 .gitconfig
-rw-rw-r--. 1 opc opc 14 Jun 18 03:53 hello.txt
-rw-r--r--. 1 opc opc 172 Apr 2 2020 .kshrc
drwxr-xr-x. 3 opc docker 33 Jul 4 2021 .kube
drwxrwxr-x. 3 opc opc 24 May 7 03:40 .m2
drwxrw----. 3 opc opc 19 Jul 4 2021 .pki
drwxrwxr-x. 5 opc opc 70 May 13 12:56 shellscript
drwx------. 2 opc opc 80 May 26 2022 .ssh
-rw-r--r--. 1 root root 3145728000 Jan 11 2022 swapfile
drwxr-xr-x. 2 opc opc 24 May 8 12:30 .vim
-rw-------. 1 opc opc 9145 May 18 12:41 .viminfo
cd – Change Directory¶
To go to another folder.
cd folder_name
Example¶
[opc@new-k8s ~]$ cd first-project/
[opc@new-k8s first-project]$ pwd
/home/opc/first-project
[opc@new-k8s first-project]$ ll
total 12
-rw-rw-r--. 1 opc opc 31 May 18 12:50 2.txt
-rw-rw-r--. 1 opc opc 21 May 18 12:40 hello.txt
-rw-rw-r--. 1 opc opc 30 May 18 12:40 README.md
Relative Path¶
A relative path is given from the current directory.
Current directory:
/home/opc
cd first-project
Absolute Path¶
An absolute path is given from the root directory /.
cd /home/opc/first-project
cat – Print / Read File Content¶
Used to print or read the content of a file.
ubuntu@manikandan:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
Abbreviations¶
pwd → print working directory
cd → change directory
cat → concatenate
Commands Summary¶
pwd → Check current working directory
ls → List files and folders (horizontal view)
ls -l → List files and folders (vertical view)
ls -la → List including hidden files and folders
ll → Alias of ls -la
cd → Change directory
cat → Print file content
Other Common Linux Utility Commands¶
which¶
Find the location of a command.
which kubectl
man¶
View the manual page of a command.
man df
id¶
Display user and group information.
id
hostname¶
Check the system hostname.
hostname
Directory Navigation Shortcuts¶
cd ..→ Move one directory upcd ../..→ Move two directories upcd→ Go to home directorycd ~→ Go to home directory explicitlycd -→ Switch to previous directory
date – Check Date and Time¶
[opc@new-k8s test]$ date
Sat Apr 15 04:39:46 GMT 2023
To display the date in a specific format like YYYYMMDD:
[opc@new-k8s test]$ date +%Y%m%d
20230415
Practice Tasks¶
- Check the current folder name using
pwd - Check the files and folders present in the current directory using
ls - Check normal and hidden files in the current directory using
ls -la - Navigate to
/etc/ssland verify the path - List the files in the SSL directory using
ls -l - Navigate up one directory level
- Go to
/tmpand list all hidden files - Go to
/etcand verify the existence of theos-releasefile - Print the content of the
os-releasefile - Find the location of the
pwdbinary usingwhich - Check your current user identity using
id - Check the system hostname
- Print the current date, then print it in
YYYYMMDDformat
🧠 Quick Quiz — Basic Linux Commands¶
Which command will list all files, including hidden ones, in the current directory?
📝 Want More Practice?¶
To strengthen your understanding and prepare for interviews, try the full 20-question practice quiz based on this chapter:
👉 Start Linux Basic Commands Quiz (20 Questions)
📬 DevopsPilot Weekly — Learn DevOps, Cloud & Gen AI the simple way.
👉 Subscribe here