Linux command line
- Linux Command Line: A Beginner's Guide for MediaWiki Administrators
This article provides a foundational understanding of the Linux command line, essential for managing a MediaWiki 1.40 installation. While a graphical user interface (GUI) can be used, the command line offers greater control, efficiency, and access to advanced features. This guide assumes a Debian/Ubuntu based distribution, common for MediaWiki deployments, but concepts are broadly applicable.
Why the Command Line?
For MediaWiki administrators, the command line is crucial for:
- System administration tasks like user management and package updates.
- File management – backing up, restoring, and manipulating MediaWiki files.
- Database administration – interacting with your MySQL/MariaDB database.
- Troubleshooting – examining logs and diagnosing issues.
- Automation – creating scripts to automate repetitive tasks (e.g., backups).
- Remote server access via SSH.
The command line uses a hierarchical file system. Understanding basic navigation is key.
- `pwd`: Prints the current working directory.
- `ls`: Lists files and directories. `ls -l` provides a detailed listing with permissions, size, and modification date. `ls -a` shows hidden files (starting with a `.`).
- `cd`: Changes directory. `cd ..` moves up one level. `cd ~` returns to your home directory.
- `mkdir`: Creates a new directory. Example: `mkdir my_new_directory`.
- `rmdir`: Removes an empty directory. Example: `rmdir my_empty_directory`.
- `touch`: Creates an empty file. Example: `touch new_file.txt`.
Essential Commands
Here's a breakdown of commonly used commands:
Command | Description | Example |
---|---|---|
`man` | Displays the manual page for a command. | `man ls` |
`echo` | Prints text to the terminal. | `echo "Hello, world!"` |
`cat` | Displays the contents of a file. | `cat /etc/apache2/apache2.conf` |
`less` | Displays file contents page by page. Useful for large files. | `less /var/log/apache2/error.log` |
`head` | Displays the first few lines of a file. | `head -n 10 /var/log/apache2/access.log` |
`tail` | Displays the last few lines of a file. `-f` option follows the file in real-time (useful for logs). | `tail -f /var/log/mediawiki/errors` |
File Manipulation
Managing files is a core skill.
- `cp`: Copies files and directories. Example: `cp file1.txt file2.txt`.
- `mv`: Moves or renames files and directories. Example: `mv file1.txt new_file.txt`.
- `rm`: Removes files. **Use with caution!** `rm -r` removes directories and their contents recursively. `rm -f` forces removal without prompting.
- `find`: Searches for files. Example: `find /var/www/html -name "LocalSettings.php"`.
- `grep`: Searches for patterns within files. Example: `grep "error" /var/log/apache2/error.log`.
User and Permissions
Understanding user permissions is vital for security.
Command | Description | Example |
---|---|---|
`whoami` | Displays the current user. | `whoami` |
`sudo` | Executes a command with superuser (root) privileges. | `sudo apt update` |
`chown` | Changes the owner of a file or directory. | `sudo chown www-data:www-data /var/www/html/images` |
`chmod` | Changes the permissions of a file or directory. (Octal notation) | `sudo chmod 755 /var/www/html/extensions` |
Permissions are typically represented in octal notation (e.g., 755). Each digit represents permissions for the owner, group, and others, respectively. 4 = read, 2 = write, 1 = execute.
Package Management (APT)
Debian/Ubuntu uses APT (Advanced Package Tool) for package management.
- `sudo apt update`: Updates the package lists. Always run this before installing or upgrading.
- `sudo apt upgrade`: Upgrades all installed packages.
- `sudo apt install <package_name>`: Installs a new package. Example: `sudo apt install php-mysql`.
- `sudo apt remove <package_name>`: Removes a package.
- `sudo apt autoremove`: Removes orphaned packages (dependencies no longer needed).
Process Management
Command | Description | Example |
---|---|---|
`ps` | Lists running processes. `ps aux` provides a comprehensive listing. | grep apache2` |
`top` | Displays a dynamic real-time view of running processes. | `top` |
`kill <process_id>` | Sends a signal to terminate a process. | `kill 1234` |
`pkill <process_name>` | Kills processes by name. | `pkill apache2` |
Shell Scripting (Introduction)
For automating tasks, shell scripting is powerful. A simple script might look like this:
```bash
- !/bin/bash
echo "Starting MediaWiki backup..." date > /var/backups/mediawiki/backup_date.txt mysqldump -u root -p'your_password' wikidb > /var/backups/mediawiki/wikidb_$(cat /var/backups/mediawiki/backup_date.txt).sql echo "Backup complete." ```
Save this as a `.sh` file (e.g., `backup.sh`), make it executable (`chmod +x backup.sh`), and run it (`./backup.sh`). Remember to replace `'your_password'` with your actual database password. Security considerations are paramount when scripting.
Further Learning
- Bash scripting tutorial
- System administration with Linux
- MySQL command line interface
- MediaWiki Backups
- Server security
Intel-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Core i7-6700K/7700 Server | 64 GB DDR4, NVMe SSD 2 x 512 GB | CPU Benchmark: 8046 |
Core i7-8700 Server | 64 GB DDR4, NVMe SSD 2x1 TB | CPU Benchmark: 13124 |
Core i9-9900K Server | 128 GB DDR4, NVMe SSD 2 x 1 TB | CPU Benchmark: 49969 |
Core i9-13900 Server (64GB) | 64 GB RAM, 2x2 TB NVMe SSD | |
Core i9-13900 Server (128GB) | 128 GB RAM, 2x2 TB NVMe SSD | |
Core i5-13500 Server (64GB) | 64 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Server (128GB) | 128 GB RAM, 2x500 GB NVMe SSD | |
Core i5-13500 Workstation | 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000 |
AMD-Based Server Configurations
Configuration | Specifications | Benchmark |
---|---|---|
Ryzen 5 3600 Server | 64 GB RAM, 2x480 GB NVMe | CPU Benchmark: 17849 |
Ryzen 7 7700 Server | 64 GB DDR5 RAM, 2x1 TB NVMe | CPU Benchmark: 35224 |
Ryzen 9 5950X Server | 128 GB RAM, 2x4 TB NVMe | CPU Benchmark: 46045 |
Ryzen 9 7950X Server | 128 GB DDR5 ECC, 2x2 TB NVMe | CPU Benchmark: 63561 |
EPYC 7502P Server (128GB/1TB) | 128 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/2TB) | 128 GB RAM, 2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (128GB/4TB) | 128 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/1TB) | 256 GB RAM, 1 TB NVMe | CPU Benchmark: 48021 |
EPYC 7502P Server (256GB/4TB) | 256 GB RAM, 2x2 TB NVMe | CPU Benchmark: 48021 |
EPYC 9454P Server | 256 GB RAM, 2x2 TB NVMe |
Order Your Dedicated Server
Configure and order your ideal server configuration
Need Assistance?
- Telegram: @powervps Servers at a discounted price
⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️