These are some of the most recommended skills in a DevOps Engineers.
1.How to start /stop services
Sometimes, there might be instance where we want to view the status of a service or even restart the same and here are a few useful commands for few common services :
All these service works on several scripts and these scripts are stored in /etc/init.d location, this init.d is a daemon which is the first process of the Linux system.
sudo /etc/init.d/apache stop — Stops the Apache serversudo /etc/init.d/mysql start — Starts the SQL server sudo /etc/init.d/mysql restart — Retarts the SQL serversudo /etc/init.d/cron status — It can be active(running) or inactive (dead)
2.How to diagnose or fix high loads
There’s at least one server resource (RAM, CPU, I/O, etc.) that’s being abused.
- Using htop command shows you the current running processes and the CPU each process is consuming.
- Crons could be taking high CPU and it can be disabled if it doesn’t ruin the system.
The /proc/ directory — also called the proc file system — contains a hierarchy of special files which represent the current state of the kernel
cat /proc/loadavg to find the average load of CPU and IOcat /proc/meminfo — To give the memory info.
3. How to diagnose or fix disk space issues
- df -h used to check the Disk Usage and Swap Memory can be enabled if needed
- Delete unwanted files rm <filename> or rm -rf <directory>
- Compress files — gzip <directory>
- Compress files using tar commands —
tar -cf newdirectory.tar directoryold , where -c is create newdirectory.tar from the directory named directoryold
4. How to Setup and Configure Linux Firewalls :
“IPTables” is the default tool provided in Linux to establish a firewall. Iptables is used to set up, maintain and inspect the tables of the IPv4 and IPv6 packet filter rules in the Linux Kernel.
a. List the current rules of iptables:
sudo iptables -L
b. To change the default policy:
sudo iptables -P Chain_name Action_to_be_taken
Example:-
sudo iptables -P FORWARD DROP
c. To append a rule at the end of the chain:
sudo iptables -A
d. To append a rule at the start of the chain:
sudo iptables -I
e. To implement a ACCEPT rule:-
sudo iptables -A/-I chain_name -s source_ip -j action_to_take
Example:-
iptables -A INPUT -s 192.168.1.3 -j ACCEPT
f. Implementing rules on specific ports/protocols:-
sudo iptables -A/-I chain_name -s source_ip -p protocol_name --dport port_number -j Action_to_take
Example:-
sudo iptables -I INPUT -s 192.168.1.3 -p tcp --dport 22 -j ACCEPT
g. To delete a rule:-
sudo iptables -D chain_name rule_number
Example:-
sudo iptables -D INPUT 1
h. To save the configuration:-
sudo invoke-rc.d iptables-persistent save
Here’s a well detailed article on the same.
5. How to Install /Update Packages
In Ubuntu, Advanced Package Tool — apt is the package management tool
sudo apt-get install <pkg>or apt-get update <pkg>
In Mac , Homebrew is one of the the package installation tool
brew install <pkg>
Cheers, Linu!