Search
Close this search box.
Search
Close this search box.

Getting Started with Linux Commands

If you have a VPS or dedicated server, then you may access the Terminal by going to Advanced > Terminal.

Here are some usuful commands.

Navigate to home

cd

Navigate to folder

cd folder_name

Clear log

clear

List down all the content inside the directory

ls

Count Files using wc

ls | wc -l

Delete Files Older Than x Days on Linux

First find the files. For example if you want to find all files that start with wp-load and are older then 5 days then run this command:

find 'firstletters'* -mtime +5

Then delete them

find 'firstletters'* -mtime +5 -exec rm -f {} \;

Get a file

When the cron job executes wget command (fetches URL resource), it creates a new file every time. It doesn’t overwrite the old downloaded file, but appends a number so by time, there will be thousands of files unless you tweak your crontab to suppress the output. So in order to suppress the output:

wget -q -O - "http://example.com/target.php" >/dev/null 2>&1