12. Linux Commands Cheat sheet
DevOps is a field that demands efficiency and precision in managing systems and infrastructure. To streamline various tasks and operations, DevOps professionals rely on a set of essential command-line tools. In this article, we will explore some of the most commonly used commands in DevOps, each serving a specific purpose to ensure the smooth operation of systems and services.
1. ls - List Contents of a Directory
The ls command is used to list the contents of a directory. By default, it displays the names of files and directories within the specified location. When used with the -l option, it provides additional information such as permissions, owner, size, and last modified date for each file.
2. sudo - Execute with Superuser Privileges
The sudo command is used to execute a specific command with superuser privileges. This allows a user to perform actions that require administrative access. It's a crucial command for making system-level changes.
3. pwd - Print Working Directory
The pwd command prints the current working directory, showing you the path of the directory you are currently in. This is helpful for maintaining awareness of your location in the filesystem.
4. cat - Concatenate and Display Files
The cat command is used to display the content of files on the terminal. It can also be used to concatenate multiple files. Various options like -b, -n, -s, and -E allow you to manipulate the output, including line numbering and displaying the end of lines.
5. Vim - Text Editor with Multiple Modes
Vim, short for "Vi Improved," is a powerful text editor used in Linux. It operates in three primary modes:
Normal mode: For navigating and editing text.
Insert mode: For entering and editing text.
Command mode: For issuing commands to save or quit the editor.
6. grep - Search for Strings in Text
The grep command is used to search for specific strings or words within text files. It functions similarly to a "Find" operation, allowing you to locate and display lines containing the specified text.
7. sort - Sort Results and Files
The sort command arranges data either alphabetically or numerically. Flags like -r, -f, and -n allow you to customize the sorting process, including reverse order and case-insensitive sorting.
8. tail - Display the End of a File
The tail command is used to display the last few lines of a file. By default, it shows the last ten lines, but you can specify the number of lines to display.
9. chmod - Change Access Permissions
The chmod command is crucial for changing the access permissions of files and directories, allowing you to specify who can read, write, or execute them.
10. chown - Change File Owner or Group
The chown command is used to change the ownership of a file or directory. This is essential for managing permissions and access control.
11. ping - Check Host Response
The ping command is used to check if a host is responding by sending network packets to it. It's a fundamental tool for network troubleshooting.
12. lsof - List Open Files
lsof stands for "list open files" and is used to display all files currently open on a Linux system. This is helpful for identifying which processes are using specific files.
13. ifconfig - Configure Network Interfaces
The ifconfig command is used to configure network interfaces on a Linux system. It allows you to view and modify network settings.
14. id - Find User and Group Information
The id command is used to retrieve information about users and groups, including their numeric IDs (UID or GID). It's valuable for understanding user and group associations.
15. cut - Extract Fields from Text
The cut command is used to extract specific fields or columns from a file or standard input. It is often combined with other commands for more complex text processing tasks.
16. sed - Stream Editor
sed, or "stream editor," is a powerful tool for performing text transformations on input files. It's particularly useful for batch text editing.
17. diff - Find Differences Between Files
The diff command is used to find differences between two text files. It highlights changes, making it valuable for code and configuration comparisons.
18. history - View Command History
The history command allows you to view a list of previously executed commands, making it easier to recall and reuse past commands.
19. find - Search for Files and Directories
The find command is used to search for files and directories based on specific criteria. It's invaluable for locating and managing files on a system.
20. free - Display System Memory Information
The free command provides information about system memory usage, including the amount of free and used memory, swap memory, and kernel buffers.
21. ssh - Secure Shell
The ssh command is used to connect to remote hosts securely. It allows users to log in to a remote system and execute commands remotely.
22. ssh-keygen - Generate SSH Key Pairs
ssh-keygen is used to generate public and private key pairs for secure authentication, enabling passwordless remote connections.
23. nslookup - DNS Lookup Tool
nslookup, short for "Name Server Lookup," is a tool used to check DNS hostnames and IP addresses. It's essential for troubleshooting network-related issues.
24. curl - Transfer Data Using Various Protocols
curl is a versatile tool for transferring data to or from a server using various protocols, including HTTP, HTTPS, and FTP. It's commonly used for automating web-related tasks.
25. tr - Translate or Delete Characters
The tr command, short for "translation," is used to translate or delete characters in a text stream. It's a handy tool for text manipulation.
26. apt-get - Package Management in Debian-Based Systems
The apt-get command is used to manage packages on Debian-based Linux systems. It allows you to install, update, and remove packages and repositories.
27. df and du - Disk Space and Usage
The df command displays available disk space and usage information, while the du command reports the size of directory trees and their contents.
28. htop - Real-Time System Resource Monitoring
htop is a real-time system resource monitoring tool that provides an interactive view of processes, system load, and resource utilization.
29. ps - Display Process Information
The ps command is used to display information about running processes. Various options allow you to customize the output to your needs.
30. kill - Terminate Processes
The kill command is used to terminate processes manually by sending a specific signal to them.
31. tnc - Test Network Connection
The tnc command, or "Test Network Connection," is a valuable tool for diagnosing network connectivity issues by providing diagnostic information for a connection.
Thank you for reading this article...
Subscribe to my newsletter
Read articles from Sunil Prasad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sunil Prasad
Sunil Prasad
Aspiring Devops Engineer who have proficient knowledge AWS || LINUX || GIT || GITHUB || ANSIBLE || DOCKER || TERRAFORM || JENKINS || KUBERNETES || PROMETHEUS || GRAFANA || UBUNTU/REDHAT || PYTHON ||