Shaded path in forest, Pulau Peucang, Indonesia

Linux Commands for Moving Files

Help on the Commands

ls –help

cd –help

cp –help

rm –help

Listing Files in a Folder

For listing the files and folders in a folder, the command is: ls (that is a lower case el)

Copying and Moving Files

The command for changing the current folder is: cd

To copy files, use the cp command.

To move files, use the mv command.

Deleting (Removing) Files

To delete files, use the rm command.

To delete all files in a folder, and the folder itself, use the rm -r command.

Moving files from WordPress Multi-Site folder structure prior to v3.5, to modern folder structure

# Moving files from WordPress Multi-Site folder structure prior to v3.5, to modern folder structure

# Change the current directory (WordPress Multi-Site, each site's Media Library folders) 
cd ~/public_html/wp-content/uploads/sites
ls

# Each site's Media Library folders are in the Site's folder, along with plugin storage.
# List contents of a folder. Add "-R" to list files recursively, current and sub-folders
# Note: might be folders other than media library, for example old plugins. 
# Important to check you are moving all files you want to keep.
ls -R 56/files/
# in this case, listing files for site 56.

# Copy specified files, current and subfolders
# ~/public_html/wp-content/uploads/sites/[siteID]/files/[years]/[months]/[images]
# to ~/public_html/wp-content/uploads/sites/[siteID]/[years]/[months]/[images]
cp --recursive 56/files/2*/ 56/ 

# Confirm moved files correctly
ls -R 56/2*/

# Delete the old (now empty) folders
# -r says to remove folders, recursively (without -r, just removes files)
rm -r 56/files/

To delete files or folders, use the rm command (or rm -r)