search
HomeOperation and MaintenanceCentOSIntroducing centos complete deletion of folders and files commands

The following column centos introductory tutorial will introduce to you the centos complete deletion of folders and files. I hope it will be helpful to friends in need!

Introducing centos complete deletion of folders and files commands

##centos Completely delete folders and files command (centos new , delete, move, copy and other commands:

1. Create a new folder

mkdir file name

Create a new folder named test in Under home

view source1 mkdir /home/test

2. Create a new text

Create a new test.sh script under home

vi /home/test.sh

3. Delete files or folders

1. Delete the test directory under the home directory

rm /home/test

2. This deletion method without parameters often prompts that it cannot be deleted because the permissions are not enough.

rm -r /home/test

3 , -r recursively deletes the directory and its subdirectories in the parameter table. The directory will be emptied and deleted. The user is usually prompted when deleting write-protected files contained in the directory.

rm - rf /home/test

-4. f does not prompt the user and deletes all files in the directory. Please check the path. It will be a tragedy if you enter it in another directory.

rm -ir /home/test

5. -i is interactive mode. Using this option, the rm command prompts the user for confirmation before deleting any files.

4. Move files or folders

mv [options] Source file or directory Target file or directory

Example:

1. Move all files in the hscripts folder/directory, Directories and subdirectories to the tmp directory mv hscripts tmp Analysis: In the above command, if the tmp directory already exists, the mv command will move all files, directories and subdirectories under the hscripts folder/directory to the tmp directory. If There is no tmp directory, it will rename the hscripts directory to the tmp directory.

2,

Move multiple files/more questions to another directorymv file1.txt tmp/file2.txt newdir
This command moves the file1.txt file in the current directory and the file2.txt file in the tmp folder/directory to the newdir directory.

Parameters:

-i: Interactive mode operation. If the mv operation will cause the overwriting of the existing target file, the system will ask whether to rewrite and require the user to answer "y" or "n" to avoid overwriting the file by mistake.

-f: Disable interactive operations. The mv operation does not give any instructions when overwriting an existing target file. After specifying this parameter, the i parameter will no longer have any effect.

5. Copy files or folders

cp [options] Source file (source) Destination file (destination)

Parameters:

-a: Equivalent to -pdr;
-d: If the source file is an attribute of a link file, copy the link file attributes instead of the file itself;
-f: Force means that if there is duplication or other questions, the user will not be asked and the copy will be forced;
-i: If the destination file (destination) already exists, it will first ask whether it is a real action when overwriting!
-l: Create a hard link link file instead of copying the file itself;
-p: Copy the file together with its attributes instead of using the default attributes;
-r : Recursive continuous copy, used for directory copy behavior;
-s: Copy into a symbolic link file (symbolic link), that is, a "shortcut" file;
-u: Only update destination if destination is older than source !
Finally, it should be noted that if there are more than two source files, the last destination file must be a "directory"!

Example:


1. Copy two files:
cp file1 file2The above cp command copies the file The contents of file1.php are transferred to the file file2.php.

2. Back up the copied file :
cp -b file1.php file2.phpCreate the file file1.php with the symbol ' ~''s backup file file2.php~.

3. Copy folders and subfolders:
cp -R scripts scripts1The above cp command copies folders and subfolders from scripts to scripts1.

6. Create directorymkdir file name
mkdir /var/www/test

The above is the detailed content of Introducing centos complete deletion of folders and files 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: What Led to the Decision to End SupportCentOS: What Led to the Decision to End SupportApr 23, 2025 am 12:10 AM

RedHatendedsupportforCentOStoshifttowardsacommerciallyfocusedmodelwithCentOSStream.1)CentOStransitionedtoCentOSStreamforRHELdevelopment.2)ThisencourageduserstomovetoRHEL.3)AlternativeslikeAlmaLinux,RockyLinux,andOracleLinuxemergedasreplacements.

Using CentOS: A Guide for System AdministratorsUsing CentOS: A Guide for System AdministratorsApr 22, 2025 am 12:04 AM

CentOS is an open source operating system based on RedHatEnterpriseLinux, suitable for server environments. 1. Select the appropriate media and options during installation and configure network, firewall and user permissions. 2. Use useradd, usermod and systemctl commands to manage users and services, and update software packages regularly. 3. Basic operations include using yum installation software and systemctl management services, and advanced features such as SELinux to enhance security. 4. Check the system log to solve common errors. Optimizing performance requires monitoring resources and cleaning of unnecessary files.

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.

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.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version