Linux Command Line Basics: A Guide for Developers
Learn to use the Linux command line effectively. Explore file management, permissions, process control, and shell scripting basics with practical examples.
Merve Arslan
WordPress & Hosting Expert
The majority of server management, deployment, and automation tasks are performed through the Linux command line. While GUI tools have limitations, the terminal gives you full control. This guide covers file management, the permission system, process control, pipes and redirection operators, and basic shell scripting concepts with practical examples.
Terminal and Shell Concepts
The terminal is the application that provides access to the command line interface. The shell is the program that interprets your commands. Bash (Bourne Again Shell) is the default shell on most Linux distributions. Alternatives include Zsh, Fish, and Dash.
The shell takes your commands, passes them to the operating system kernel, and displays the results. Customize your environment with environment variables, aliases, and shell functions. The .bashrc or .zshrc file loads automatically with each terminal session.
💡 Tip: The man command shows detailed documentation for any command. For example, man ls displays all parameters for the ls command. For quick summaries, consider installing the tldr tool.
File and Directory Management
In Linux, everything is a file — text files, directories, devices, and even processes. The file system is organized hierarchically under the root directory (/).
| Command | Description | Example |
|---|---|---|
| ls | List directory contents | ls -la /var/log |
| cd | Change directory | cd /etc/nginx |
| cp / mv / rm | Copy / Move / Remove | cp -r src/ backup/ |
| find | Search for files | find / -name "*.log" -mtime -7 |
| grep | Search text within files | grep -r "error" /var/log/ |
| chmod / chown | Change permissions and ownership | chmod 755 script.sh |
File Permissions and Ownership
Every Linux file has three permission groups: owner, group, and others. Each group has read (r=4), write (w=2), and execute (x=1) permissions. chmod 755 gives the owner full access and read-execute to group and others. Web server files typically use 644 for files and 755 for directories.
⚠️ Important: Never use chmod 777 — it gives everyone full access and creates a serious security vulnerability. Use chmod 644 for web files and chmod 755 for directories.
Process Management
Running programs are called processes. ps aux lists all processes, while top or htop shows real-time resource usage. Send signals to processes with kill — kill -15 (SIGTERM) for graceful shutdown, kill -9 (SIGKILL) for forced termination.
For background processes, use the & operator or nohup command. In production, prefer process managers like PM2 or systemd. Use systemctl to start, stop, and check the status of systemd services.
Pipes and Redirection Operators
The pipe (|) sends one command's output as input to another. This lets you chain small, single-purpose tools into powerful processing pipelines — the foundation of Unix philosophy. For example, cat access.log | grep "404" | wc -l counts 404 errors in a log file.
Redirection operators write output to files: > overwrites, >> appends. 2>&1 merges error output with standard output. The tee command writes output to both screen and file. These techniques are essential for server management and log analysis.
Basic Shell Scripting
Shell scripts automate repetitive tasks. Build complex automation scenarios with variables, conditionals (if/else), loops (for, while), and functions. Script files should start with #!/bin/bash (shebang) on the first line.
Common use cases include backup scripts, log rotation, health checks, and deployment automation. The Bash reference manual provides comprehensive documentation. For complex automation, analyze your scripts with ShellCheck.
Frequently Asked Questions
Should I use Bash or Zsh?
Bash is available by default on most servers and is reliable for script compatibility. Zsh improves the developer experience with auto-completion, theme support, and a plugin ecosystem. Use Bash for server scripts and Zsh for your personal terminal.
How long does it take to learn the Linux command line?
You can learn basic file management and navigation commands in a few days. Gaining proficiency in process management, networking, and shell scripting takes a few weeks of practice. The 20–30 most frequently used commands cover the majority of daily tasks.
Can I use Linux commands on Windows?
Yes, WSL 2 (Windows Subsystem for Linux) lets you run a full Linux environment on Windows. Install Ubuntu, Debian, or Fedora distributions from the Microsoft Store for direct access to the Linux command line.
After learning Linux command line basics, check our Nginx configuration guide and Docker development environment article.
Linux Server Management Made Easy
Configure your Linux environment as you wish with full root access on Hosted Cloud VPS servers.
Explore VPS PlansMerve Arslan
WordPress & Hosting Expert
Creating guide content on WordPress performance optimization, hosting selection, and e-commerce infrastructure.
Comments coming soon