Create Directory
Introduction: The mkdir command creates directories in Linux. It's fundamental for organizing files and creating project structures on your server.
mkdir /home/4Born-Server-Setup/backup
mkdir -p /home/4Born-Server-Setup/logs/nginx/error
mkdir "Project Files" temp cache
mkdir -m 755 /home/4Born-Server-Setup/public
Real Example: Create backup folder, create nested directories with -p (creates parent dirs), create multiple folders at once, and create public folder with specific permissions (755 = rwxr-xr-x).
List Directory Contents
Introduction: The ls command lists directory contents with various formatting options. Essential for navigating and understanding file structures.
ls /home/4Born-Server-Setup
ls -la /home/4Born-Server-Setup/logs
ls -lh /home/4Born-Server-Setup/*.conf
ls -lt /home/4Born-Server-Setup/logs | head -10
find /home/4Born-Server-Setup -name "*.log" -ls
Real Example: List our server directory, show all files including hidden (-la), show config files with human-readable sizes (-lh), show 10 newest files by time (-lt), and find all .log files with details.
Navigate Directories
Introduction: The cd command changes your current working directory. It's like clicking through folders but faster and more precise for server navigation.
cd /home/4Born-Server-Setup
cd nginx/conf
cd ../logs
cd ~
cd -
pwd
Real Example: Go to our server directory, enter nginx config folder, go back and into logs (../logs), go to home (~), return to previous directory (-), and show current path (pwd).
Copy Files/Folders
Introduction: The cp command creates copies of files and directories. Use -r for folders, -a to preserve all attributes, and -v for verbose output showing what's being copied.
cp /home/4Born-Server-Setup/nginx.conf /home/4Born-Server-Setup/backup/
cp -r /home/4Born-Server-Setup/logs /home/4Born-Server-Setup/backup/
cp -av /home/4Born-Server-Setup/config/ /home/4Born-Server-Setup/backup/
cp -u /home/4Born-Server-Setup/logs/*.log /home/4Born-Server-Setup/backup/logs/
Real Example: Copy nginx config to backup, copy entire logs folder recursively, copy config folder preserving attributes with verbose output (-av), and copy only newer log files (-u for update).
Move/Rename Files
Introduction: The mv command moves files to new locations or renames them. Unlike cp, the original file is removed from its old location (cut & paste operation).
mv /home/4Born-Server-Setup/temp.log /home/4Born-Server-Setup/logs/
mv /home/4Born-Server-Setup/nginx.conf /home/4Born-Server-Setup/nginx.conf.backup
mv /home/4Born-Server-Setup/old_project /home/4Born-Server-Setup/archived/
mv /home/4Born-Server-Setup/logs/*.old /home/4Born-Server-Setup/archive/
Real Example: Move temp.log to logs directory, rename nginx.conf to nginx.conf.backup for safety, move old_project to archived folder, and move all .old files to archive directory.
Delete Files/Folders
Introduction: The rm command permanently deletes files and directories. Be very careful! Use -i for interactive confirmation, -r for directories, and -f to force deletion.
rm /home/4Born-Server-Setup/temp/*.tmp
rm -i /home/4Born-Server-Setup/important_file.txt
rm -rf /home/4Born-Server-Setup/old_logs
find /home/4Born-Server-Setup/logs -name "*.log" -mtime +30 -delete
Real Example: Delete all .tmp files from temp folder, delete important file with confirmation (-i), force delete old_logs folder and contents (-rf), and auto-delete log files older than 30 days.