search
HomeOperation and MaintenanceCentOSSummary of commonly used CentOS commands and shortcut keys

The following centos tutorial column will introduce to you CentOScommon commands and shortcut keys. I hope it will be helpful to friends in need!

Summary of commonly used CentOS commands and shortcut keys

I recently started learning Linux and installed CentOS 6.4 in VMware Player. For your own convenience and the convenience of others, we have compiled common Linux commands and shortcut keys.

Common commands:

Files and directories:

# CD/Home into '/HOME' Directory

# CD .. Return to the previous level catalog

# CD ../ .. Back to the previous two -level directory

# CD -Return to the last directory of the last directory

# CP File1 File2 copy the file1 as File2

## CP -A DIR1 DIR2 Copy a directory

# CP -A / TMP/DIR1. Copy a directory to the current working directory (. Represents the current directory)

# LS View the file in the directory

# LS -A display hidden file

## LS -L display detailed information

## LS -LRT display files according to time (L represents a detailed list, R represents reverse sorting, T means sorting by time)

PWD display work path

# Mkdir Dir1 Create 'Dir1' Directory

# Mkdir Dir1 Dir2 and create two directory

# Mkdir -P/TMP/DIR1/DIR2

## mv dir1 dir2 Move/rename a directory

# rm -f file1 Delete 'file1'

# rm -rf dir1 Delete 'dir1 ' Contents of the directory and its subdirectories

View the file content:

# cat file1                                                                                                                                                                                      View the contents of the file forward starting from the first byte

# head -2 file1                                                                                                                                                                                                                                             View the first two lines of a file Contents of file

# tail -3 file1 View the last three lines of a file

##Text processing:

# grep str /tmp/test Search for "str" ​​in the file '/tmp/test'

# grep ^str /tmp/test Search for lines starting with "str" ​​in the file '/tmp/test'

# grep [0-9] /tmp/test Find all lines containing numbers in the '/tmp/test' file

# grep str -r /tmp/* In the directory '/tmp ' and its subdirectories to search for "str"

# diff file1 file2 Find the differences between two files

# sdiff file1 file2 Display the differences between the two files in a comparative manner

Find:

find / -name file1

find / -user user1                                                                                                                                                                                                                     user1' to find Files ending with '.bin'

# find /usr/bin -type f -atime 100 Find executable files that have not been used in the past 100 days

# find /usr/bin - type f -mtime -10 Find files that were created or modified within 10 days

# locate \*.ps Find files ending with '.ps' file at the end, first run the 'updatedb' command

# find -name '*.[ch]' | xargs grep -E 'expr' Find -type f in all .c and .h files in the current directory and its subdirectories

# -print0 | Finding 'expr'

## Compression and decompression in the current directory:

## BZIP2 File1 Compression File1 # bunzip2 file1.bz2 Decompress file1.bz2

# gzip file1 Compress file1

# gzip -9 file1 Maximum compression of file1

# gunzip file1.gz Decompression of file1 .gz

# tar -cvf archive.tar file1                                                                                                         packed file1 into archive.tar

(-c: Create a compressed archive; -v: Display all processes; -f: Use the file name, which is required. is the last parameter)

# tar -cvf archive.tar file1 dir1 Package file1, dir1 into archive.tar

# tar -tf archive.tar Display the contents of a package

# tar -xvf archive.tar Release a package

# tar -xvf archive.tar -C /tmp Release the compressed package to the /tmp directory

# zip file1. ZIP FILE1 Create a zip format compressed package

# ZIP -R File1.zip File1 DIR1 to compress the file and directory into a zip format compressed package

# UNZIP FILE1.zip to decompress a zip The compressed packet of the format to the current directory

## unzip test.zip -d/tmp/unzip a zip format compression packet to/tmp directory

# y yum Tools:

# yum -y install [package] Download and install an rpm package

# yum localinstall [package.rpm] Install an rpm package, Use your own software repository to resolve all dependencies

# yum -y update Update all rpm packages installed in the current system

# yum update [package] Update an rpm package

# yum remove [Package] Delete an RPM package

## y List List all the packages installed in the current system

# u [Package] Search for software packs in the RPM warehouse

# yum clean [package]                                                                                                                                     off out the software packages under the cache directory (/var/cache/yum)

#                       down                   out out all header files           out. Delete all cached packages and header files

##Network:

ifconfig eth0                                                                                                              Configuration

# ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Configure the IP address of the network card

# ifdown eth0 Disable 'eth0' network device

# ifup eth0                                                                                                                                                                                                         ‐       ‐                           Display the configuration of a wireless network card

# iwlist scan Show wireless network

# ip addr show The IP address of the network card

# Others:

SU -Switch to ROOT permissions (different from SU)

# shutdown -h now                                                                                                                                                                                                                                                                                   # # pstree                                                                                                                                                                                                                                                   off ## df -h Display disk usage

# Cal -3 Display the previous month, the current month and the next month's month calendar

# Cal 10 1988 Display the specified month, the annual month calendar

Date-- date '1970-01-01 UTC 1427888888 seconds' Convert a number of seconds relative to 1970-01-01 00:00 into time

Common shortcut keys:

In CentOS 6.4, shortcut keys can be set through System->Preferences->Keyboard Shortcuts, as shown in the figure. For example, you can set the shortcut key for running the terminal to Ctrl Alt T.

# counter to Delete the character from the cursor. Ctrl c Cancel the command entered in the current line, equivalent to Ctrl Break

Ctrl A cursor move to the head (ahead of line), which is equivalent to the usual home key

# Ctrl E cursor to End of Line (END of Line) Move the cursor forward by one character position

Ctrl b Move the cursor backward by one character position

Ctrl l Clear the screen, which is equivalent to executing the clear command

Ctrl r Display: prompt, search related historical commands (reverse-i-search) based on user input

Ctrl w Delete the beginning of the word from before the cursor position to the current word

Ctrl t Swap the two characters before the cursor position

Ctrl y Paste the last deleted word

Ctrl Alt d Display the desktop

Alt b Move the cursor backward to Previous word

Alt d Delete from the cursor position to the end of the current word

Alt F2 Run

Alt F4 Close the current window

Alt F9 Minimize the current window

Alt F10 Maximize the current window

Alt Tab Switch windows

Alt Press and hold the left button to move the window (or scroll the mouse wheel on the bottom taskbar )

[Middle mouse button] Paste the highlighted text. Use the left mouse button to select text. Point your cursor to where you want to paste the text. Click the middle mouse button to paste.

[Tab] Command line auto-completion. Use this method when using the shell prompt. Type the first few characters of a command or file name and then press the [Tab] key, and it will automatically complete the command or display all commands that match the characters you type.

Press / directly on the desktop or file manager to enter the location and open the file manager.

Quick search: Press / directly in vi or Firefox to enter the search state.

Website links and pictures can be dragged and dropped directly to the desktop or directory, and can be downloaded immediately.

Drag the file in the file manager directly into the terminal to get the complete path name in the terminal.

Click the middle mouse button on the blank space of the scroll bar, and the screen will scroll to that place.

The above is the detailed content of Summary of commonly used CentOS commands and shortcut keys. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
CentOS: Security, Stability, and PerformanceCentOS: Security, Stability, and PerformanceApr 21, 2025 am 12:11 AM

CentOS is the first choice for server and enterprise environments for its superior security, stability and performance. 1) Security provides forced access control through SELinux to improve system security. 2) Stability is supported by the LTS version for up to 10 years to ensure the stability of the system. 3) Performance significantly improves system response speed and resource utilization by optimizing kernel and system configuration.

The CentOS Replacement Landscape: Current Trends and ChoicesThe CentOS Replacement Landscape: Current Trends and ChoicesApr 20, 2025 am 12:05 AM

CentOS alternatives should have the characteristics of stability, compatibility, community support and package management. 1.AlmaLinux provides 10 years of support, 2. RockyLinux is initiated by the founder of CentOS to ensure compatibility with CentOS. Migration cost and performance optimization should be considered when choosing.

CentOS: An Introduction to the Linux DistributionCentOS: An Introduction to the Linux DistributionApr 19, 2025 am 12:07 AM

CentOS is an open source distribution based on RedHatEnterpriseLinux, focusing on stability and long-term support, suitable for a variety of server environments. 1. The design philosophy of CentOS is stable and suitable for web, database and application servers. 2. Use YUM as the package manager to release security updates regularly. 3. Simple installation, you can build a web server with a few commands. 4. Advanced features include enhanced security using SELinux. 5. Frequently asked questions such as network configuration and software dependencies can be debugged through nmcli and yumdeplist commands. 6. Performance optimization suggestions include tuning kernel parameters and using a lightweight web server.

CentOS in Action: Server Management and Web HostingCentOS in Action: Server Management and Web HostingApr 18, 2025 am 12:09 AM

CentOS is widely used in server management and web hosting. Specific methods include: 1) using yum and systemctl to manage the server, 2) install and configure Nginx for web hosting, 3) use top and mpstat to optimize performance, 4) correctly configure the firewall and manage disk space to avoid common problems.

CentOS: A Community-Driven Linux DistributionCentOS: A Community-Driven Linux DistributionApr 17, 2025 am 12:03 AM

CentOS is a stable, enterprise-grade Linux distribution suitable for server and enterprise environments. 1) It is based on RedHatEnterpriseLinux and provides a free, open source and compatible operating system. 2) CentOS uses the Yum package management system to simplify software installation and updates. 3) Support advanced automation management, such as using Ansible. 4) Common errors include package dependency and service startup issues, which can be solved through log files. 5) Performance optimization suggestions include the use of lightweight software, regular cleaning of the system and optimization of kernel parameters.

What Comes After CentOS: The Road AheadWhat Comes After CentOS: The Road AheadApr 16, 2025 am 12:07 AM

Alternatives to CentOS include RockyLinux, AlmaLinux, OracleLinux, and SLES. 1) RockyLinux and AlmaLinux provide RHEL-compatible binary packages and long-term support. 2) OracleLinux provides enterprise-level support and Ksplice technology. 3) SLES provides long-term support and stability, but commercial licensing may increase costs.

CentOS: Exploring the AlternativesCentOS: Exploring the AlternativesApr 15, 2025 am 12:03 AM

Alternatives to CentOS include UbuntuServer, Debian, Fedora, RockyLinux, and AlmaLinux. 1) UbuntuServer is suitable for basic operations, such as updating software packages and configuring the network. 2) Debian is suitable for advanced usage, such as using LXC to manage containers. 3) RockyLinux can optimize performance by adjusting kernel parameters.

Centos shutdown command lineCentos shutdown command lineApr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

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

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.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft