Today I learned basics of linux commands, below commands are sufficient for devOps please guide someone.

Shailesh Gokhale - Aug 19 - - Dev Community

Here are some essential Linux commands that are frequently used in DevOps for managing systems, automating tasks, and deploying applications:

1. File and Directory Management

  • ls: List files and directories.

     ls -la  # List all files with detailed information
    
  • cd: Change directory.

     cd /path/to/directory  # Navigate to a specific directory
    
  • cp: Copy files or directories.

     cp file1.txt file2.txt  # Copy file1.txt to file2.txt
     cp -r /src /dest  # Copy a directory recursively
    
  • mv: Move or rename files and directories.

     mv oldname.txt newname.txt  # Rename a file
     mv /src /dest  # Move a file or directory
    
  • rm: Remove files or directories.

     rm file.txt  # Remove a file
     rm -rf /path/to/dir  # Remove a directory recursively
    

2. File Viewing and Editing

  • cat: Concatenate and display file content.

     cat file.txt  # Display file content
    
  • less or more: View large files one screen at a time.

     less largefile.log  # View large files
    
  • grep: Search for a pattern within files.

     grep "pattern" file.txt  # Search for a pattern in a file
     grep -r "pattern" /path  # Recursively search in a directory
    
  • nano, vi, vim: Text editors for editing files.

     nano file.txt  # Open file in nano editor
     vi file.txt  # Open file in vi editor
    

3. System Monitoring and Process Management

  • top: Display real-time system information, including running processes.

     top  # Display running processes and system information
    
  • htop: An enhanced version of top (requires installation).

  • ps: Display information about running processes.

     ps aux  # List all running processes
    
  • kill: Terminate a process.

     kill -9 PID  # Forcefully terminate a process with the specified PID
    
  • df: Show disk space usage.

     df -h  # Show disk space usage in human-readable format
    
  • du: Show directory space usage.

     du -sh /path/to/dir  # Show size of a directory
    

4. Networking

  • ifconfig or ip: Display or configure network interfaces.

     ifconfig  # Display network interface information
     ip addr  # Display IP addresses
    
  • ping: Test network connectivity.

     ping google.com  # Ping Google to test connectivity
    
  • netstat: Network statistics and connections.

     netstat -tuln  # List all listening ports
    
  • curl: Transfer data from or to a server.

     curl http://example.com  # Fetch a web page
    
  • wget: Download files from the web.

     wget http://example.com/file.zip  # Download a file
    

5. User and Permissions Management

  • sudo: Execute a command as another user, typically root.

     sudo command  # Run a command with elevated privileges
    
  • chmod: Change file or directory permissions.

     chmod 755 file.sh  # Set file permissions
    
  • chown: Change file or directory ownership.

     chown user:group file.txt  # Change owner and group of a file
    
  • useradd / userdel: Add or delete a user.

     sudo useradd username  # Add a new user
     sudo userdel username  # Delete a user
    
  • passwd: Change a user’s password.

     passwd username  # Change password for a user
    

6. Archiving and Compression

  • tar: Archive files.

     tar -cvf archive.tar /path/to/dir  # Create a tar archive
     tar -xvf archive.tar  # Extract a tar archive
    
  • zip / unzip: Compress or decompress files.

     zip archive.zip file.txt  # Compress a file into a zip archive
     unzip archive.zip  # Extract files from a zip archive
    

7. Package Management

  • apt (Debian/Ubuntu): Install, update, and manage packages.

     sudo apt update  # Update package list
     sudo apt install package_name  # Install a package
    
  • yum (RHEL/CentOS): Similar to apt for Red Hat-based distributions.

     sudo yum install package_name  # Install a package
    

8. Automation and Scripting

  • cron: Schedule periodic tasks.

     crontab -e  # Edit the cron jobs
    
  • bash: Shell scripting.

     #!/bin/bash
     echo "Hello, World!"
    

9. Version Control (Git)

  • git clone: Clone a repository.

     git clone https://github.com/user/repo.git  # Clone a git repository
    
  • git pull: Update local repository with remote changes.

     git pull origin main  # Pull latest changes from the main branch
    
  • git commit: Commit changes to the repository.

     git add .  # Stage all changes
     git commit -m "Commit message"  # Commit changes
    

10. Docker and Kubernetes

  • docker ps: List running containers.
  • docker images: List images.
  • docker build: Build an image.
  • kubectl get pods: List Kubernetes pods.
  • kubectl apply -f: Apply a configuration file.

These commands cover the basics for managing a Linux environment, handling files, processes, networking, and working with popular DevOps tools like Git, Docker, and Kubernetes.

. .
Terabox Video Player