Linux commands for DevOps (Commands used in day-to-day activities).

Linux commands for DevOps (Commands used in day-to-day activities).

Mostly Used Commands in DevOps:

  1. Ls: This command is used to list the contents of a directory.

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

No alt text provided for this image


2. Sudo: This command executes only that command with superuser privileges.

No alt text provided for this image


3. Pwd: This command will print your directory location, where you currently working.

No alt text provided for this image


4. Cat: This is used to concatenate and display files on the terminal. It can also be used to modify existing ones.

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

No alt text provided for this image


5. Vim: This is a text editor used in Linux. It stands for “Vi Improved”.

No alt text provided for this image

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.


6. Grep: This command searches for a particular string/ word in a text file. This is similar to “Ctrl+F” but executed via a CLI.

No alt text provided for this image

This would print all of the lines in “chxtan.txt” that contain the word “This".


7. Sort: This command is used to sort the results of search either alphabetically or numerically. It also sorts files and directories.

No alt text provided for this image

sort -r: the flag returns the results in reverse order.

sort -f: the flag does case-insensitive sorting.

sort -n: the flag returns the results as per numerical order.


8. Tail: This command prints the last N number of data of the given input. By default, it prints 10 lines.

We can specify the number of lines, that we want to display.

No alt text provided for this image


9. Chmod: This command is used to change the access permissions of files and directories.

For example: Following “chmod” command will give the user permission to read, write and execute a file.

No alt text provided for this image


10. Chown: This command is used to change the file Owner or group.

Here, below the ownership of “Chetan.txt” file got changed to root.

No alt text provided for this image


11. Ping –?This command will ping a host and check if it is responding.

No alt text provided for this image


12. Lsof: It is used to display a list of all the open files on a Linux system.

No alt text provided for this image


13. Ifconfig: This is used to configure the kernel-resident network interfaces.

No alt text provided for this image


14.?ID: This is used to find out user and group names and numeric ID’s (UID or group ID) of the current user or any other user in the server.

Syntax: id <option> <user_name>

No alt text provided for this image


15. Cut: This command is used to extract specific fields or columns from a file or standard input.

It is often combined with other commands, such as sort, uniq, and grep, to perform more complex text-processing tasks.

No alt text provided for this image


16. Sed: This is used to perform basic text transformations on an input file. It stands for "stream editor" and is a powerful tool for editing text files or streams in a Linux environment.

No alt text provided for this image


17. Diff: This command is used to find the difference between two files.

No alt text provided for this image

18. History: This command is used to view the previously executed command.

No alt text provided for this image


“History 10” – Will give you the last 10 executed commands.

No alt text provided for this image

?

19. Find: This is used to find files and directories and perform subsequent operations on them.?

In the below command, It will search in the present working directory and its subdirectories, and print the name of the file that have “.txt” file extension.

No alt text provided for this image

?

20. Free: This command displays the total amount of free space available along with the amount of memory used and swap memory in the system, and also the buffers used by the kernel.

No alt text provided for this image

?

21. ssh user@host –?connect to the host as a user.

22. Ssh-keygen: This command is used to generate a public/private authentication key pair.

This process of authentication allows the user to connect remote server without providing a password.

(This authentication method we will use to authenticate the server with Jenkins while deploying CI/CD pipelines).

No alt text provided for this image

?

23. Nslookup: This stands for “Name server Lookup”. This is a tool for checking DNS hostname to Ip or Ip to Hostname. This is very helpful while troubleshooting.

No alt text provided for this image


24. Curl: Curl is a tool used for transferring data to or from a server, using various protocols, such as HTTP, HTTPS, FTP, and more. Basic example:

Syntax: curl <url>

No alt text provided for this image

?-o: It will save downloaded file on the local machine with the name provided in parameters.

No alt text provided for this image


25. Tr: Tr stands for translation. This command is for translating or deleting characters.?

No alt text provided for this image

?

26. Apt-get: This command is used to install, update, and remove packages, as well as to manage the package repository sources.

Here are some common apt-get commands:

  • apt-get update: This updates the package index files from the package repositories listed in the /etc/apt/sources.list file. This is usually the first command you should run after adding a new repository or package to your system.
  • apt-get upgrade: This installs newer versions of packages that are already installed on the system. It will also remove any packages that are no longer required.
  • apt-get install: This installs one or more packages. For example, to install the nano text editor, you would run apt-get install nano.
  • apt-get remove: This removes one or more packages, but it does not remove the configuration files for the package.
  • apt-get purge: This removes one or more packages and their configuration files.
  • apt-get autoremove: This removes packages that were installed as dependencies but are no longer needed.

?

27. Df, du:

Df (disk free) command will have an account of available disk space, used by file system.

Du (disk usage) command reports the size of directory tree including all the content.

No alt text provided for this image
No alt text provided for this image

??

28. Htop: This command is used to monitor the system’s resources and processes that are running in real time.

No alt text provided for this image

?

29. Ps: We use ps command to check the unique id behind every process.

  • a?= show processes for all users
  • u?= display the process’s user/owner
  • x?= also show processes not attached to a terminal

No alt text provided for this image

?

30. Kill: This command is used to terminate processes manually. This command basically, will send a signal that terminates it.

No alt text provided for this image

?

31. TNC: This is “Test Network Connection” command. Mostly used command while troubleshooting. It displays diagnostic information for a connection.

?

Command: tnc <server_name> -port <port>

Really Helpful!

回复
Sidharth Shukla

Cloud & Server Administrator | AWS | Azure | GCP | DevOps Enthusiast

1 年

awsesome

回复
Jyotirmayee Parida

AI/ML Engineer | AWS Certified Machine Learning – Associate | AI/ML & Cloud Automation Enthusiast | Specializing in Generative AI & Scalable ML Pipelines on AWS

1 年

really useful Chetan R ?? , thanks for sharing.

Maaz Mohd

Aspiring DevOps Engineer || Seeking Entry-Level Position || Experience With Linux | AWS | Git | Jenkins | apache | Docker | Kubernetes | Terraform | Ansible | Chef |

2 年

ls -a Using ‘a’ flag, lists all the hidden contents in the specified directory

要查看或添加评论,请登录

Chetan R的更多文章

  • Interview Question Series - 7 (Monitoring)

    Interview Question Series - 7 (Monitoring)

    Here are the top frequently asked interview questions for Monitoring: 1. What is monitoring in DevOps, and why is it…

    5 条评论
  • Interview Question Series - 6 (AWS)

    Interview Question Series - 6 (AWS)

    1. What is AWS and how is it different from traditional data centers? AWS is a cloud computing platform that offers a…

    3 条评论
  • DevOps Project - 15 (Step-by-step Implementation)

    DevOps Project - 15 (Step-by-step Implementation)

    DevOps Project - 14: Deploy DOTNET web app using Azure PAAS service, use Terraform to deploy infrastructure, and…

    4 条评论
  • Interview Question Series - 5 (CI/CD)

    Interview Question Series - 5 (CI/CD)

    Interview Question Series - 5 (CI/CD) 1. What is CI/CD? >> CI/CD stands for Continuous Integration/Continuous…

    20 条评论
  • DevOps Project - 14 (Step-by-step Implementation)

    DevOps Project - 14 (Step-by-step Implementation)

    DevOps Project - 14: 3 Tier Application Deployment using Kubernetes EKS Cluster. 1.

    36 条评论
  • DevOps Project - 13 (Step-by-step Implementation)

    DevOps Project - 13 (Step-by-step Implementation)

    The very first step is to Install Terraform in your machine, by visiting the official site of Terraform. Here you need…

    14 条评论
  • Interview Question Series - 4 (GIT)

    Interview Question Series - 4 (GIT)

    1. What is Git, and how does it differ from other version control systems? Answer: Git is a distributed version control…

    13 条评论
  • Interview Question Series - 3 (Kubernetes)

    Interview Question Series - 3 (Kubernetes)

    1. What is Kubernetes, and why is it important for container orchestration? Answer: Kubernetes is an open-source…

    10 条评论
  • Interview Question Series - 2 (Docker)

    Interview Question Series - 2 (Docker)

    1. What is Docker? Docker is an open-source platform that allows you to automate the deployment, scaling, and…

    17 条评论
  • DevOps Project - 12 (Step-by-step Implementation)

    DevOps Project - 12 (Step-by-step Implementation)

    Project 10: Build a website using AWS CodeCommit and AWS CodeBuild. Here is the Architecture: 1.

    24 条评论

社区洞察

其他会员也浏览了