search
HomeOperation and MaintenanceLinux Operation and MaintenanceA complete list of commonly used Linux commands

Many common commands in Linux must be mastered. Here I will share with you some common basic commands that I learned when I was getting started with Linux. I hope it can help you.

A complete list of commonly used Linux commands

1. Instruction to display date: date

2. Instruction to display calendar: cal

3. Simple and easy calculation Device: bc

How can 10/100 become 0? This is because bc only outputs integers by default. If you want to output the number of decimal points, you must execute scale=number. That number is the number of decimal points, for example:

4. Several important hotkeys [ Tab], [ctrl]-c, [ctrl]-d

[Tab] button---has the function of "command completion" and "file completion"

[Ctrl] -c key---let the current program "stop"

[Ctrl]-d key---usually means: "End Of File, EOF or End OfInput" ; In addition, it can also be used to replace exit

5, man

to exit with q,

man -f man

6, and data synchronization writing Enter the disk: sync

Enter sync, the data that has not been updated in the memory will be written to the hard disk; therefore, this command is important before the system is shut down or restarted. ! Better to do it a few times!

7. Commonly used shutdown command: shutdown

In addition, it should be noted that the time parameter must be added to the command, otherwise shutdown will automatically jump to run-level 1 (that is, single-person maintenance Login status), this is nerve-wracking! Here are some examples of time parameters:

Restart, shutdown: reboot, halt,poweroff

8. Switch execution level: init

Linux has seven execution levels. :

--run level 0: Shutdown

--run level 3:Pure text mode

--run level 5:Contains graphical interface mode

--run level 6: Restart

Use the init command to switch between modes:

If you want to shut down, in addition to the above shutdown -h now In addition to poweroff, you can also use the following command to shut down:

9. Change the group to which the file belongs: chgrp

10. Change the file owner: chown

He can also directly modify the name of the group

11. Change the permissions of the file: chmod

There are two ways to set permissions, which can be used respectively. Use numbers or symbols to change permissions.

--Change file permissions for numeric type:

--Change file permissions for symbol type:

12. View version information, etc.

13. Change directory: cd

14. Display the current directory: pwd

15. Create a new directory: mkdir

is not recommended for common use -p option, because you are worried that if you make a typo, the directory name will become messy

16. Delete the "empty" directory: rmdir

17 , display of files and directories: ls

18, copy files or directories: cp

19, remove files or directories: rm

20, move files and directories, Or rename: mv

21. Get the file name and directory name of the path: basename, dirname

22. Display the file content starting from the first line: cat

23. Display starting from the last line: tac (it can be seen that tac is cat written backwards)

24. When displaying, output the line number: nl

25, page by page Display file content: more

26. Similar to more, but better than more, it can turn pages forward: less

27. Only read the first few lines: head

28. Read only the last few lines: tail

29. Read the file content in binary format: od

30. Modify the file time or create a new file: touch

31. File default permissions: umask

32. Configuration file hidden attributes: chattr

33. Display file hidden attributes: lsattr

34. Observe files Type: file

35. Search for [Execution Block]: which

36. Search for a specific file: whereis

37. Search for a specific file: locate

38. Search for specific files: find

39. Compress files and read compressed files: gzip, zcat

40. Compress files and read compressed files: bzip2, bzcat

41. What is the difference between compressing files and reading compressed files: tar

ps:IP.GZIP.TAR? How deep is the compression?

tar是打包,不是压缩,只是把一堆文件打成一个文件而已GZIP用在HTTP协议上是一种用来改进WEB应用程序性能的技术,将网页内容压缩后再传输。
zip就不用说了,主流的压缩格式。
zip最新的压缩算法还是很好的,建议还是用zip格式化,全平台通用。
tar没有怎样压缩,压缩率100%,主要是永远打包,
zip压缩率看文件类型,jpg就没怎么压缩率,但bmp很高
gzip一般比zip高
zip
zip -r myfile.zip ./*
将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件.
unzip
unzip -o -d /home/sunny myfile.zip
把myfile.zip文件解压到 /home/sunny/
-o:不提示的情况下覆盖文件;
-d:-d /home/sunny 指明将文件解压缩到/home/sunny目录下
zip 命令:
# zip test.zip test.txt
它会将 test.txt 文件压缩为 test.zip ,当然也可以指定压缩包的目录,例如 /root/test.zip
# unzip test.zip
它会默认将文件解压到当前目录,如果要解压到指定目录,可以加上 -d 选项
# unzip test.zip -d /root/

The above is the detailed content of A complete list of commonly used Linux commands. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
The 5 Core Components of the Linux Operating SystemThe 5 Core Components of the Linux Operating SystemMay 08, 2025 am 12:08 AM

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The 5 Essential Elements of Linux: ExplainedThe 5 Essential Elements of Linux: ExplainedMay 07, 2025 am 12:14 AM

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux Operations: Security and User ManagementLinux Operations: Security and User ManagementMay 06, 2025 am 12:04 AM

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

Linux Operations: File System, Processes, and MoreLinux Operations: File System, Processes, and MoreMay 05, 2025 am 12:16 AM

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Linux Operations: Shell Scripting and AutomationLinux Operations: Shell Scripting and AutomationMay 04, 2025 am 12:15 AM

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux Operations: Understanding the Core FunctionalityLinux Operations: Understanding the Core FunctionalityMay 03, 2025 am 12:09 AM

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

Linux: Entering and Exiting Maintenance ModeLinux: Entering and Exiting Maintenance ModeMay 02, 2025 am 12:01 AM

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

Understanding Linux: The Core Components DefinedUnderstanding Linux: The Core Components DefinedMay 01, 2025 am 12:19 AM

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

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 Article

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools