Linux Commands for Software Engineers
Tags: softwaredevelopment, softwareengineering, linux, cli
Published: 2024-07-09 09:00:33

## 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.`
> ```github
> Example: ls -l (detailed list)
> ```

> **2. cd**
> `Purpose: Change directory.`
> ```github
> Example: cd /home/user (navigate to user's home directory)
> ```

> **3. pwd**
> `Purpose: Print working directory.`
> ```github
> Example: pwd
> ```

> **4. mkdir**
> `Purpose: Create a new directory.`
> ```github
> Example: mkdir new_directory
> ```

> **5. rmdir**
> `Purpose: Remove an empty directory.`
> ```github
> Example: rmdir old_directory
> ```

> **6. rm**
> `Purpose: Remove files or directories.`
> ```github
> Example: rm file.txt (remove a file), rm -r directory (remove a directory and its contents)
> ```

> **7. cp**
> `Purpose: Copy files or directories.`
> ```github
> 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.`
> ```github
> 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.`
> ```github
> Example: touch newfile.txt
> ```

> **10. cat**
> `Purpose: Concatenate and display file content.`
> ```github
> Example: cat file.txt
> ```

> **11. more**
> `Purpose: View file content one screen at a time.`
> ```github
> Example: more file.txt
> ```

> **12. less**
> `Purpose: View file content with backward movement.`
> ```
> Example: less file.txt
> ```

> **13. head**
> `Purpose: Output the first part of a file.`
> ```github
> Example: head -n 10 file.txt (first 10 lines)
> ```

> **14. tail**
> `Purpose: Output the last part of a file.`
> ```github
> Example: tail -n 10 file.txt (last 10 lines)
> File Permissions
> ```

> **15. chmod**
> `Purpose: Change file permissions.`
> ```github
> Example: chmod 755 script.sh
> ```

**16. chown**

`Purpose: Change file owner and group.`

```github
Example: chown user:group file.txt
```

**17. chgrp**

> `Purpose: Change group ownership.`
> ```github
> Example: chgrp group file.txt
> ```

> **18. uname**
> `Purpose: Print system information.`
> ```github
> Example: uname -a
> ```

> **19. df**
> `Purpose: Report file system disk space usage.`
> ```github
> Example: df -h (human-readable format)
> ```

> **20. du**
> `Purpose: Estimate file space usage.`
> ```github
> Example: du -sh directory (summary of directory)
> ```

> **21. top**
> `Purpose: Display task manager.`
> ```github
> Example: top
> ```

> **22. htop**
> `Purpose: Interactive process viewer.`
> ```github
> Example: htop
> ```

> **23. ps**
> `Purpose: Report a snapshot of current processes.`
> ```github
> Example: ps aux
> ```

> **24. free**
> `Purpose: Display memory usage.`
> ```github
> Example: free -h
> ```

> **25. uptime**
> `Purpose: Show how long the system has been running.`
> ```github
> Example: uptime
> ```

> **26. ping**
> `Purpose: Check network connectivity.`
> ```github
> Example: ping google.com
> ```

> **27. ifconfig**
> `Purpose: Configure network interfaces.`
> ```github
> Example: ifconfig
> ```

> **28. ip**
> `Purpose: Show/manipulate routing, devices, policy routing, and tunnels.`
> ```github
> Example: ip addr
> ```

> **29. netstat**
> `Purpose: Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.`
> ```github
> Example: netstat -tuln
> ```

> **30. ss**
> `Purpose: Another utility to investigate sockets.`
> ```github
> Example: ss -tuln
> ```

> **31. scp**
> `Purpose: Secure copy (remote file copy program).`
> ```github
> Example: scp file.txt user@remote:/path/
> ```

**32. rsync**

`Purpose: Remote file and directory synchronization.`

```github
Example: rsync -avz source/ user@remote:/path/
```

> **33. grep**
> `Purpose: Print lines matching a pattern.`
> ```github
> Example: grep "search_term" file.txt
> ```

> **34. awk**
> `Purpose: Pattern scanning and processing language.`
> ```github
> Example: awk '{print $1}' file.txt
> ```

> **35. sed**
> `Purpose: Stream editor for filtering and transforming text.`
> ```github
> Example: sed 's/old/new/g' file.txt
> ```

> **36. apt-get (Debian/Ubuntu)**
> `Purpose: Handle packages.`
> ```github
> 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.`
> ```github
> Example: sudo yum install package_name
> ```

> **38. dnf (Fedora) **
> `Purpose: Modernized version of yum.`
> ```github
> Example: sudo dnf install package_name
> ```

> **39. pacman (Arch)**
> `Purpose: Package manager for Arch Linux.`
> ```github
> Example: sudo pacman -S package_name
> Archiving and Compression
> ```

> **40. tar**
> `Purpose: Archive files.`
> ```github
> Example: tar -czvf archive.tar.gz directory/
> ```

> **41. zip**
> `Purpose: Package and compress files.`
> ```github
> Example: zip -r archive.zip directory/
> ```

> **42. unzip**
> `Purpose: Extract compressed files.`
> ```github
> Example: unzip archive.zip
> ```

> **43. gzip**
> `Purpose: Compress files.`
> ```github
> Example: gzip file.txt
> ```

> **44. gunzip**
> `Purpose: Decompress files.`
> ```github
> Example: gunzip file.txt.gz
> ```

> **45. fdisk**
> `Purpose: Partition table manipulator.`
> ```github
> Example: sudo fdisk /dev/sda
> ```

> **46. mkfs**
> `Purpose: Build a Linux file system.`
> ```github
> Example: sudo mkfs.ext4 /dev/sda1
> ```

> **47. mount**
> `Purpose: Mount a file system.`
> ```github
> Example: sudo mount /dev/sda1 /mnt
> ```

> **48. umount**
> `Purpose: Unmount a file system.`
> ```github
> Example: sudo umount /mnt
> ```

> **49. adduser**
> `Purpose: Add a user to the system.`
> ```github
> Example: sudo adduser username
> ```

> **50. usermod**
> `Purpose: Modify a user account.`
> ```github
> Example: sudo usermod -aG groupname username
> ```

**51. passwd**
`Purpose: Change user password.`
```github
Example: passwd username
```

> **52. whoami**
> `Purpose: Print the current user id and name.`
> ```github
> Example: whoami
> ```

> **53. groups**
> `Purpose: Show user groups.`
> ```github
> Example: groups username
> ```

> **54. kill**
> `Purpose: Terminate a process.`
> ```github
> Example: kill PID
> ```

> **55. killall**
> `Purpose: Terminate all processes by name.`
> ```github
> Example: killall process_name
> ```

> **56. pkill**
> `Purpose: Send a signal to a process by name.`
> ```github
> Example: pkill process_name
> ```

> **57. bg**
> `Purpose: Resume a job in the background.`
> ```github
> Example: bg %1
> ```

> **58. fg**
> `Purpose: Bring a job to the foreground.`
> ```github
> Example: fg %1
> ```

> **59. export**
> `Purpose: Set environment variables.`
> ```github
> Example: export VAR=value
> ```

> **60. alias**
> `Purpose: Create an alias for a command.`
> ```github
> Example: alias ll='ls -la'
> ```


**61. source**

`Purpose: Execute commands from a file in the current shell.`

```github
Example: source ~/.bashrc
```

> **62. history**
> `Purpose: Show command history.`
> ```github
> Example: history
> ```

> **63. clear**
> `Purpose: Clear the terminal screen.`
> ```
> Example: clear
> ```

> **64. exit**
> `Purpose: Exit the shell.`
> ```github
> Example: exit
> ```


`LinkedIn Account` : [LinkedIn](https://www.linkedin.com/in/matthew-odumosu/)
`Twitter Account `: [Twitter](https://twitter.com/iamcymentho)
**Credit**: Graphics sourced from [cloudzy](https://cloudzy.com/blog/10-linux-commands-every-user-should-know/)