Introduction
Linux is a powerful and versatile operating system widely used in software development, system administration, and DevOps. Mastering Linux commands is essential for navigating the file system, managing processes, and automating tasks efficiently. This guide covers the most common Linux commands that every software engineer should know, providing a solid foundation for working effectively in a Linux environment. Let's dive into the key Linux commands you should be familiar with.
Basic Commands
1. ls
Purpose: List directory contents.Example: ls -l (detailed list)2. cd
Purpose: Change directory.Example: cd /home/user (navigate to user's home directory)3. pwd
Purpose: Print working directory.Example: pwd4. mkdir
Purpose: Create a new directory.Example: mkdir new_directory5. rmdir
Purpose: Remove an empty directory.Example: rmdir old_directory6. rm
Purpose: Remove files or directories.Example: rm file.txt (remove a file), rm -r directory (remove a directory and its contents)7. cp
Purpose: Copy files or directories.Example: cp source.txt destination.txt (copy file), cp -r source_dir destination_dir (copy directory)8. mv
Purpose: Move or rename files or directories.Example: mv oldname.txt newname.txt (rename file), mv file.txt /new/path/ (move file)9. touch
Purpose: Create an empty file or update the timestamp of an existing file.Example: touch newfile.txt10. cat
Purpose: Concatenate and display file content.Example: cat file.txt11. more
Purpose: View file content one screen at a time.Example: more file.txt12. less
Purpose: View file content with backward movement.Example: less file.txt13. head
Purpose: Output the first part of a file.Example: head -n 10 file.txt (first 10 lines)14. tail
Purpose: Output the last part of a file.Example: tail -n 10 file.txt (last 10 lines) File Permissions15. chmod
Purpose: Change file permissions.Example: chmod 755 script.sh
16. chown
Purpose: Change file owner and group.
Example: chown user:group file.txt
17. chgrp
Purpose: Change group ownership.Example: chgrp group file.txt18. uname
Purpose: Print system information.Example: uname -a19. df
Purpose: Report file system disk space usage.Example: df -h (human-readable format)20. du
Purpose: Estimate file space usage.Example: du -sh directory (summary of directory)21. top
Purpose: Display task manager.Example: top22. htop
Purpose: Interactive process viewer.Example: htop23. ps
Purpose: Report a snapshot of current processes.Example: ps aux24. free
Purpose: Display memory usage.Example: free -h25. uptime
Purpose: Show how long the system has been running.Example: uptime26. ping
Purpose: Check network connectivity.Example: ping google.com27. ifconfig
Purpose: Configure network interfaces.Example: ifconfig28. ip
Purpose: Show/manipulate routing, devices, policy routing, and tunnels.Example: ip addr29. netstat
Purpose: Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.Example: netstat -tuln30. ss
Purpose: Another utility to investigate sockets.Example: ss -tuln31. scp
Purpose: Secure copy (remote file copy program).Example: scp file.txt user@remote:/path/
32. rsync
Purpose: Remote file and directory synchronization.
Example: rsync -avz source/ user@remote:/path/
33. grep
Purpose: Print lines matching a pattern.Example: grep "search_term" file.txt34. awk
Purpose: Pattern scanning and processing language.Example: awk '{print $1}' file.txt35. sed
Purpose: Stream editor for filtering and transforming text.Example: sed 's/old/new/g' file.txt36. apt-get (Debian/Ubuntu)
Purpose: Handle packages.Example: sudo apt-get update (update package index), sudo apt-get install package_name (install a package)37. yum (RHEL/CentOS)
Purpose: Package manager for RPM-based distributions.Example: sudo yum install package_name*38. dnf (Fedora) *
Purpose: Modernized version of yum.Example: sudo dnf install package_name39. pacman (Arch)
Purpose: Package manager for Arch Linux.Example: sudo pacman -S package_name Archiving and Compression40. tar
Purpose: Archive files.Example: tar -czvf archive.tar.gz directory/41. zip
Purpose: Package and compress files.Example: zip -r archive.zip directory/42. unzip
Purpose: Extract compressed files.Example: unzip archive.zip43. gzip
Purpose: Compress files.Example: gzip file.txt44. gunzip
Purpose: Decompress files.Example: gunzip file.txt.gz45. fdisk
Purpose: Partition table manipulator.Example: sudo fdisk /dev/sda46. mkfs
Purpose: Build a Linux file system.Example: sudo mkfs.ext4 /dev/sda147. mount
Purpose: Mount a file system.Example: sudo mount /dev/sda1 /mnt48. umount
Purpose: Unmount a file system.Example: sudo umount /mnt49. adduser
Purpose: Add a user to the system.Example: sudo adduser username50. usermod
Purpose: Modify a user account.Example: sudo usermod -aG groupname username
51. passwd
Purpose: Change user password.
Example: passwd username
52. whoami
Purpose: Print the current user id and name.Example: whoami53. groups
Purpose: Show user groups.Example: groups username54. kill
Purpose: Terminate a process.Example: kill PID55. killall
Purpose: Terminate all processes by name.Example: killall process_name56. pkill
Purpose: Send a signal to a process by name.Example: pkill process_name57. bg
Purpose: Resume a job in the background.Example: bg %158. fg
Purpose: Bring a job to the foreground.Example: fg %159. export
Purpose: Set environment variables.Example: export VAR=value60. alias
Purpose: Create an alias for a command.Example: alias ll='ls -la'
61. source
Purpose: Execute commands from a file in the current shell.
Example: source ~/.bashrc
62. history
Purpose: Show command history.Example: history63. clear
Purpose: Clear the terminal screen.Example: clear64. exit
Purpose: Exit the shell.Example: exit
LinkedIn Account : LinkedIn
Twitter Account: Twitter
Credit: Graphics sourced from cloudzy
Top comments (0)