Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Linux command in DevOps
Next article icon

Linux command in DevOps

Last Updated : 23 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

DevOps engineers use Linux every day because it’s free, fast, and easy to customize. More importantly, most DevOps tools like Docker, Kubernetes, Ansible, Terraform, and Jenkins are built to run best on Linux.

In DevOps, you often work on cloud servers (like AWS, Azure, or Google Cloud), and most of them run Linux by default. To manage these servers, engineers use Linux commands to move files, check logs, install software, run scripts, and fix problems. That’s why if you want to start a career in DevOps, learning Linux is one of the first and most important steps. It helps you work faster, solve problems easily, and use the tools that DevOps teams rely on every day.

In this article, we will first learn what Linux is, then understand its file system, and after that, we’ll go through some basic and important Linux commands that are useful in DevOps.

File System in Linux

In Linux, everything is represented as a file, including a hardware program. The files are stored in a directory, and every directory contains a file with a tree structure. That is called the file system hierarchy. Linux uses a single-rooted, inverted tree-like structure. The root directory is represented with / (forward slash). It is a top-level directory in Linux.

Basic command

In this section, we are going to discuss the basic commands of Linux:

1. pwd

The 'pwd' command helps you identify your current location in the file system :

   `pwd` - Print Working Directory     
Screenshot-2023-10-06-082949
pwd

2. ls

The 'ls' command is used to list the files and directories in the current directory :

  `ls` - List Files and Directories

Command

Description

ls <Path Name>

` any define path` is define after `ls` command, it will display all contain of that location.

ls -l

` -l ` flag is used to display the lists all contents with some extra information like permission of the file or folder , time stamp.

ls - a

` -a ` flag is used to see the hidden files and folder.

first-v2
List Files and Directories
v-4
Display hidden file


v-5
permission of all file

3. uname

The 'uname' command retrieves system information:

   uname - Print System Information
v-6
uname

Note : By adding `-r ` flag to the `uname` command , you can display the kernal release version.

uname -r   Print Kernel Release Information
33
uname -r

4. cd

The 'cd' command allows you to navigate the file system by changing your current directory.

cd  -  Change Directory
12223
Cd

5. clear

The 'clear' command clears the terminal screen, providing a clean workspace.

  clear - Clear the Terminal Screen
55
clear

6. whoami

'whoami' returns the username of the current user logged into the terminal.

 whoami - Display the Current User 
66
whoami

7. History

'History' This command is used to display the history of the common that previously executed. history

history
v-7
History

8. free

'free' This command is used to check the memory-related detail in your system.

 free
55
free

9. nslookup

'nslookup' is used to obtain information for DNS server. It stands for Name Server Lookup.

nslookup <domain name>
v10
nslookup

10. ssh-keygen

'ssh-keygen' is used to establish a secure SSH connection from your host machine to any remote server. It generates a public/private key pair.

ssh-keygen -t rsa

final

11. curl

'curl' is a tool which is used to fetch data and post the data over the internet. it can used various of protocol like HTTPS , SMTP and FTP.

curl [options] [URL]
1234
curl

12 . curl -o

'curl -o' flag saves the data into a file on the local machine.

`curl -o` [file_name] [URL...]
gh
store response on local machine

13. apt-get

apt-get command used to manage packages in the linux. APT stand for the Advanced Packaging Tool , and its main used of install , update , upgrade and remove the packages.

apt-get [options] command
rrr
apt

14. du

'du' command is used to check disk usage space.

du
ffgg
du

15. df

'df'the is a command used to check the available disk space in system.

df -h


du
df


15. ifconfig

ifconfig is command is used to view the information about your network interface

ifconfig [OPTIONS] [INTERFACE]
rrrr
ifconfig

16. ip

The command is a modern replacement of ifconfig command. It is used to view and manage network settings. You can check Ip addresses, configure network interfaces, view routing tables by this command.

ip [OPTIONS] OBJECT {COMMAND | help}
ip-addr-

Creating Files and Directories

In DevOps, creating and managing files and directories is a common task. Here are some essential commands :

For Creating Directories

1 . For creating a single directory:

 mkdir GFG                                   
ww
mkdir

2. For creating multiple directories:

 mkdir GFG1 GFG2 GFG3                                                 
ppp
mkdir gfg1 gfg2 gfg3

3. For creating directory paths (directories inside directories):

mkdir -p   /GFG/GFG1/GFG2
10
mkdir -p

4. For creating a series of numbered directories:

 mkdir gfg{1..3}             
gk
mkdir gfg{1..3}

For Creating Files

We can create file in linux by using various commands like vi, touch, echo, nano etc. The following table will explain the use case of each command:

CommandPurposeExampleNotes
touchCreates an empty filetouch file.txtCan create multiple files: touch a.txt b.txt
echoCreates a file with some contentecho "Hello" > hello.txtOverwrites if file already exists
catCreates and writes to a filecat > notes.txtType content, then press Ctrl + D to save
nanoOpens a terminal text editornano file.txtUser-friendly; press Ctrl + X to exit and save
vi or vimOpens a powerful terminal editorvi file.txtPress i to insert, Esc to exit, :wq to save

Copying and Pasting Files and Directories

The cp command is used for copying and pasting files or directories in Linux. Here are some commonly used options and examples:

1 . For copying a file with verbosity and force (overwrite if necessary):

cp -rvf  gfg1   gfg
123
cp -rvf


Removing Files and Directories

To delete files or directories in DevOps, you can use the rm command. Be cautious, as it permanently removes data. Here's an example:

For removing a directory and its contents:

rm -rvf  gfg

ff
rm

Renaming Files and Directories

The mv command is used to rename files or directories. For example, to rename a directory from "gfg" to "gfg-devops," you can use:

mv gfg  gfg-devops      


last
mv


User Management

User management in Linux is a crucial aspect of DevOps and system administration. Managing users and their permissions ensures that your systems are secure, organized, and meet the needs of your organization. Here's an overview of user management in Linux within a DevOps context:

1 . Creating a User

To create a new user in Linux, you can use the useradd command. For example:

sudo useradd  [usernam]
1
sudo useradd GEEKSFORGEEKS
2
GEEKSFORGEEKS user created

2. Setting a Password

After creating a user, set a password using the passwd command:

 sudo passwd [username]
3
setting password for GEEKSFORGEEKS user

3. Deleting a User

To delete a user, use the userdel command :

sudo userdel  [username]
7
deleting user GEEKSFORGEEKS

4. Switch to Another User

The su command allows you to switch to another user's account by providing the username as an argument. To exit from the user's account and return to your original session, you can simply type 'exit'.

su  [USER NAME]


4
Switch to user GEEKSFORGEEKS

5. Rename the User

To change the username from the current name (oldname) to the new name (newname), use the following command.

sudo usermod -l [newname] [oldname]
8
chnage the user name from GEEKSFORGEEKS to GFG

Group Management

A group is a collection of user accounts that is very use full to administrators for managing and applying permission to a number users.

Command

Description

sudo groupadd <groupname>

Making a new group

sudo groupdel <groupname>

delete the group

sudo usermod -g <groupname> <username>

Adding a user to a group

ss
create the new Group called GFG
rrrrr
Delete the Group called GFG


Process Management

A process management is the process of controlling and monitoring the process running on a Linux system.

1. ps

ps command displays currently running processes.

ps aux
ps-command


2. top

The top command is used for memory monitoring. It shows a real-time view of system processes.

top
top-command

3. Kill

The kill command is used to terminate a process using it's PID.

kill 1234
kill-command

Linux File System Permission

In linux , to increase the security of the file and directory. we need to used permission. There are total three type of file permission are Read , Write , Execute.

There are three type of file permission are as follow:

  • user ( u ) : Permissions used for the user of the file.
  • group( g ) : Permission used by the group member.
  • other (o) : Permission used by all other users.

For example, suppose a file has read permissions that are allowed for the user. In this case, the user can only read that file, while the group and others will not be able to read it.

1 . ls -ld

It is used to check the permission of directory

 ls -ld
permisiion
check the permission of directory

Permission

Access for a file

Access for a directory

Read (r)

display file contents and copy the file

view contents of directory

Write (w)

modify the file contents

modify the contents of a directory

Execute (x)

execute the file if it an executable permission

allow use of cd command to access the directory


hello
File Permission classes

Permission with numeric & symbol

Number

Permission Type

Symbol

0

No permission

---

1

Execute

--x

2

Write

-w-

3

Execute +Write

-wx

4

Read

r--

5

Read + Execute

r-x

6

Read +Write

rw-

7

Read + Write + Execute

rwx

2. chmod

This command is used to change the permission of file and directory.

chmod <permission of user , group , other> {filename }


ok
GFG file
okkk
Give execution permission

3. chown

It is used to change the owner of the file and directory.

chown [owner_name] [file name]
pk
current ownership is faizan


ff
ownership change to GFG user

4. cat

It is used to read and concatenate the text inside the files. with help of this command we can displays the content inside the file.

cat <flag> {filename}

Command

Description

cat -b

This flag adds number to the text line.

cat -E

This flag add $ at the end of each line.


he
Display the contain the file GFG

5. Grep (Global Regular Expression Print)

It filter searches a file for a particular pattern of characters , and displays all lines that contain the pattern.

grep <flag or search_word> {file name}

Command

Description

grep -i

Delivers results for case-insensitive strings.

grep -n

Retrieve the corresponding strings and their respective line numbers.

grep -v

Provides the output of lines that do not contain the search string.

PP
Search key word Hello from GFG.txt

6. Sort

It print the output of a file, either alphabetically, numerically or by other specified way.

sort filename
sort-filename


7. head

The head command is used to display the first few lines of one or more text files.

head -n 2 gfg
head-command

8. tail

The tail command is used to display the last few lines of one or more text files.

tail -n 3 gfg
tail-command

9. find

The find command is used to search files and directories based on different criteria such as name, size, type and modification date.

find [path] [expression]
find-command

Conclusion

In conclusion, this article has emphasized the vital role of Linux fundamentals in the toolkit of a DevOps professional. By providing insights into essential Linux commands and concepts, it equips individuals in the field to efficiently navigate file systems, manage users and groups, implement file permissions, and perform a variety of tasks critical for the success of DevOps operations, ultimately contributing to the security and functionality of their systems.


Next Article
Linux command in DevOps

F

faizanalam2030
Improve
Article Tags :
  • Linux-Unix
  • Geeks Premier League
  • Geeks Premier League 2023

Similar Reads

    Devops and Linux Tutorial
    DevOps combines software development (Dev) and operations (Ops) to speed up software delivery and enhance collaboration. It uses automation and streamlined processes to build, test, and deploy software more reliably and efficiently. Before starting with DevOps, learning Linux and Git is essential. L
    4 min read
    Automation Testing Vs. DevOps
    In the world of software development, two key concepts often come up: ##Automated Testing and DevOps. Both have significant contributions to the delivery of quality and on-time software projects. Thus, although they are related, they both work quite differently and entail different measures. In this
    5 min read
    The Role of Linux in Cloud Computing and DevOps
    Linux now cannot be underemphasized in the current and of the future era which includes the cloud computing and DevOps trend. It’s open source character, flexibility and the ability to scale account for the popularity of this cloud infrastructure tool by the organizations that intend to leverage it
    11 min read
    DevOps Engineer Jobs in Ahemdabad
    Ahmedabad, a burgeoning tech hub in India, is witnessing a surge in demand for DevOps engineers. These professionals play a crucial role in streamlining software development processes, ensuring seamless collaboration between development and operations teams, and enhancing the efficiency and reliabil
    7 min read
    Devops and Microservices
    DevOps and microservices have transformed how organizations develop and deploy software. DevOps fosters collaboration between development and operations teams, enhancing efficiency and innovation. Microservices architecture, on the other hand, enables modular development, allowing teams to build, de
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences