Linux commands for DevOps
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:
pwd
- Print Working Directory: Displays the current directory.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.
sudo
: Execute commands with superuser privileges.cd
- Change Directory: Changes the current directory to the specified location.mkdir
- Make Directory: Creates a new directory.rm
- Remove: Remove files or directories.rm -r: to remove the directory along with the child directories.
rmdir: to remove normal(empty) directory.
cp
- Copy: Copy files or directories.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:
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.
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:
find
- Used to search for files and directories. It lets you locate files by their names, types, sizes, modification times, and other attributes.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:
chmod
- Change Access Permissions Changes the permissions of a file or directory.chown
- Change File Owner or Grouptail
- 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.
head
- Display the number of lines from the head.ps
- Check the Unique ID Behind Every Process.kill
- Terminate Processes Manually.kill -9
: Forcefully terminate a process.kill -15
: Gracefully terminate a process.
5. Network Commands:
ping
- Check Host Responsiveness.ifconfig
- Configure Network Interfaces.nslookup
- Name Server Lookup.curl
- Transfer Data Between ServersLinux 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
Subscribe to my newsletter
Read articles from abha kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by