Introduction to Linux Development
Linux provides a powerful and flexible environment for software development. Whether you're building system tools, web servers, or desktop applications, understanding Linux fundamentals is essential.
Essential Commands
# Navigation
pwd # Print working directory
cd /path/to/dir # Change directory
ls -la # List files with details
# File operations
cp source dest # Copy files
mv source dest # Move/rename files
rm file # Remove file
mkdir -p dir/subdir # Create directories
# Text processing
cat file # Display file content
grep pattern file # Search in file
sed 's/old/new/g' # Stream editor
awk '{print $1}' # Text processing
# Process management
ps aux # List processes
top # Interactive process viewer
kill -9 PID # Terminate process
Shell Scripting
Bash scripts automate repetitive tasks:
#!/bin/bash
# Variables
NAME="World"
echo "Hello, $NAME!"
# Conditionals
if [ -f "$1" ]; then
echo "File exists: $1"
else
echo "File not found: $1"
fi
# Loops
for file in *.txt; do
echo "Processing $file"
wc -l "$file"
done
# Functions
greet() {
local name=$1
echo "Welcome, $name!"
}
greet "Developer"
# Command substitution
TODAY=$(date +%Y-%m-%d)
echo "Today is $TODAY"
Development Tools
- GCC/G++: GNU Compiler Collection
- GDB: GNU Debugger
- Make: Build automation
- Git: Version control
- Vim/Neovim: Text editors
Building C/C++ on Linux
# Compile a simple program
gcc -o hello hello.c
g++ -std=c++20 -o app main.cpp
# With warnings and debugging
g++ -Wall -Wextra -g -O2 -o app main.cpp
# Using Make
make
make clean
make install
# Using CMake
mkdir build && cd build
cmake ..
cmake --build .
Package Management
# Debian/Ubuntu (apt)
sudo apt update
sudo apt install build-essential
sudo apt search package-name
# Fedora/RHEL (dnf)
sudo dnf install gcc-c++
sudo dnf search package-name
# Arch Linux (pacman)
sudo pacman -S base-devel
pacman -Ss package-name
Permissions
# Change permissions
chmod 755 script.sh # rwxr-xr-x
chmod +x script.sh # Add execute permission
chmod u+w file # Add write for user
# Change ownership
chown user:group file
sudo chown -R user:user directory/
← Back to Developer Resources