AGAmirali Gholian

Amirali Gholian

💻 Python | 🐧 Linux | 🚀 AI
← Back to Home

🐧 Linux

Essential Linux commands and system administration

1. File and Directory Commands

What is it? These commands help you navigate and manage files in Linux. Like using File Explorer, but with text commands.
file_commands.sh
# pwd - show current directory pwd # ls - list files ls # Simple list ls -la # Detailed list with hidden files # cd - change directory cd /home # Go to home folder cd .. # Go up one level cd ~ # Go to user home # mkdir - create folder mkdir my_folder # cp - copy file cp file.txt file_copy.txt # mv - move or rename mv old_name.txt new_name.txt # rm - delete rm file.txt # Delete file rm -r folder/ # Delete folder # cat - show file content cat file.txt

2. SSH - Secure Connection

What is it? SSH lets you connect to remote computers securely. Like having remote access to another computer.
ssh_guide.sh
# Connect to remote server ssh user@example.com # Connect with specific port ssh -p 2222 user@example.com # Generate SSH key (do this once) ssh-keygen -t rsa -b 4096 # Copy key to server (for password-less login) ssh-copy-id -i ~/.ssh/id_rsa.pub user@example.com # Copy file from local to remote scp file.txt user@example.com:/home/user/ # Copy file from remote to local scp user@example.com:/home/user/file.txt .

3. Permissions - Control Access

What is it? Permissions control who can read, write, or run files. Important for security and organization.
permissions.sh
# chmod - change permissions # Format: chmod [who][action][permission] file # Numbers: r=4, w=2, x=1 chmod 755 file.sh # Owner: read+write+execute # Group and Others: read+execute chmod 644 file.txt # Owner: read+write # Group and Others: read only chmod 700 secret.txt # Only owner can access # Make file executable chmod +x script.sh # chown - change owner sudo chown user:group file.txt