Linux
VINAI KOLLURI
DevOps Engineer | Cloud & Automation | CI/CD | IaC | Scalable Deployments | DevOps Enthusiast & Mentor
Here are some essential Linux commands for a DevOps engineer :
1. ls: Lists files and directories in the current directory.
ls
2. cd: Changes the current directory.
cd /path/to/directory
3. pwd: Prints the current working directory.
pwd
4. mkdir: Creates a new directory.
mkdir new_directory
5. rm: Removes files or directories.
rm file.txt
rm -r directory_name # to remove a directory and its contents
6. cp: Copies files or directories.
cp source_file destination_file
cp -r source_directory destination_directory # to copy directories
7. mv: Moves or renames files or directories.
mv old_name new_name
mv file.txt /path/to/destination
# File Viewing and Editing
8. cat: Concatenates and displays file contents.
cat file.txt
9. less: Views file contents one page at a time.
less file.txt
10. nano: Edits files using the nano text editor.
nano file.txt
11. head: Displays the first few lines of a file.
head file.txt
12. tail: Displays the last few lines of a file.
tail file.txt
# System Monitoring and Management
13. ps: Displays currently running processes.
ps
ps aux # detailed view of all processes
14. top: Displays real-time system information, including processes and resource usage.
top
15. htop: An interactive process viewer (requires installation).
htop
16. df: Reports file system disk space usage.
df -h # human-readable format
17. du: Estimates file and directory space usage.
du -h /path/to/directory # human-readable format
18. free: Displays memory usage.
free -h # human-readable format
19. uptime: Shows how long the system has been running.
uptime
20. who: Displays who is currently logged in.
who
21. uname: Displays system information.
uname -a # detailed system information
# Network Commands
22. ifconfig: Configures and displays network interface information (older command, ip is preferred).
ifconfig
23. ip: Shows/manages IP addresses and routing.
ip addr show
ip route show
24. ping: Checks network connectivity to a host.
ping google.com
25. curl: Transfers data from or to a server.
curl https://example.com
26. wget: Downloads files from the web.
27. netstat: Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
netstat -tuln # shows listening ports
28. traceroute: Prints the route packets take to a network host.
traceroute google.com
# File Permissions and Ownership
领英推荐
29. chmod: Changes file permissions.
chmod 755 file.sh # sets read, write, execute for owner; read, execute for group and others
30. chown: Changes file owner and group.
chown user:group file.txt
31. chgrp: Changes group ownership of a file.
chgrp group file.txt
# Compression and Archiving
32. tar: Archives files.
tar -cvf archive.tar /path/to/directory # create an archive
tar -xvf archive.tar # extract an archive
33. zip and unzip: Compresses and decompresses files.
zip -r archive.zip /path/to/directory # create a zip archive
unzip archive.zip # extract a zip archive
34. gzip: Compresses files.
gzip file.txt # compresses file.txt to file.txt.gz
35. gunzip: Decompresses files.
gunzip file.txt.gz # decompresses file.txt.gz to file.txt
# Searching and Finding Files
36. grep: Searches text using patterns.
grep "search_pattern" file.txt
37. find: Searches for files in a directory hierarchy.
find /path/to/search -name "filename"
38. locate: Finds files by name (uses a database).
locate filename
39. which: Shows the full path of shell commands.
which ls
40. whereis: Locates binary, source, and manual page files for a command.
whereis ls
# User Management
41. useradd and userdel: Adds and deletes users.
sudo useradd new_user
sudo userdel old_user
42. passwd: Changes a user's password.
sudo passwd username
43. usermod: Modifies user accounts.
sudo usermod -aG group username # adds user to a group
# System Updates and Package Management (Amazon Linux)
44. yum: Manages packages on Amazon Linux.
sudo yum update # updates package lists and upgrades all packages
sudo yum install package_name # installs a package
45. rpm: RPM package manager.
sudo rpm -i package.rpm # installs a package
sudo rpm -e package_name # removes a package
# Disk Management
46. fdisk: Partition table manipulator for Linux.
sudo fdisk -l # lists disk partitions
47. mkfs: Builds a Linux file system.
sudo mkfs -t ext4 /dev/sdX1 # creates an ext4 file system on the specified partition
48. mount: Mounts a file system.
sudo mount /dev/sdX1 /mnt
49. umount: Unmounts a file system.
sudo umount /mnt
# Miscellaneous Commands
50. echo: Displays a line of text.
echo "Hello, World!"
51. date: Displays or sets the system date and time.
date
52. cal: Displays a calendar.
cal
53. alias: Creates an alias for a command.
alias ll='ls -la'
54. history: Displays the command history.
history
55. clear: Clears the terminal screen.
clear