Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A Collection of basic commands commonly used in CentOS

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of the basic commands commonly used in CentOS. Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Command for shutdown (shutdown, restart, and logout of the system)

Shutdown-h now shuts down the system (1)

Init 0 shuts down the system (2)

Telinit 0 shuts down the system (3)

Shutdown-h hours:minutes & shuts down the system at the scheduled time

Shutdown-c cancels shutting down the system at the scheduled time

Shutdown-r now restart (1)

Reboot restart (2)

Logout logout

two。 Commands to view system information

Processor Architecture of arch display Machine (1)

Processor Architecture of uname-m display Machine (2)

Uname-r shows the kernel version in use

Dmidecode-Q display hardware system components-(SMBIOS / DMI)

Hdparm-I / dev/hda lists the architectural features of a disk

Hdparm-tT / dev/sda performs testable read operations on disk

Cat / proc/cpuinfo displays the information of CPU info

Cat / proc/interrupts display interrupt

Cat / proc/meminfo verifies memory usage

Cat / proc/swaps shows which swap is used

Cat / proc/version shows the kernel version

Cat / proc/net/dev display Network Adapter and Statistics

Cat / proc/mounts displays the loaded file system

Lspci-tv lists PCI devices

Lsusb-tv display USB device

Date displays the system date

Cal 2007 displays the calendar for 2007

Date 041217002007.00 sets the date and time-month, day, hour, year. Second

Clock-w saves time changes to BIOS

3. File and directory operation command

Cd / home enter the'/ home' directory'

Cd.. Return to the previous directory

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

Cd enters the personal home directory

Cd ~ user1 enters the personal home directory

Cd-returns the directory where it was last located

Pwd displays the work path

Ls view the files in the directory

Ls-F View the files in the directory

Ls-l displays the details of files and directories

Ls-a shows hidden files

Mkdir dir1 creates a directory called 'dir1''

Mkdir dir1 dir2 creates two directories at the same time

Mkdir-p / tmp/dir1/dir2 create a directory tree

Rm-f file1 deletes a file called 'file1''

Rmdir dir1 deletes a directory called 'dir1''

Rm-rf dir1 deletes a directory called 'dir1' and deletes its contents at the same time

Rm-rf dir1 dir2 deletes both directories and their contents

Mv dir1 new_dir rename / move a directory

Cp file1 file2 copies 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 creates a soft link to a file or directory

Ln file1 lnk1 creates a physical link to a file or directory

Touch file1 creates a file

4. File search command

Find /-name file1 enters the root file system from'/'to search for files and directories

Find /-user user1 searches for files and directories belonging to user 'user1'

Find / home/user1-name\ * .bin searches for files ending with '.bin' in the directory'/ home/user1''

Find / usr/bin-type f-atime + 100 searches for execution files that have not been used in the past 100 days

Find / usr/bin-type f-mtime-10 searches for files that have been created or modified within 10 days

Locate\ * .ps looks for files that end with '.ps'-run the 'updatedb' command first

Whereis file shows the location of a binary, source, or man

Which file displays the full path to a binary or executable file

5. View the contents of the file

Cat file1 looks forward at the contents of the file from the first byte

Tac file1 starts from the last line to view the contents of a file in reverse

More file1 looks at the contents of a long file

Less file1 is similar to the 'more' command, but it allows the same reverse operation in the file as the forward operation

Head-2 file1 looks at the first two lines of a file

Tail-2 file1 looks at the last two lines of a file. Mount command

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

Umount / dev/hda2 unmount a disk called hda2 (exit from mount point'/ mnt/hda2' first)

Fuser-km / mnt/hda2 force uninstall when the device is busy

Umount-n / mnt/hda2 runs the uninstall operation without writing to the / etc/mtab file (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 mounts 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 mounts a file or ISO image file

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

Mount / dev/sda1 / mnt/usbdisk mounts a usb shortcut or flash memory device

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

6. Commands for disk space operations

Df-h displays a list of mounted partitions

Ls-lSr | more arranges files and directories by size

Du-sh dir1 estimates the directory 'disk space already used by dir1''

Du-sk * | sort-rn displays the size of files and directories in turn based on capacity

7. User and group related commands

Groupadd group_name creates a new user group

Groupdel group_name deletes 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 creates a user belonging to the "admin" user group

Useradd user1 creates a new user

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

Passwd user1 modifies a user's password (only root is allowed to execute)

Chage-E 2005-12-31 user1 sets the expiration period for user passwords

Ls-lh display permissions

Chmod 777 directory1 sets permissions for directory owners (u), groups (g), and others (o) to read (r), write (w), and execute (x)

Chmod 700directory1 delete group (g) and others (o) read and write permissions to the directory

Chown user1 file1 changes the owner property of a file to use1.

Chown-R user1 directory1 changes the owner property of a directory and simultaneously changes the properties of all files in the directory to be owned by use1

Chgrp group1 file1 changed the group of files to group1

Chown user1:group1 file1 changes the owner and group properties of a file. The group is group1 and the user is use1.

Find /-perm-Utility lists all the files in a system that are controlled by SUID

Chmod Utility / bin/file1 sets the SUID bit of a binary file-the user running the file is also given the same permissions as the owner

Chmod Umurs / bin/file1 disables the SUID bit of a binary file

Chmod genders / home/public sets the SGID bit of a directory-similar to SUID, but for directories

Chmod Gmurs / home/public disables the SGID bit of a directory

Chmod STIKY / home/public sets the STIKY bit of a file-only legitimate owners are allowed to delete the file

Chmod Omurt / home/public disables the STIKY bit of a directory

8. Command to package and unzip files

Bunzip2 file1.bz2 unzips a file called file1.bz2'

Bzip2 file1 compresses a file called 'file1'

Gunzip file1.gz unzips a file called file1.gz'

Gzip file1 compresses a file called 'file1'

Gzip-9 file1 maximum compression

Rar a file1.rar test_file creates a package called 'file1.rar'

Rar a file1.rar file1 file2 dir1 packages' file1', 'file2' and directory' dir1'

Rar x file1.rar unpack rar

Unrar x file1.rar unpack rar

Tar-cvf archive.tar file1 creates an uncompressed tar package

Tar-cvf archive.tar file1 file2 dir1 creates a package that contains the 'file1',' file2' 'dir1'

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 package to the / tmp directory (- c is the specified directory)

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

Tar-xvfj archive.tar.bz2 decompresses a compressed package in bzip2 format

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

Tar-xvfz archive.tar.gz decompresses a compressed package in gzip format

Zip file1.zip file1 creates a compressed package in zip format

Zip-r file1.zip file1 file2 dir1 compresses several files and directories into a package in zip format at the same time

Unzip file1.zip decompresses a compressed package in zip format

9. Commands about the RPM package

Rpm-ivh package.rpm installs a rpm package

Rpm-ivh-nodeeps package.rpm installs a rpm package and ignores dependency warnings

Rpm-U package.rpm updates a rpm package without changing its configuration file

Rpm-F package.rpm updates a confirmed installed rpm package

Rpm-e package_name.rpm deletes a rpm package

Rpm-qa displays all installed rpm packages in the system

Rpm-qa | grep httpd displays all rpm packages with the word "httpd" in their names

Rpm-qi package_name gets special information about an installed package

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

Rpm-qc package_name displays a list of configuration files provided by the installed rpm package

Rpm-Q package_name-- whatrequires displays a list of dependencies on a rpm package

Rpm-Q package_name-- whatprovides shows the volume occupied by a rpm packet

Rpm-Q package_name-- scripts displays the script l executed during installation / removal

Rpm-Q package_name-- changelog displays the modification history of a rpm package

Rpm-qf / etc/httpd/conf/httpd.conf confirms which rpm package provided the given file

Rpm-qp package.rpm-l displays a list of files provided by an uninstalled rpm package

Rpm-- import / media/cdrom/RPM-GPG-KEY Import Public key Digital Certificate

Rpm-checksig package.rpm confirms the integrity of a rpm package

Rpm-qa gpg-pubkey confirms the integrity of all installed rpm packages

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

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

Rpm-Vp package.rpm confirms that a rpm package is not installed

Rpm2cpio package.rpm | cpio-- extract-- make-directories * bin* runs the executable file from a rpm package

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

Rpmbuild-- rebuild package_name.src.rpm builds a rpm package from a rpm source code

10.YUM software package upgrader

Yum install package_name download and install a rpm package

Yum localinstall package_name.rpm will install a rpm package and use your own software repository to solve all dependencies for you

Yum update package_name.rpm updates all installed rpm packages on the current system

Yum update package_name updates a rpm package

Yum remove package_name deletes a rpm package

Yum list lists all packages installed on the current system

Yum search package_name searches rpm repository for software packages

Yum clean packages cleans the rpm cache and deletes downloaded packages

Yum clean headers deletes all header files

Yum clean all deletes all cached packages and header files

This is the end of the content of the basic commands commonly used in CentOS. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report