While cPanel & WHM automates many server administration tasks, familiarity with the Linux® command line can prove useful for both WHM and cPanel users. This documentation gives a brief overview of some basic Linux commands that you may wish to use as you manage your website or server.
For steps to access the command line, read our How to Access the Command Line documentation.
Common Linux commands
To execute a command, enter the command with any options or arguments that it requires and press Enter.
The following table lists some basic Linux commands and their functions:
List files and directories that exist within your current directory. This command resembles the
To view dotfiles (filenames that begin with a period) and additional file and directory details, add the
Navigate between directories.
Print the contents of the specified file to the CLI.
To view the data that currently displays on your server's console screen, run the following command:
Print the last 20 lines of a file to the command line interface (CLI).
You can add an argument to change the number of lines that this command prints. For example, to print the last 100 lines of the
Print the contents of a file to the CLI, one screen at a time.
Open the specified file in the
Open the specified file in the
Search for a string in a specified file, and prints each line that contains a match to the CLI.
Create an empty file in the specified location.
Create a symbolic link between the two specified files.
Delete the specified file. After you run this command, the system prompts you to confirm the file's deletion.
|List which users recently logged in and the timestamp for each login.|
|List currently logged-in users and the location from which they logged in.|
|List all of the server's current network connections.|
Guess a file's type, based on the file's contents.
|Show the system's current disk usage for each directory and subdirectory.|
Display the word count for a specific file.
Copy a file into a new file.
Change a file's octal permissions.
For more information, read the Wikipedia article about the
Change a file's user and group ownership.
Query applications that match the
You can find the most common applications in the following locations:
Return information about the server's current processes.
To view all of the running processes, run one of the following commands:
Run multiple commands on the same line
Various command-line tasks may require that you use different commands on the same line. Linux includes easy methods to perform these tasks.
- Use the pipe character (
|) to retrieve data from one program and "pipe" it to another program.
- Use a single greater-than bracket (
>) to create a new file if the file does not already exist, or to overwrite any existing content if the file does exist.
- Use a double greater-than bracket (
>>) to create a new file if the file does not already exist, or to append the new data to the file if the file does exist.
- Use a single less-than bracket (
<) to send input from a file to a command.
The table below lists examples of how to combine tasks into a single line:
|This command searches for all of the lines in the |
|This command prints all of the current login history to the |
This command finds the last 10,000 lines from the
The system treats periods (
|This command shows the number of active connections to Apache (Apache's |
|This command lists the number of MySQL threads. If subselect expressions start new threads, the output of the |
Common configuration files and directories
You can find common configuration files and directories in the following locations on your server: