Table of Contents
2. Find the file location" >2. Find the file location
(1)locate
(2)find
3. Command line editing skills" >3. Command line editing skills
4. Check the pid of a process" >4. Check the pid of a process
5. Check the running status of certain processes" >5. Check the running status of certain processes
Home Computer Tutorials Computer Knowledge Take stock of some practical Linux tips

Take stock of some practical Linux tips

Mar 12, 2024 pm 01:49 PM
in l i

Take stock of some practical Linux tips

Linux is a powerful operating system with many useful commands and tips to help you use it more efficiently.

1. Check the file check value

During the file copying or transmission process, the file may be damaged or modified. In this case, the check value can be used for verification.

Usually, we need to use some interface programs provided by other teams in our work. Whenever the running results of these programs are not as expected, we will compare the md5 check values ​​of both parties to confirm the consistency of the data.

There are many ways to generate the check value of a file. Commonly used ones include md5sum check, crc check, sum check, etc.

The

commands are:

md5sum file_name
cksum file_name
sum 算法参数 file_name
Copy after login

For example:

Let’s take a test.txt file as an example:

  • md5sum verification
md5sum test.txt
Copy after login
  • crccheck
cksum test.txt
Copy after login
  • sum verification

There are two algorithms for sum verification, which we can configure through parameters:

-r: Indicates using the system v algorithm. -s: Indicates using the BSD algorithm.

When we do not configure it, the system v algorithm is used by default.

sum -r test.txt
sum -s test.txt
Copy after login

2. Find the file location

(1)locate

Everyone is usually accustomed to using find to find files, but I think sometimes locate is faster, so I usually use locate first.

locate is different from find: find searches on the hard disk, while locate only searches in the /var/lib/slocate database. The speed of locate is faster than find. It does not really search, but checks the database.

Some systems may not have locate and you need to install it yourself. For example, Ubuntu can be installed by entering the following command:

apt-get update
apt-get install mlocate
Copy after login

locateThe command to find files is very simple:

lcoate file_name
Copy after login

(2)find

The find command can search by name, type, owner, size, etc.

Basic syntax for searching files:

find path -option file_name
Copy after login

If you use the name to search for the stdio.h file:

find / -name stdio.h
Copy after login

3. Command line editing skills

We mistakenly entered some relatively long content into the terminal:

it@weijishu:~$ dsfdsfdddddddddddddddddddddddddddddddddddfsgadgdsgasdgsdhfdkshfkjdshflksdhfkldshfkj
Copy after login

How to delete it faster? Frantically pressing the backspace key certainly does the trick. But there is a faster way:

Enter the shortcut key ctrl u to delete all the content in front of the cursor. In addition, there are several practical and commonly used shortcut keys as follows:

  • ctrl k: Delete all content behind the cursor.
  • ctrl a: Move the cursor to the beginning.
  • ctrl e: Move the cursor to the end.

In addition, the command line also has many practical and uncommon shortcuts. Interested friends can learn them by themselves.

4. Check the pid of a process

Order:

pidof process_name
Copy after login

5. Check the running status of certain processes

The top command can check some information about the process, but there are too many processes running in the system, which is not conducive to us checking the running status of some processes

At this time we can check the running status of the specified process through the following command, for example:

To view the status of the kcalc process, command:

top -p `pidof kcalc`
Copy after login

This is much simpler.

Notice:

The "` sign" here is not a single quotation mark! ! !

This symbol is to the left of the exclamation point! key on the keyboard.

View multiple processes, such as:

top -p `pidof kcalc` -p `pidof test_x86`
Copy after login

In addition to the above tips, there are also practical tips such as the following. They are briefly listed here and will be introduced in detail later.

  • View command history: You can use the history command to view recently used commands, and you can also use pipes and grep commands to filter commands starting with a certain string.
  • File synchronization: Use the rsync command to synchronize files between local and remote. It is more powerful and flexible than the cp or scp command.
  • View the contents of the file: Use the less or tail command to view the contents of the file. less can page forward, and tail can view the last few lines of the file.
  • View processes: Use the ps command to view the currently running processes. You can use the grep command to filter out processes starting with a certain string.
  • Port forwarding: Use the ssh command to do port forwarding, mapping a port on the remote host to a local port.
  • Data backup: You can use the tar command to package a directory or file into a tar package, and then use the cpio or dd command to back up the tar package to another location.
  • System monitoring: Use the top or htop command to view the system's CPU, memory, network, etc. usage in real time.
  • Network test: Use the ping and traceroute commands to test network connectivity and routing paths.
  • Text processing: Use awk, sed, grep and other commands to process text data and perform data filtering, replacement, sorting and other operations.
  • The above is the detailed content of Take stock of some practical Linux tips. For more information, please follow other related articles on the PHP Chinese website!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    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

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    1 months ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    1 months ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    1 months ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Chat Commands and How to Use Them
    1 months ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    What is the best graphics card for i7 3770? What is the best graphics card for i7 3770? Dec 29, 2023 am 09:12 AM

    What graphics card is good for Core i73770? RTX3070 is a very powerful graphics card with excellent performance and advanced technology. Whether you're playing games, rendering graphics, or performing machine learning, the RTX3070 can handle it with ease. It uses NVIDIA's Ampere architecture, has 5888 CUDA cores and 8GB of GDDR6 memory, which can provide a smooth gaming experience and high-quality graphics effects. RTX3070 also supports ray tracing technology, which can present realistic light and shadow effects. All in all, the RTX3070 is a powerful and advanced graphics card suitable for those who pursue high performance and high quality. RTX3070 is an NVIDIA series graphics card. Powered by 2nd generation NVID

    Li Auto's L series welcomes new member: Li Auto L6 positioned as a medium-sized five-seat SUV Li Auto's L series welcomes new member: Li Auto L6 positioned as a medium-sized five-seat SUV Jul 02, 2023 pm 11:57 PM

    According to news on June 30, Li Auto’s L series models, including L7, L8 and L9, have achieved considerable sales results in their respective price ranges. However, according to the editor’s understanding, Li Auto hopes to further increase sales, and its focus is on the performance of another new car, the Li Li L6. Recently, a blogger allegedly photographed a camouflaged Ideal L6 car in a highway service area. According to the photos taken by the blogger, the camouflaged car suspected to be the Lili L6 is not driving normally, but is parked on a trailer. Compared with the white Weilai SUV next to it, even as the lowest-positioned model in the L series, the Lideal L6 appears to be quite large. It is reported that the Lili L6 is positioned as a medium-sized five-seat SUV. Although these photos don't provide much information about the appearance details

    Tips for using i18n to implement multi-language switching in Vue Tips for using i18n to implement multi-language switching in Vue Jun 25, 2023 am 09:33 AM

    With the continuous development of internationalization, more and more websites and applications need to support multi-language switching functions. As a popular front-end framework, Vue provides a plug-in called i18n that can help us achieve multi-language switching. This article will introduce common techniques for using i18n to implement multi-language switching in Vue. Step 1: Install the i18n plug-in First, we need to install the i18n plug-in using npm or yarn. Enter the following command at the command line: npminst

    What do out and in interfaces mean? What do out and in interfaces mean? Sep 28, 2021 pm 04:39 PM

    The out interface refers to the output interface, and the in interface refers to the input interface. The out interface generally represents the audio source line output interface, which is used to connect loads, such as speakers, headphones, etc.; while the in interface generally represents the audio source line input interface, which is used to connect CD players, mobile phones, MP3 players, computers, etc.

    Can the i7 generation be installed with win11? Can the i7 generation be installed with win11? Dec 30, 2023 pm 11:40 PM

    As we all know, there are device restrictions on the installation of win11, and restrictions such as uefi startup are set on the CPU. So can the earliest i7 generation install win11? In fact, it is theoretically possible, but installation is not recommended. Can the i7 generation be installed with win11: Answer: The i7 generation can be installed with win11, but if the configuration is too low, it will freeze, so it is not recommended to install win11. 1. Win11 limits the CPU mainly due to the need for uefi startup and tpm2.0 issues. 2. But this will only restrict us from getting update push in the system normally, and will not restrict the PE system. 3. So we only need to use a USB flash drive to download win11 and install win11 in pe. 4. However, when running win11,

    Intel's latest processor i9-14900K stands out in the Geekbench test, leading the new generation in performance! Intel's latest processor i9-14900K stands out in the Geekbench test, leading the new generation in performance! Sep 22, 2023 pm 03:41 PM

    According to news on September 6, Intel will launch a new generation of Raptor Lake Refresh processor series this month. The latest news shows that the flagship model of this series, the Core i9-14900K, performed brilliantly in the Geekbench6.1.0 single-core test, achieving a score of 3121. Compared with the previous generation of 13900K, this result has increased by about 6%. In terms of multi-core performance, although it is slightly inferior to the previous generation, it also shows strong computing potential. According to the editor's understanding, the performance of the Core i9-14900K processor benefits from its innovative design. The processor uses 8 P cores and 16 E cores, taking full advantage of the multi-core architecture. It is particularly worth mentioning that this processor also introduces Th

    What is the difference between on, in, as, and where in Mysql? What is the difference between on, in, as, and where in Mysql? Jun 03, 2023 am 11:37 AM

    The difference between Mysqlon, in, as, and where Answer: Where query conditions, use on for internal and external connections, as as an alias, in to query whether a certain value creates 2 tables in a certain condition: student, scorestudent: score: whereSELECT*FROMstudentWHEREs_sex=' Male'For example: onSELECT*FROMstudentLEFTJOINscoreonstudent.s_id=score.s_id; combination of on and where: SELECT*FROMstudentLEFTJOINs

    Is it better to install win7 or win10 system on i5? Details Is it better to install win7 or win10 system on i5? Details Dec 23, 2023 pm 12:43 PM

    If the processor of our computer is an i5 processor, and we want to reinstall the system of the computer, the editor thinks that we should make relevant considerations based on the hardware configuration requirements of the system. Is it better to install win7 or win10 system on i5? . Only the one that suits you in terms of hardware configuration and personal needs is the best. Let’s take a look at what the editor said for details~ I hope it can help you. Is it better to install win7 or win10 system on i5? Answer: It is better to install win10 system on i5 processor now. 1. As far as win7 and win10 systems are currently used by the most users, in fact, the configuration requirements of the two systems are similar. 2. Therefore, in terms of performance, fluency, and applicability, the win10 system is better than win7

    See all articles