50 linux productions level powerfull commands. these commands are very usefull in real environment in devops, sysops, linux-administrator roles, and in shell scripting
Linux Powerfull Commands:::::::::::::::::::
50 Linux commands that are very useful for DevOps tasks, along with brief explanations and examples:
- rsync - Remote File Copy:
- Efficiently copy files between local and remote systems.
- awk - Text Processing:
- A powerful text processing tool for pattern scanning and reporting.
#cat logfile | awk '/error/ {print $1, $2}'
- sed - Stream Editor:
- Perform text transformations on input streams.
#cat file.txt | sed 's/old/new/g' 4. find - Search for Files:
- Search for files in a directory hierarchy.
- tar - Archive and Compress:
- Create compressed archive files.
- curl - Transfer Data with URLs:
- Transfer data from or to a server.
curl -O https://example.com/file.txt
- lsof - List Open Files:
- List information about files opened by processes.
- iptables - IP Packet Filter:
- Configure IP packet filter rules.
- grep - Search Text Patterns:
- Search for patterns in files.
- awk '{print $NF}' - Extract Last Column:
- Extract and print the last column from a file.
- tee - Redirect Output to File and Terminal:
- Redirect output to a file and display it on the terminal.
- htop - Interactive Process Viewer:
- Display an interactive process viewer.
- netstat - Network Statistics:
- Display network connections, routing tables, interface statistics, masquerade connections, etc.
- awk '!seen[$0]++' - Remove Duplicate Lines:
- Remove duplicate lines from a file.
- tail -n 20 - Display Last 20 Lines:
- Display the last N lines of a file.
- du -h - Show Disk Usage:
- Display disk usage of files and directories.
- ps aux | grep process_name - List Processes:
- List all processes and filter by name.
- watch -n 1 command - Execute Command Periodically:
- Run a command repeatedly at a specified interval.
- df -h - Display Free Disk Space:
- Show free disk space on mounted filesystems.
- nc -l 8080 - Simple Netcat Server:
- Start a simple server using netcat.
- cut -d' ' -f1 - Extract First Column:
- Extract and print the first column from a file.
- journalctl - View System Logs:
- Query and display messages from the journal.
- chmod +x filename - Make File Executable:
- Grant execute permission to a file.
#chmod +x script.sh
- chown user:group filename - Change File Owner:
- Change the owner and group of a file.
- nohup command & - Run Command in Background:
- Run a command that keeps running even after logging out.
- head -n 10 - Display First 10 Lines:
- Display the first N lines of a file.
- fdisk -l - List Partitions:
- Display the partition table for all disks.
- history - View Command History:
- Display the command history for the current session.
- uptime - Check System Uptime:
- Display how long the system has been running.
- crontab -e - Edit Cron Jobs:
- Edit the crontab file to schedule jobs.
- ip a - Show IP Addresses:
- Display network interfaces and their IP addresses.
- systemctl status service_name - Check Service Status:
- View the status of a systemd service.
- echo "Hello, World!" > file.txt - Write to File:
- Write text to a file (overwrites existing content).
- useradd username - Add User:
- Add a new user to the system.
- passwd username - Set User Password:
- Set or change the password for a user.
- ps -ef - Show All Processes:
- Display information about all processes.
- kill -9 process_id - Forcefully Kill Process:
- Terminate a process forcefully.
- scp file.txt user@remote:/path - Secure Copy:
- Copy files securely between local and remote systems.
#scp localfile.txt user@remote:/path
- free -m - Display Free Memory:
- Show the amount of free and used memory.
- systemctl restart service_name - Restart Service:
- Restart a systemd service.
- echo $VARIABLE - Display Environment Variable:
- Display the value of an environment variable.
- ps aux | sort -rk 3,3 - Top CPU Consuming Processes:
- List processes sorted by CPU usage.
- tail -f /var/log/auth.log - Monitor Authentication Logs:
- Continuously monitor authentication logs.
- systemctl stop service_name - Stop Service:
- Stop a systemd service.
- wget - Download Files from the Web:
- Download files from the internet.
- grep -i "error" /path/to/log/*.log - Case-Insensitive Search:
- Search for errors in logs regardless of case.
- df -Th - Display Disk Space Usage with Type:
- Show disk space usage with filesystem type.
- journalctl --since "2023-01-01" - View Logs Since Date:
- Display journal logs since a specific date.
- systemctl enable service_name - Enable Service at Boot:
- Enable a systemd service to start at boot.
- awk -F: '//home/ {print $1, $7}' /etc/passwd - Extract
User and Home Directory:
- Extract and print username and home directory from /etc/passwd.