Hakki
Posted on November 22, 2023
This cheat sheet includes essential Linux commands and concepts commonly used in the DevOps workflow:
File System Navigation:
-
pwd
: Print the current working directory. -
ls
: List files and directories in the current directory.-
ls -l
: List files and directories in long format. -
ls -a
: List all files and directories, including hidden ones.
-
-
cd
: Change the current directory.-
cd ~
: Change to the home directory. -
cd ..
: Move up one directory level.
-
-
touch
: Create an empty file. -
mkdir
: Create a new directory. -
rm
: Remove files or directories.-
rm -r
: Remove directories recursively.
-
-
mv
: Move or rename files and directories. -
cp
: Copy files and directories. -
find
: Search for files and directories. -
grep
: Search for text within files. -
cat
: Display the contents of a file. -
more
orless
: View file content page by page. -
head
andtail
: Display the beginning or end of a file. -
file
: Determine file type.
File Permissions:
-
chmod
: Change file permissions. -
chown
: Change file ownership. -
chgrp
: Change group ownership. -
umask
: Set default permissions for new files and directories.
Process Management:
-
ps
: List running processes.-
ps aux
: List all processes.
-
-
top
: Monitor system processes in real-time. -
kill
: Terminate processes. -
killall
: Terminate processes by name. -
bg
andfg
: Manage background and foreground processes. -
nohup
: Run a command that continues running even after you log out.
Package Management (Debian/Ubuntu):
-
apt-get update
: Update package lists. -
apt-get upgrade
: Upgrade installed packages. -
apt-get install
: Install new packages. -
apt-get remove
: Remove packages. -
apt-cache search
: Search for packages. -
dpkg
: Debian package management commands.
Package Management (Red Hat/CentOS):
-
yum update
: Update packages. -
yum install
: Install packages. -
yum remove
: Remove packages. -
yum search
: Search for packages. -
rpm
: RPM package management commands.
Networking:
-
ifconfig
orip
: Display network interface information. -
ping
: Check network connectivity. -
netstat
: Network statistics. -
ssh
: Securely access remote systems. -
scp
: Securely copy files between systems. -
curl
orwget
: Download files from the internet. -
nc
: Netcat for network-related tasks. -
iptables
orfirewalld
: Configure firewall rules.
System Information:
-
uname
: Display system information. -
df
: Show disk space usage. -
du
: Show directory space usage. -
free
: Display memory usage. -
top
orhtop
: Monitor system resources. -
lscpu
orcat /proc/cpuinfo
: CPU information. -
lsblk
orfdisk -l
: List block devices. -
date
: Display the system date and time.
Shell Scripting:
- Create and edit shell scripts using a text editor like
nano
,vim
, oremacs
. - Use
#!/bin/bash
(or another shell) as the shebang line. - Make the script executable with
chmod +x script.sh
. - Execute the script with
./script.sh
.
Version Control:
-
git
: Git commands for version control. -
svn
: Subversion commands for version control.
Containerization (Docker):
-
docker
: Docker commands for container management. -
docker-compose
: Compose multiple containers.
Automation (cron):
-
crontab
: Schedule recurring tasks.
Text Processing:
-
sed
: Stream editor for text manipulation. -
awk
: Text processing tool. -
cut
: Extract sections from lines of files.
Monitoring and Logging:
- Use tools like
syslog
,journalctl
, andlogrotate
for system logs. - Use monitoring tools like Nagios, Zabbix, or Prometheus for system health.
π πͺ π
π©
Hakki
Posted on November 22, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.