Linux commands for DevOps

abha kambleabha kamble
3 min read

Linux, the go-to operating system for DevOps enthusiasts, offers a command-line interface packed with powerful tools. These commands are your trusty companions, simplifying tasks and boosting productivity.

1. File System Navigation and Inspection:

  1. pwd - Print Working Directory: Displays the current directory.

  2. ls - List Files and Directories: Lists the files and directories in the current directory.

    If you run ls -l, it will show the permissions, owner, size, and last modified date for each file in the directory.

  3. sudo: Execute commands with superuser privileges.

  4. cd - Change Directory: Changes the current directory to the specified location.

  5. mkdir - Make Directory: Creates a new directory.

  6. rm - Remove: Remove files or directories.

    rm -r: to remove the directory along with the child directories.

    rmdir: to remove normal(empty) directory.

  7. cp - Copy: Copy files or directories.

  8. mv - Move or Rename: Move or rename files and directories.

    mv is also used to rename files or directories, for example below:

2. Text Processing:

  1. cat - Concatenate and Display Files.

    cat -b: This adds line numbers to non-blank lines.

    cat -n: This adds line numbers to all lines.

    cat -s: This squeezes blank lines into one line.

    cat โ€“E: This shows $ at the end of the line.

  2. vim - Text Editor with Various Modes.

    Mostly used modes in VIM:

    • Normal mode: This is the default mode in which vim starts. In normal mode, you can use various commands to navigate and edit the text.

    • Insert mode: In insert mode, you can type text into the file. To enter insert mode, press the "i" key. To exit insert mode and return to normal mode, press the "Esc" key.

    • Command mode: In command mode, you can enter commands to perform various actions, such as saving the file or quitting vim. To enter command mode, press the ":" key.

3. String Search and Manipulation:

  1. find- Used to search for files and directories. It lets you locate files by their names, types, sizes, modification times, and other attributes.

  2. grep- Search for Strings in Text Files.

    grep root /etc/passwd (to find root in file passwd)

    grep -i root /etc/passwd (case insensitive)

    grep -i file * (searches file case sensitively all over)

    grep -iR file * (case insensitive recursively searched file all over)

4. Process Management and Access Permissions:

  1. chmod - Change Access Permissions Changes the permissions of a file or directory.

  2. chown- Change File Owner or Group

  3. tail - Print the last N lines of the given input.

    By default, it prints 10 lines. We can specify the number of lines, that we want to display.

  4. head - Display the number of lines from the head.

  5. ps - Check the Unique ID Behind Every Process.

  6. kill - Terminate Processes Manually.

    • kill -9: Forcefully terminate a process.

    • kill -15: Gracefully terminate a process.

5. Network Commands:

  1. ping - Check Host Responsiveness.

  2. ifconfig - Configure Network Interfaces.

  3. nslookup - Name Server Lookup.

  4. curl - Transfer Data Between Servers

    Linux commands are the building blocks of DevOps efficiency. By mastering these essentials, you empower yourself to navigate, manipulate, and optimize your system seamlessly. Dive into the Linux command-line universe and elevate your DevOps game! ๐Ÿš€ #DevOps #LinuxCommands

0
Subscribe to my newsletter

Read articles from abha kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

abha kamble
abha kamble