search
HomeOperation and MaintenanceCentOSShare a complete list of CentOS basic commands

The following is the centos introductory tutorial column to share with you a complete list of CentOS basic commands. I hope it will be helpful to friends in need!

Share a complete list of CentOS basic commands

1. Shutdown (system shutdown, restart and logout) commands

shutdown -h now Shut down the system(1)

init 0 Shut down the system(2)

telinit 0 Shut down the system(3)

shutdown -h hours:minutes & Shut down the system according to the scheduled time

shutdown -c Cancel shut down the system according to the scheduled time

shutdown -r now Restart(1)

reboot Restart(2)

logout Logout

2. Command to view system information

arch Display the processor architecture of the machine (1)

uname -m displays the processor architecture of the machine (2)

uname -r displays the kernel version being used

dmidecode - q Display hardware system components - (SMBIOS/DMI)

hdparm -i /dev/hda List the architectural characteristics of a disk

hdparm - tT /dev/sda Perform a test read operation on the disk

cat /proc/cpuinfo Display CPU info information

cat / proc/interrupts Display interrupts

cat /proc/meminfo Verify memory usage

cat /proc/swaps Display which swaps are used

cat /proc/version displays the kernel version

cat /proc/net/dev displays network adapter and statistics

cat /proc/mounts Display mounted file systems

lspci -tv List PCI devices

lsusb -tv display USB device

date Display the system date

cal 2007 Display the calendar for 2007

date 041217002007.00 Set date and time - month, day, hour, minute, year.second

clock -w Save time modification to BIOS

3 .File and directory operation commands

cd /home Enter the '/ home' directory'

cd .. Return to the previous level Directory

cd ../.. Return to the upper two-level directory

cd Enter the personal home directory

cd ~user1 Enter the personal home directory

cd - Return to the last directory

pwd Display working path

ls View the files in the directory

ls -F View the files in the directory

ls - l Display details of files and directories

ls -a Display hidden files

mkdir dir1 Create a directory called 'dir1''

mkdir dir1 dir2 Create two directories at the same time

mkdir -p /tmp/dir1/dir2 Create a directory tree

rm -f file1 Delete a file called 'file1'

rmdir dir1 Delete a directory called 'dir1'

rm -rf dir1 Delete a directory called 'dir1' and delete its contents at the same time

rm -rf dir1 dir2 Delete two directories and their contents at the same time

mv dir1 new_dir Rename/move a directory

cp file1 file2 Copy a file

cp dir /* . Copy all files in a directory to the current working directory

cp -a /tmp/dir1 . Copy a directory to the current working directory

cp -a dir1 dir2 Copy a directory

ln -s file1 lnk1 Create a soft link pointing to a file or directory

ln file1 lnk1 Create a physical link to a file or directory

touch file1 Create a file

4. File search command

find / -name file1 Enter the root file system starting from '/' to search for files and directories

find / -user user1 Search for files and directories belonging to user 'user1'

find /home/user1 -name \*.bin Search for files and directories with Files ending with '.bin'

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

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

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

whereis file displays the location of a binary file, source code or man

which file displays a Full path to binary or executable file

5. View file contents

cat file1 from the first Bytes start to view the contents of the file in the forward direction

tac file1 View the contents of a file in the reverse direction starting from the last line

more file1 View one Contents of long files

less file1 Similar to the 'more' command, but it allows reverse operations on the file as well as forward operations

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

tail -2 file1 View the last two lines of a file 5. Mount command

mount /dev/hda2 /mnt/hda2 Mount a disk called hda2 (Note: Make sure the directory '/mnt/hda2' already exists)

umount /dev/hda2 Uninstall A disk called hda2 (exit from the mount point '/mnt/hda2' first)

fuser -km /mnt/hda2 Forced unmount when the device is busy

umount -n /mnt/hda2 Runs the unmount operation without writing the /etc/mtab file (very useful when the file is read-only or when the disk is full)

mount /dev/fd0 /mnt/floppy Mount a floppy disk

mount /dev/cdrom /mnt/cdrom Mount a CD

mount /dev/hdc /mnt/cdrecorder Mount a cdrw or dvdrom

mount /dev/hdb /mnt/cdrecorder Mount a cdrw or dvdrom

mount -o loop file.iso /mnt/cdrom Mount a file or ISO image file

mount -t vfat /dev/hda5 /mnt/hda5 mount Mount a Windows FAT32 file system

mount /dev/sda1 /mnt/usbdisk Mount a USB disk or flash device

mount - t smbfs -o username=user,password=pass //WinClient/share /mnt/share Mount a windows network share

6. Disk space operation commands

df -h Display the mounted partition list

ls -lSr |more Arrange files and directories by size

du -sh dir1 Estimate the used disk space of directory 'dir1'

du -sk * | sort -rn Sort by capacity Display the size of files and directories

7. User and group related commands

groupadd group_name Create a new user Group

groupdel group_name Delete a user group

groupmod -n new_group_name old_group_name Rename a user group

useradd -c "Name Surname " -g admin -d /home/user1 -s /bin/bash user1 Create a user belonging to the "admin" user group

useradd user1 Create a new user

userdel -r user1 Delete a user ('-r' also deletes the home directory)

passwd user1 Modify a user User's password (only allowed to be executed by root)

##chage -E 2005-12-31 user1 Set the expiration period of the user password

##ls - lh show permission

chmod 777 directory1 Sets the permissions of the directory owner (u), group (g) and others (o) to read (r), write (w) and execute (x)

chmod 700 directory1 Delete the read, write and execute permissions of the group (g) and others (o) on the directory

chown user1 file1 Change the ownership of a file The human attribute is use1.

chown -R user1 directory1 changes the owner attribute of a directory and simultaneously changes the attributes of all files in the directory to be owned by use1

chgrp group1 file1 changes the group of the file to group1

chown user1:group1 file1 changes the owner and group attributes of a file. The group it belongs to is group1 and the user is use1.

find / -perm -u s List all files controlled by SUID in a system

chmod u s /bin/file1 Set up a binary File's SUID bit - The user running the file is also granted the same permissions as the owner

chmod u-s /bin/file1 Disables the SUID bit of a binary file

chmod g s /home/public Set the SGID bit of a directory - similar to SUID, but this is for the directory

chmod g-s /home/public Disable a directory SGID bit

chmod o t /home/public Set the STIKY bit on a file - only allows legitimate owners to delete the file

chmod o-t /home /public disables the STIKY bit of a directory

8. Commands for packaging and decompressing files

bunzip2 file1.bz2 Unzip a file called 'file1.bz2'

bzip2 file1 Compress a file called 'file1'

gunzip file1.gz Unzip a A file called 'file1.gz'

##gzip file1 Compress a file called 'file1'

gzip -9 file1 Maximum compression

rar a file1.rar test_file Create a package called 'file1.rar'

rar a file1.rar file1 file2 dir1 Package 'file1 ', 'file2' and directory 'dir1'

rar x file1.rar Unpack the rar package

unrar x file1.rar Unpack the rar package

tar -cvf archive.tar file1 Create a non-compressed tar package

tar -cvf archive.tar file1 file2 dir1 Create a file containing 'file1', 'file2' 'dir1' package

tar -tf archive.tar displays the contents of a package

tar -xvf archive.tar releases a package

tar -xvf archive.tar -C /tmp releases the compressed package to the /tmp directory (-c is the specified directory)

tar -cvfj archive.tar.bz2 dir1 Create a compressed package in bzip2 format

tar -xvfj archive.tar.bz2 Decompress a compressed package in bzip2 format Package

tar -cvfz archive.tar.gz dir1 Create a compressed package in gzip format

tar -xvfz archive.tar.gz Unzip A compressed package in gzip format

zip file1.zip file1 Create a compressed package in zip format

zip -r file1.zip file1 file2 dir1 Compress several files and directories into a zip format compressed package at the same time

unzip file1.zip Decompress a zip format compressed package

9. Commands about RPM packages

rpm -ivh package.rpm Install an rpm package

rpm -ivh --nodeeps package.rpm Install an rpm package and ignore dependency warnings

rpm -U package.rpm Update an rpm package without changing its configuration file

rpm -F package.rpm Update an rpm package that has been installed

rpm -e package_name.rpm Delete an rpm package

rpm -qa displays all installed rpm packages in the system

rpm -qa | grep httpd displays all rpm packages whose names contain the word "httpd"

rpm -qi package_name Get special information about an installed package

rpm -ql package_name displays a list of files provided by an installed rpm package

##rpm -qc package_name displays a list of configuration files provided by an installed rpm package

rpm -q package_name --whatrequires Displays a list of dependencies with an rpm package

rpm -q package_name --whatprovides Displays an rpm package The volume occupied by the package

rpm -q package_name --scripts Displays the scripts executed during installation/removal l

##rpm -q package_name --changelog Display the modification history of an rpm package

rpm -qf /etc/httpd/conf/httpd.conf Confirm which rpm package the given file is provided by

rpm -qp package.rpm -l displays a list of files provided by an rpm package that has not yet been installed

rpm --import /media/cdrom/ RPM-GPG-KEY Import the public key digital certificate

rpm --checksig package.rpm Confirm the integrity of an rpm package

rpm - qa gpg-pubkey Confirm the integrity of all installed rpm packages

rpm -V package_name Check file size, license, type, owner, group, MD5 check and last modification time

rpm -Va Check all installed rpm packages in the system - use with caution

rpm -Vp package.rpm Confirm that an rpm package is still available Not installed

rpm2cpio package.rpm | cpio --extract --make-directories *bin* Run executable file from an rpm package

rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm Install a built package from an rpm source code

rpmbuild --rebuild package_name.src. rpm Build an rpm package from an rpm source code

10.YUM package upgrader

yum install package_name download And install an rpm package

yum localinstall package_name.rpm will install an rpm package, using your own software repository to resolve all dependencies for you

yum update package_name.rpm Update all rpm packages installed in the current system

yum update package_name Update an rpm package

yum remove package_name Delete an rpm package

yum list List all packages installed in the current system

yum search package_name Search for software packages in the rpm repository

yum clean packages Clean rpm cache and delete downloaded packages

yum clean headers Delete all header files

yum clean all Delete all cached packages and header files

The above is the detailed content of Share a complete list of CentOS basic commands. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:cnblogs. If there is any infringement, please contact admin@php.cn delete
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.

Difference between centos and ubuntuDifference between centos and ubuntuApr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Centos configuration IP addressCentos configuration IP addressApr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to install centosHow to install centosApr 14, 2025 pm 09:03 PM

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

Centos8 restarts sshCentos8 restarts sshApr 14, 2025 pm 09:00 PM

The command to restart the SSH service is: systemctl restart sshd. Detailed steps: 1. Access the terminal and connect to the server; 2. Enter the command: systemctl restart sshd; 3. Verify the service status: systemctl status sshd.

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)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools