search
HomeComputer TutorialsComputer KnowledgeEight of the most commonly used Linux commands in DevOps

Eight of the most commonly used Linux commands in DevOps

Feb 19, 2024 pm 03:42 PM
Table of contentsOrderLinux operating systemcd

Eight of the most commonly used Linux commands in DevOps

DevOps engineers often rely on the Linux operating system. Proficiency in basic Linux commands is essential for efficient system management. This article will introduce the basic commands for using Linux in DevOps practice.

1 List files and directories: 'ls' command

You can use the ls command to list files and directories in the current working directory.

picture

As you can see, you can use the command ls to display all directories and files in the current directory.

To display detailed information about a file, use the -l option:

picture

When you use ls -l, you will see detailed information about each file and directory, such as permissions, owner, group, size, and modification date.

2 Change directory: cd command

The cd command is used to navigate between directories. To move to a specific directory, use:

cd /path/to/directory

To move up one level: cd ..

So, the cd command (short for "change directory") is a command line instruction that switches to a different directory in order to explore and interact with the files and subdirectories within that specific directory.

3 Reading files: less, more, tail and head commands

The less and more commands are used to view the contents of a file in Linux without having to fully open the file. They are used to view parts of a file one by one, making it easier for developers to read large files.

  • less: Files can be scrolled using the arrow keys and exited at any time.
  • more: Similar to less, it also only displays one screen of text. You can go to the next screen by pressing the space bar and exit when done.

These two commands are useful when you want to quickly check the contents of a file without reading the entire content at once.

You can try it yourself: get a file and enter: less filename or more filename

There are also two commands available for reading large files. The head command is used to view the beginning of the file, while the tail command displays the end of the file. These two commands are useful when working with large files and you only need to view the beginning or end. head and tail are just like reading the first or last page of a book without reading the whole book.

4 Create and edit files: touch and nano commands

The touch command only performs one task - you create an empty file. Nano, on the other hand, is more like a text editor. It not only creates files but also supports writing and editing file contents there. Thus, touch can provide an empty file, and nano further allows text to be added and modified in that file.

picture

nano editor

In the nano text editor, you can use commands to perform various tasks. To save changes, click Ctrl O, confirm the file name, and press Enter. Exiting nano is as simple as clicking Ctrl X and if there are unsaved changes, you will be prompted to save before leaving. Use the arrow keys to navigate in the editor. To cut, copy, and paste text, use commands such as Ctrl K, Alt ^, and Ctrl U. Finding text can be done with Ctrl W, while replacing text can be done with Ctrl \. If you need to go to a specific line, press Ctrl _ and enter the line number. These commands make nano a user-friendly text editor, allowing developers to perform basic operations easily.

5 Create directory

Use the mkdir command to create a directory: mkdir directory_name will create a directory named directory_name (the developer can choose any name)

6 Delete files and directories

Use the rm command to delete files. To delete a directory, the -r option is required:

rm filenamedelete file

rm -r directory_name delete directory (use rm -r with caution as it will recursively delete the directory and its contents.)

7 File and search commands

The file command determines the file type: file filename It will display the type of file.

find command searches files and directories: find /path/to/search -name “filename”

8 Search keywords/patterns with grep command

grep is a powerful tool that helps search for specific words or patterns in files. When a developer is looking for a specific keyword in a file, they simply type grep, followed by the keyword to search for and the file name. grep will display all lines in the file that contain the keyword you are looking for. It works like a text detective - it finds and highlights the required information in a file, making it a useful command for text exploration and analysis.

grep "keyword" filename

To search directories recursively:

grep -r "keyword" /path/to/search

The above is the detailed content of Eight of the most commonly used Linux commands in DevOps. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
How to Download Technic Launcher on Windows/Mac/Linux? - MiniToolHow to Download Technic Launcher on Windows/Mac/Linux? - MiniToolMay 03, 2025 am 12:50 AM

Technic Launcher will let you play your favorite mod packs instantly. Some players want to download it but don’t know how to do that. Don’t worry! This post from php.cn tells you how to download and install Technic Launcher.

Top 7 Workarounds for Apps Keep Crashing on Android - MiniToolTop 7 Workarounds for Apps Keep Crashing on Android - MiniToolMay 03, 2025 am 12:49 AM

Do you meet apps crashing when using your Android device for a long time? What do you do to address it? If this is happening to you and you have no idea about what to do, you can try the solutions below in this guide on php.cn Website to fix it.

Resolved! How to Fix the Windows Update Error 0X80073BC3? - MiniToolResolved! How to Fix the Windows Update Error 0X80073BC3? - MiniToolMay 03, 2025 am 12:48 AM

In the most cases, the error 0X80073BC3 refers to the issue happened on the Windows update process. That can stop the normal update-related service, hassling people a lot. So, how to get rid of the Windows update error 0X80073BC3? This post on php.cn

Top 5 Solutions to Valorant Error Code Val 7 Windows 10/11 - MiniToolTop 5 Solutions to Valorant Error Code Val 7 Windows 10/11 - MiniToolMay 03, 2025 am 12:47 AM

Like any other games, there are quite a few glitches and bugs in Valorant. Error code Val 7 is among them. In order to get rid of it, we try our best to come up with some workarounds for you in this post on php.cn Website and hope it can help you out

Top 4 Proven Ways to Ctrl F Not Working on Windows 10/11Top 4 Proven Ways to Ctrl F Not Working on Windows 10/11May 03, 2025 am 12:46 AM

Ctrl F make our life easier and it must be quite frustrating when Ctrl F not working Windows 10. In this guide on php.cn Website, we’ll provide you with some easy and efficient ways to get this convenient shortcut to work for you again.

Easy Ways to Remove an Administrator Account on Windows 10/11Easy Ways to Remove an Administrator Account on Windows 10/11May 03, 2025 am 12:45 AM

For some reason, you might want to remove the administrator account on your Windows 10 or Windows 11. You can do this in the Settings app or in Control Panel. php.cn Software will introduce these two easy ways in this post.

How to Enable and Use Office Sidebar in Microsoft Edge? - MiniToolHow to Enable and Use Office Sidebar in Microsoft Edge? - MiniToolMay 03, 2025 am 12:44 AM

To enhance the coordination between Microsoft Edge and other functional software, Microsoft Edge has issued a new feature – Office Sidebar – that provides more quick and easy channels to access your targets. This article on php.cn Website will tell y

Four Ways to Fix the Windows Update Error Code 0x800703edFour Ways to Fix the Windows Update Error Code 0x800703edMay 03, 2025 am 12:43 AM

Your Windows may go malfunction when you perform a Windows Update and that’s when you meet an error code. Since many people find the Windows update error code 0x800703ed, this article on php.cn Website will list some useful methods for you.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)