search
HomeOperation and MaintenanceLinux Operation and MaintenanceProgrammers must master 59 commonly used Linux commands

The content of this article is about 58 commonly used commands in Linux. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

  1. Quick start terminal: ctr alt t

  2. Enlarge terminal font: ctr shift ' '

  3. Terminal font reduction: ctr '-'

  4. ls: View the file information of the current directory

  5. pwd: View the path of the current directory

  6. touch: Create file

  7. mkdir: Create folder

  8. rmdir: Delete empty folder

  9. rm: Files are deleted by default. -r means to recursively delete all file information in the folder and finally delete the folder

  10. cd Switch directory 10.1 cd directory name: Switch to the specified directory 10.2 cd ..: Switch to the upper level directory 10.3 cd .: Switch to the current directory 10.4 cd ~: Switch to the user's working directory 10.5 cd -=> cd ~ : Switch to the user's working directory 10.6 cd -: Switch to the last directory

  11. clear :Clear screen->window : cls

  12. Absolute path: The path starting from the root directory is called an absolute path -> cd /home/python

  13. Relative path: The path starting from the current directory is called a relative path -> cd ../test cd ./test

  14. Summary on the use of absolute paths and relative paths: If the directory being switched is close to the root directory, use the absolute path. If the directory being switched is close to the current directory, use the relative path. , if the directory being switched is not close to the current directory and the root directory, use the absolute path

  15. cp: copy 15.1 cp file name path: copy the file to the specified directory 15.2 cp file name Path/new file name: Copy the file to the specified path and then modify it to the new file name 15.3 cp file name new file name: Copy the file to the current directory and modify it to the new file name 15.3 cp Folder path -r : Copy the folder to the specified path -r: Copy all the files in the folder recursively

  16. mv: Move (cut) 16.1 mv file name path : Move the file to the specified directory 16.2 mv file name path/new file name: Move the file to the specified path and modify it to the new file name 16.3 mv file name new file name: Rename the 16.4 mv folder path: Move the folder to the specified path

  17. tree: View directory information in the form of a directory tree 17.1 tree path: View directory tree information in the specified path

  18. cal: View the current month calendar 18.1 cal -y: View the full year calendar information

  19. date: View the current time 19.1 Time format: date " %Y-%m-%d %H:%M:%S": Year, month, day and ten seconds

  20. history: View historical command 20.1! Historical command number: Execute the corresponding historical command

  21. Command format: 21.1 Command name options parameters, prompt options can sometimes be placed after the parameters, but if an error is reported, you can consider placing them after the command, such as: scp -r 21.2 Options: For example: -r, The options may have 0 or more 21.3 Parameters: file name or path, the parameters may have 0 or more

  22. Command name --help: View help information

  23. man Command name: View help information 23.1 f Space: View next page 23.2 b: View previous page 23.3 Enter: View next line 23.4 q: Exit

  24. rm: Option 24.1 -i: Reminder before deletion 24.2 -r: Recursively delete all file information in the folder 24.3 -f: If the file does not exist, no error message is displayed when deleting 24.4 -v: Display deletion description information 24.5 -d: Delete empty directory

  25. ls option 25.1 -l: Display in list form 25.2 -a: Display hidden files 25.3 - h: Display file size unit

  26. ##ll -> ls -al

  27. l -> ls

  28. mkdir options: 28.1 -p: Create the required folders in advance

  29. cp options 29.1 -i: Display reminder 29.2 -r: Recursively Copy the folder 29.3 -f: Direct overwrite 29.4 -v: Display the copied path description

  30. mv options: 30.1 -i: Display reminder 30.2 -f: Direct overwrite 30.3 -v: Display the moved path description

  31. Redirection (>,>>): Rewrite the specified display direction, save the data displayed on the terminal to a file, and view the data later View through files 31.1 >: If the file exists, the original data will be cleared first and then new data will be written, which is equivalent to file operation: w 31.2 >>: If the file exists, then it will be performed based on the original data. Append writing data is equivalent to file operation: a Summary: ls, tree, cat collection redirection uses

  32. gedit: command of text editing tool, readable and writable

  33. cat: View the data in the file in the terminal, read-only

  34. more: Split screen display 34.1 f (space): See the next page 34.2 b: Look at the previous page 34.3 Enter: Look at the next line 34.4 q: Exit

  35. | Pipeline: Can be understood as a container for data 35.1 Note: You cannot look at the previous page when using the pipe in combination with more Page: b shortcut key does not work 35.2 ls, tree cat can be used in combination with pipes

  36. File merging 36.1 cat 1.txt 2.txt > 3.txt

  37. Link: Soft link: Just like a shortcut, note: deleting the original file soft link is invalid, creating a soft link will not increase the number of hard links by 1, you can create a soft link in a directory. Very important note Point: If the soft link is not in the same directory as the original file, then the original file needs to use the absolute path of the soft link: ln -s 1.txt 1-s.txt, ln -s /home/python/Desktop/AAA /1.txt ../1-s.txt By default, search

  38. in the current directory

    Hard link: Just like a person can have multiple names, deleting the original file will not affect the hard link file. File data can still be obtained using hard link files. Note: Hard links cannot be created for directories. Creating a hard link can only be created for files. Creating a hard link will increase the number of hard links by 1. Use of hard links: ln 1.txt 1-h.txt

  39. grep: Find data based on search content 38.1 -n: Display line number 38.2 -v: Negate based on search content 38.3 -i: Ignore case

  40. find: Search for files based on the specified path 39.1 -name: Search based on the file name 39.2 -size: Search based on the file size, please note that it is not accurate and generally not used 39.3 -perm: Search based on permissions r:4 w:2 x:1 find . -name "*.txt" -> Search for files with .txt suffix. Wildcard: plays the role of fuzzy query, * means matching 0 or more characters, ?: can only match any character, Tip: Wildcards have nothing to do with regular expressions

  41. ls. Use it in combination with wildcards. For example: ls *.txt

  42. ##tar to package 41.1 tar -cvf test .tar *.txt -> test.tar package, please note that the space will not become smaller because it is not compressed

  43. gzip compression 42.1 gzip test.tar -> test.tar.gz Compressed package, the space will become smaller

  44. tar packaging and compression (must master) 43.1 tar -zcvf test.tar.gz *.txt -> test.tar.gz compressed package 43.2 -z: Compression -c: Packaging -v: Display the packaged file f: Specify the file name

  45. gzip Decompress 44.1 gzip -d test.tar.gz -> test.tar package

  46. tar Unpack 45.1 tar -xvf test.tar -> Files in the package 45.2 -x: Unpack

  47. tar Unpack and unpacking (must master) 46.1 tar -zxvf test.tar.gz -> Decompress and unpack the file 46.2 tar -zxvf test.tar.gz -C path -> Decompress and unpack the compressed package to the specified path

  48. bz2 Pack and compress -jcvf test.bz2 *.txt -> test.bz2

  49. bz2 Unzip and unpack 48.1 tar -jxvf test.bz2 -> Get the file 48.2 in the compressed package tar -jxvf test.bz2 -C path -> Decompress and unpack the compressed file to the specified path

  50. zip packaging and compression 49.1 zip test[.zip optional] *.txt -> test.zip

  51. unzip decompression and unpacking 50.1 unzip test.zip -> get the solution Compressed and unpacked files 50.2 unzip test.zip -d path -> Decompress and unpack to the specified path 50.3 Summary: zip compressed packages take up the largest space, and generally use .gz and bz2

  52. chmod: Modify file permissions 51.1 User role: u: Current user g: User in the same group o: Other users a: All users 51.2 Permissions: r(4): Readable w(2): Writable x( 1): Executable - (0): No permission 51.3 chmod a=rwx 1.txt, chmod a=- 1.txt, chmod a= 1.txt, chmod 777 1.txt chmod 000 1.txt 51.4 Different users are different Permissions: chmod u=r,g=w,r=rwx 1.txt, chmod 427 1.txt

  53. cp option-a: retain file permissions, mainly for other users Permissions, Tip: -a contains the -r option, you can also copy the folder

  54. which: Get the path of the command

  55. sudo -s: Switch to the administrator user

  56. whoami: current user

  57. who: those users currently logged in

  58. passwd:Change password

  59. exit:Exit account

The above is the detailed content of Programmers must master 59 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
Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Understanding Linux's Maintenance Mode: The EssentialsUnderstanding Linux's Maintenance Mode: The EssentialsApr 14, 2025 am 12:04 AM

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

How Debian improves Hadoop data processing speedHow Debian improves Hadoop data processing speedApr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

How to learn Debian syslogHow to learn Debian syslogApr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

How to choose Hadoop version in DebianHow to choose Hadoop version in DebianApr 13, 2025 am 11:48 AM

When choosing a Hadoop version suitable for Debian system, the following key factors need to be considered: 1. Stability and long-term support: For users who pursue stability and security, it is recommended to choose a Debian stable version, such as Debian11 (Bullseye). This version has been fully tested and has a support cycle of up to five years, which can ensure the stable operation of the system. 2. Package update speed: If you need to use the latest Hadoop features and features, you can consider Debian's unstable version (Sid). However, it should be noted that unstable versions may have compatibility issues and stability risks. 3. Community support and resources: Debian has huge community support, which can provide rich documentation and

TigerVNC share file method on DebianTigerVNC share file method on DebianApr 13, 2025 am 11:45 AM

This article describes how to use TigerVNC to share files on Debian systems. You need to install the TigerVNC server first and then configure it. 1. Install the TigerVNC server and open the terminal. Update the software package list: sudoaptupdate to install TigerVNC server: sudoaptinstalltigervnc-standalone-servertigervnc-common 2. Configure TigerVNC server to set VNC server password: vncpasswd Start VNC server: vncserver:1-localhostno

Debian mail server firewall configuration tipsDebian mail server firewall configuration tipsApr 13, 2025 am 11:42 AM

Configuring a Debian mail server's firewall is an important step in ensuring server security. The following are several commonly used firewall configuration methods, including the use of iptables and firewalld. Use iptables to configure firewall to install iptables (if not already installed): sudoapt-getupdatesudoapt-getinstalliptablesView current iptables rules: sudoiptables-L configuration

Debian mail server SSL certificate installation methodDebian mail server SSL certificate installation methodApr 13, 2025 am 11:39 AM

The steps to install an SSL certificate on the Debian mail server are as follows: 1. Install the OpenSSL toolkit First, make sure that the OpenSSL toolkit is already installed on your system. If not installed, you can use the following command to install: sudoapt-getupdatesudoapt-getinstallopenssl2. Generate private key and certificate request Next, use OpenSSL to generate a 2048-bit RSA private key and a certificate request (CSR): openss

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

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)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools