Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of commands commonly used in linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "linux commonly used command summary", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "linux commonly used command summary" bar!

Basic commands:

Hostname: view the full name of the current host.

Hostname kgc means to modify the hostname of the current system to kgc, which will take effect after logging out and logging back in.

Pwd: the user displays the working directory where the current user is located

Ls: displays all files in the current directory

Ls-a: displays all files, including. Opening and hidden files

Lsb_release-an operating system version

Cat / proc/cupinfo query cpu information

Cat / proc/meminfo query memory information

Ls: list list displays directory contents

Ls-ld: displays only the detailed properties of the current directory, not the contents of the directory

Ls-lh: can be displayed in a longer format that is easier to read

Executing the alias myls ='is-alh' command defines a command alias named myls, and later executing myls is equivalent to executing the "ls-alh" command.

Du: statistics on the space consumption of directories and files (DiskUsage)

Du-sh / home/cjhbq_bqxt/etl_remote/: the size of the space occupied by the statistical directory

Du-ah / home/cjhbq_bqxt/etl_remote/: counts the amount of space occupied by all files and subdirectories under the directory.

Touch: creating an empty file

Touch text.txt

Mkdir: create a new directory

Mkdir public_html: create a pulic_html in the current directory

Mkdir-p / multi/movie/cart: create nested multi-tier directories at once.

Cp: copy a file or directory and rebuild a copy of the file or directory that needs to be loaded and save it as a new file or directory.

Cp [options] Source file or directory destination file or directory

-r: indicates that all files and subdirectories are copied recursively

Rm: delete file or directory command

-rf deletes directly without prompting.

Mv: move a file or directory, if moving between the same directory is equivalent to renaming

Which: find the file storage directory executed by the user

Which ls

Find: find a file or directory

Find / etc-name "resol*.conf"

View and retrieve documents

Cat command: display and connect the contents of a file

Cat file name

Cat / etc/redhat-release / proc/version can view the contents of multiple files, the former recording the system discovery version, the latter recording the system kernel and development environment, time and other information.

More command: view the contents of files on more than one screen, display them separately, and show the percentage in the lower left corner.

Press the Enter key to scroll down to view, press the space to flip down a screen, press b key to flip up a screen, press Q key to exit and return.

Less command: view more than one screen of file content, although the split screen display, but the lower left corner does not show the percentage but shows the file name, press Page Up page up, Page Down page down, press / key to find content, n to show the next content, N to show the previous content.

Head command: display the first part of the file, you can use the "- n" (n is the specific number of lines) option to determine the number of lines to be displayed, the default display of 10 lines.

Head-10 / etc/passwd

Tail command: used to view the contents at the end of the file. The tail command is generally used to query the system log. With-f, you can also track the dynamic updates of the tail content of the file in real time. Press ctrl+C to terminate.

Tail-f / log/message

Statistics and retrieval of file contents

Wc command: count the number of words (word count), lines and other information in the contents of the file

The wc command is used to count the number of lines, word books, bytes and other information contained in the file content. Using the file name as a parameter, you can count multiple files at the same time.

-c: count the number of bytes in the contents of the file

-l: count the number of lines in the file

-w: count the number of words in the contents of the file (separated by spaces or tab stops)

Wc / etc/hosts: use-c,-l and-w options by default without any options

Wc-l / etc/passwd: statistical user data

Find / etc-name "* .conf" | wc-l: the number of files that meet the criteria

Grep command: retrieving and filtering file contents

The grep command is used to find and display lines in a file that contain a specified string, and you can directly specify a key string as a query condition.

-I: case-insensitive when looking for content

-v: reverse lookup, that is, output rows that do not match the query criteria.

Grep "ftp" / etc/passwd: find the line that contains the ftp string.

Backup and restore documents

The most common compression command tools for Linux include gzip and bzip2, and the most commonly used archive command tool is tar

Gzip and gunzip commands: default extension ".gz"

Gzip mkfile: compression

Gzip-d mkfile.gz or gunzip mkfile.gz: decompress

Bzip and bunzip2 commands: extension ".bz2"

Tar command: used to archive directories and files.

Tar zcvf sysfile.tar.gz / etc / boot: back up the etc and boot directories and generate the archive package of sysfile.tar.gz under the current directory. You can see the list of archived files during execution.

Other additions:

List all hard disk devices and their partition information in the current system: fdisk-l

View disk usage: df-hT

2018-12-20 add:

Switch between multiple directories (pushd,popd)

Pushd: remember where you are now and go to this place

Popd: "pops" the directory you pushed last time from the list, and then asks you to go back to the pop-up directory

Thank you for your reading, the above is the content of the "summary of commonly used commands in linux". After the study of this article, I believe you have a deeper understanding of the summary of commands commonly used in linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report