Important Linux Commands you will require as Linux Admin /Devops Engineer /Site Reliability Engineer.
Table of contents
No headings in the article.
- File Commands
ls: List files and directories in the current directory.
pwd: Print the current working directory.
cd: Change the current working directory.
mkdir: Create a new directory.
rmdir: Remove an empty directory.
rm: Remove files and directories.
cp: Copy files and directories.
mv: Move or rename files and directories.
ln: Create links to files and directories.
touch: Create or update a file's timestamp.
cat: Concatenate or display files.
less: View files in a pager with scrolling and searching features.
more: View files in a pager with limited features.
head: Display the first few lines of a file.
tail: Display the last few lines of a file.
wc: Count words, lines, and characters in a file.
diff: Compare two files and show the differences.
grep: Search for a pattern in a file or input stream.
find: Find files that match certain criteria.
locate: Find files by name using a database.
Text Processing
grep: Search for a pattern in a file or input stream.
cat: Concatenate or display files.
awk: Processes and manipulates text files.
sed: Stream editor for modifying files.
File Compression and Archiving:
tar: Archives files into a tarball.
gzip: Compresses files.
zip/unzip: Compresses and extracts files in ZIP format.
rsync: Synchronizes files and directories.
Package Management:
apt-get: Package management for Debian-based systems.
yum: Package management for RPM-based systems.
dnf: Next-generation package manager (RPM-based).
pacman: Package management for Arch Linux.
- System Information Commands
uname: Print system information such as kernel name, version, and architecture.
hostname: Print or set the system hostname.
date: Print or set the system date and time.
uptime: Show how long the system has been running and the load average.
who: Show who is logged in to the system.
w: Show who is logged in and what they are doing.
last: Show the last logins to the system.
free: Show the amount of free and used memory in the system.
df: Show the disk space usage of the file systems.
du: Show the disk space usage of files and directories.
Process Management
ps: Show information about the running processes.
top: Show the processes that are using the most CPU and memory resources.
htop: Show the processes that are using the most CPU and memory resources in an interactive interface.
Nice: Sets Process Priority
User Management Commands
useradd: Create a new user account.
userdel: Delete a user account and its home directory.
usermod: Modify a user account's attributes.
passwd: Change a user's password.
chage: Change a user's password expiration settings.
su: Switch to another user's account.
groups: Print the groups that a user belongs to.
id: Print the user ID and group ID of a user.
umask: Set the default permissions for newly created files and directories.
Permissions and ownership:
chown: Change the owner and group of files and directories.
chmod: Change the permissions of files and directories.
sudo: Execute a command as another user, usually the superuser.
sudo: Executes commands with elevated privileges.
- Network Commands
ping: Test the connectivity to another host by sending packets and measuring the response time.
traceroute: Trace the route that packets take to reach another host.
ip: Show or manipulate IP addresses and routing tables.
ifconfig: Show or configure network interfaces.
iwconfig: Show or configure wireless network interfaces.
netstat: Show network connections, routing tables, and statistics.
ss: Show network connections, sockets, and statistics.
tcpdump: Capture and analyze network traffic.
nmap: Scan ports and services on a network host.
curl: Transfer data from or to a server using various protocols.
wget: Download files from the web.
ssh: Connect to a remote host using secure shell protocol.
scp: Copy files securely between hosts using secure copy protocol.
sftp: Transfer files securely between hosts using secure file transfer protocol.
rsync: Synchronize files between hosts using remote sync protocol.
- System Administration:
systemctl: Controls system services (systemd).
cron: Schedules periodic tasks.
journalctl: Views system logs.
fdisk: Disk partitioning utility.
Package Management Commands Depending on your Linux distribution, you may use different commands to install, update, remove, and search for software packages. Here are some examples:
Debian/Ubuntu based distributions Use apt or apt-get commands.
apt update apt upgrade apt install [package] apt remove [package] apt search [package]
Red Hat/CentOS/Fedora based distributions Use yum or dnf commands.
yum update yum install [package] yum remove [package] yum search [package]
dnf update dnf install [package] dnf remove [package] dnf search [package]
Arch Linux based distributions Use pacman command.
pacman -Syu pacman -S [package] pacman -R [package] pacman -Ss [package]