Frequently Used Commands
Below is a list of a few commonly used commands. The highlighted
arguments should be replaced with the actual arguments.
ls
- Displays everything in the current directoryls -a
- Displays all files, including hiddenls -l
- Displays all files, along with the size and timestamptar -zxpf archive.tar.gz
- Uncompresses tar.gz filestar -xpf archive.tar
- Uncompresses .tar filesgunzip archive.gz
- Uncompresses .gz filescp source target
- Copies a filemv source target
- Moves a file to a new file, or renamemkdir directory-name
- Creates a directoryrmdir directory-name
- Deletes a directoryrm file-name
- Deletes a filerm -rfv directory-name
- Deletes a directorycd location
- Moves to a directorycd ..
- Moves to a lower directorycd ~
- Moves to your home directorycd -
- Moves to the previous directorypwd
- Displays the current directorypico
- Opens the text editorftp
- Connect to an FTP serverlynx
- View a webpagedf -h
- Displays the hard drive stats in human-readable formatquota
- Displays your disk quotauptime
- Displays the uptime of the serveruname -a
- Displays the operating system statswhoami
- Displays your current account informationwho
- Displays others connected to the serverlast
- Displays the last loginwhereis
- Shows where a file is locatedmail
- Checks your emailps -x
- Displays processes your runningps -a
- Displays all processes runningps -ux
- Displays running processes, with CPU/Memory usagekill process
- Kills a processkill -9 process
- Kills an eggdrop processkillall process
- Kills all running process of the same typewhatis
- Description of commandsman
- Displays help on the commandnano
- Opens the editortop
- Gives an overall view of what is going on with the server including memory usage, server load and running processes. Press q
to exit top.sar -q
- Gives a report of the process list, 1-minute and 5-minute average load every 10 minutes since midnight (server time)tar -zcf filename.tar.gz filename
- Archives the file or directory of your choice, replace filename.tar.gz
with the name you want your tar file to have (including tar.gz extension at the end) and replace filename
with the file or directory you want to pack into the archive. You can also use a path/to/file for both of these arguments.updatedb
- Updates the locate/search database
netstat -n -p
- Useful to see who is connected to your server. This also resolves hostnames to IP addresses and the -p
flag shows what each connected user is doing, providing a PID for it (if available).
find / -user username
- Replace username
with a username of one of your accounts to find all the files that belong to them. Also useful to add the |more
switch so you can scroll one screen at a time. Ever have a client who seems to show a lot more files than are actually in their home directory? This is how you find those files and fix them. Common problem on cPanel servers is cpmove
files that don't get properly deleted and get added to a user's account.
The --help
flag - For example tar --help
, similar to man
, it shows information about any given command.
tail -10 filename
- Gives you the last 10 lines of a file. Can change the # to whatever you want.
cp -R fileordirectory path/to/destination
- The -R
flag runs the command recursively and allows you to copy an entire directory.
kill -9 process
- Not just for eggdrops. Known as "hard kill" and is handy for terminating any stubborn process that refuses to end. Please use with caution, as ending a system process can sometimes cause severe issues.
killall process
- Terminate all processes being run by a user. Useful if you have an abuser eating up system resources. Please use with caution, as ending a system process can sometimes cause severe issues.
Manage Services
Restart a service:
systemctl restart service-name
Stop a service:
systemctl stop service-name
Start a service:
systemctl start service-name
Check current status:
systemctl status service-name
Replace service-name
with the name of the actual service.
On a RHEL-based cPanel server, here are the most common services:
bandmin
chkservd
cpanel
crond
exim
httpd
mysql
named
proftpd
Editing Cron Jobs
To edit the cron jobs of the current account:
crontab -e
To edit a user's cron jobs:
crontab -u username -e
Replace username
with the actual username of the user you want to edit.
cPanel / WHM Scripts
If your server has cPanel installed, it will add many useful and important scripts under the /scripts
directory. You can find a current list of these scripts here: WHM Scripts | cPanel & WHM Documentation
DISCLAIMER: The scripts and commands provided in our knowledgebase are for informational purposes only. We do not provide any warranty or support. It is essential to review and modify the scripts/commands to fit your site's specific needs. There may be unforeseen outcomes when adding new script code to an existing website. You should discuss it with your website manager and seek advice from an experienced website developer if you are unsure.
Updated by SP on 23/11/2022