No results found

Try a different search query

Popular searches:

Add to Cart

Cart

You have no purchases yet

Browse Marketplace

Basic Linux Commands for Web Developers

A complete guide to essential Linux commands every web developer should know. From file system navigation to process management.

20 min read
3,886
5
7
Basic Linux Commands for Web Developers

Which terminal do you use?

5 votes

Log In to vote

Linux is the foundation of modern web infrastructure. Most servers in the world run on Linux, so knowing basic commands is essential for every web developer. In this article, we'll cover the most important commands you'll use daily.

File System Navigation

First of all, you need to learn how to navigate the file system. Here are the basic commands:

# Show current directory
pwd

# Change directory
cd /var/www/html

# Go up one level
cd ..

# Go to home directory
cd ~

# List directory contents
ls -la

Tip from an experienced admin: use Tab for path autocompletion - it saves a lot of time and prevents errors.

— Alex, DevOps engineer with 10 years of experience

Working with Files and Directories

Creating, copying, moving, and deleting files - basic operations you'll perform constantly:

# Create directory
mkdir my_project
mkdir -p path/to/nested/directory

# Create file
touch index.php

# Copy file
cp source.txt destination.txt
cp -r source_dir/ destination_dir/

# Move/rename
mv old_name.txt new_name.txt

# Delete file
rm file.txt

# Delete directory with contents
rm -rf directory/
Warning: The rm -rf command deletes files permanently! Always double-check the path before executing.

Viewing File Contents

# Output entire file
cat config.php

# First 20 lines
head -20 access.log

# Last 50 lines
tail -50 error.log

# Follow file in real-time
tail -f /var/log/nginx/access.log

# Page-by-page view
less large_file.log

File Permissions

Understanding file permissions is critical for your server's security:

# Change file owner
chown www-data:www-data file.php

# Recursively change owner
chown -R www-data:www-data /var/www/html

# Set permissions
chmod 755 script.sh
chmod 644 config.php

# Recursively for directories
find /var/www -type d -exec chmod 755 {} \;
find /var/www -type f -exec chmod 644 {} \;
Tip: For OpenCart, recommended permissions are: 755 for directories and 644 for files. The image, system/storage directories and config.php may need 777 during installation.

Finding Files and Text

# Find file by name
find /var/www -name "*.php"

# Find files modified in the last hour
find . -mmin -60

# Search text in files
grep -r "function getProducts" /var/www/html

# Search with line numbers
grep -rn "error" /var/log/

Process Management

Monitoring and managing processes helps maintain server health:

# Show all processes
ps aux

# Interactive process monitor
htop

# Find process by name
ps aux | grep nginx

# Kill process
kill 1234
kill -9 1234  # force

# Restart service
sudo systemctl restart nginx
sudo systemctl restart php8.2-fpm

Network Commands

# Check connection
ping google.com

# Check open ports
netstat -tulpn
ss -tulpn

# Download file
wget https://example.com/file.zip
curl -O https://example.com/file.zip

# Check DNS
nslookup example.com
dig example.com

Useful Combinations

The power of Linux is revealed in combining commands:

# Find large files
du -h /var/www | sort -rh | head -20

# Count lines of code in project
find . -name "*.php" | xargs wc -l

# Find and replace text in all files
find . -name "*.php" -exec sed -i 's/old_text/new_text/g' {} \;

# Archive project
tar -czvf backup.tar.gz /var/www/html

# Monitor disk usage
df -h
du -sh /var/www/*

The command line may seem complex at first, but with practice, it will become your most powerful tool. Start with basic commands and gradually expand your arsenal.

— Linus Torvalds

Conclusion

These commands cover 90% of a web developer's daily tasks. I recommend creating a cheat sheet and practicing daily. Over time, these commands will become second nature, and you'll be able to perform complex operations in seconds.

Next Step: After mastering basic commands, move on to learning bash scripts for automating routine tasks.
DEV Тестовий

DEV Тестовий

Привіт! Я досвідчений розробник з OpenCart екосистеми з понад 10 роками практики. Технічний стек включає PHP (core мова для OpenCart), MySQL/MariaDB для баз даних, JavaScript/jQuery для фронтенду, HTML5/CSS3/Bootstrap для верстки. Маю глибокий досвід роботи з архітектурою OpenCart (MVC, Event System, OCMOD), інтеграцією платіжних систем та API, оптимізацією продуктивності магазинів. Окрім розробки, займаюся серверним адмініструванням — Linux (Ubuntu/Debian), Apache/Nginx, налаштування VPS/Dedicated серверів, DNS менеджмент, SSL сертифікати, email. Обслуговую понад 5000 інтернет-магазинів по всьому світу, надаючи комплексні рішення від розробки до технічної підтримки.

articles
12
views
53,919
likes
63
followers
3

Related Posts

Comments (7)

Replying to

Please log in to leave a comment

Log In
a
Можна ще про chmod та права доступу детальніше?
OCTemplates
Використовую ці команди щодня на роботі.
o
Finally understood the difference between grep and find!
a
Чи можете зробити шпаргалку PDF з цими командами?

We use cookies

We use cookies and similar technologies to improve your experience, analyse traffic, and show personalised ads. Read our Cookie Policy for details.