Home Operation and Maintenance CentOS Share a complete list of CentOS basic commands

Share a complete list of CentOS basic commands

Sep 29, 2020 pm 01:45 PM
centos

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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1659
14
PHP Tutorial
1258
29
C# Tutorial
1232
24
What are the backup methods for GitLab on CentOS What are the backup methods for GitLab on CentOS Apr 14, 2025 pm 05:33 PM

Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

Centos shutdown command line Centos shutdown command line Apr 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 ubuntu Difference between centos and ubuntu Apr 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)

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos configuration IP address Centos configuration IP address Apr 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

What are the common misunderstandings in CentOS HDFS configuration? What are the common misunderstandings in CentOS HDFS configuration? Apr 14, 2025 pm 07:12 PM

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

See all articles