DEV Community

Cover image for Linux Commands for Software Engineers
Odumosu Matthew
Odumosu Matthew

Posted on

Linux Commands for Software Engineers

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: pwd

4. mkdir
Purpose: Create a new directory.

Example: mkdir new_directory

5. rmdir
Purpose: Remove an empty directory.

Example: rmdir old_directory

6. 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.txt

10. cat
Purpose: Concatenate and display file content.

Example: cat file.txt

11. more
Purpose: View file content one screen at a time.

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.

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 Permissions

15. chmod
Purpose: Change file permissions.

Example: chmod 755 script.sh

16. chown

Purpose: Change file owner and group.

Example: chown user:group file.txt
Enter fullscreen mode Exit fullscreen mode

17. chgrp

Purpose: Change group ownership.

Example: chgrp group file.txt

18. uname
Purpose: Print system information.

Example: uname -a

19. 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: top

22. htop
Purpose: Interactive process viewer.

Example: htop

23. ps
Purpose: Report a snapshot of current processes.

Example: ps aux

24. free
Purpose: Display memory usage.

Example: free -h

25. uptime
Purpose: Show how long the system has been running.

Example: uptime

26. ping
Purpose: Check network connectivity.

Example: ping google.com

27. ifconfig
Purpose: Configure network interfaces.

Example: ifconfig

28. ip
Purpose: Show/manipulate routing, devices, policy routing, and tunnels.

Example: ip addr

29. netstat
Purpose: Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

Example: netstat -tuln

30. ss
Purpose: Another utility to investigate sockets.

Example: ss -tuln

31. 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/
Enter fullscreen mode Exit fullscreen mode

33. grep
Purpose: Print lines matching a pattern.

Example: grep "search_term" file.txt

34. awk
Purpose: Pattern scanning and processing language.

Example: awk '{print $1}' file.txt

35. sed
Purpose: Stream editor for filtering and transforming text.

Example: sed 's/old/new/g' file.txt

36. 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_name

39. pacman (Arch)
Purpose: Package manager for Arch Linux.

Example: sudo pacman -S package_name
Archiving and Compression

40. 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.zip

43. gzip
Purpose: Compress files.

Example: gzip file.txt

44. gunzip
Purpose: Decompress files.

Example: gunzip file.txt.gz

45. fdisk
Purpose: Partition table manipulator.

Example: sudo fdisk /dev/sda

46. mkfs
Purpose: Build a Linux file system.

Example: sudo mkfs.ext4 /dev/sda1

47. mount
Purpose: Mount a file system.

Example: sudo mount /dev/sda1 /mnt

48. umount
Purpose: Unmount a file system.

Example: sudo umount /mnt

49. adduser
Purpose: Add a user to the system.

Example: sudo adduser username

50. usermod
Purpose: Modify a user account.

Example: sudo usermod -aG groupname username

51. passwd
Purpose: Change user password.

Example: passwd username
Enter fullscreen mode Exit fullscreen mode

52. whoami
Purpose: Print the current user id and name.

Example: whoami

53. groups
Purpose: Show user groups.

Example: groups username

54. kill
Purpose: Terminate a process.

Example: kill PID

55. killall
Purpose: Terminate all processes by name.

Example: killall process_name

56. pkill
Purpose: Send a signal to a process by name.

Example: pkill process_name

57. bg
Purpose: Resume a job in the background.

Example: bg %1

58. fg
Purpose: Bring a job to the foreground.

Example: fg %1

59. export
Purpose: Set environment variables.

Example: export VAR=value

60. 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
Enter fullscreen mode Exit fullscreen mode

62. history
Purpose: Show command history.

Example: history

63. clear
Purpose: Clear the terminal screen.

Example: clear

64. exit
Purpose: Exit the shell.

Example: exit

LinkedIn Account : LinkedIn
Twitter Account: Twitter
Credit: Graphics sourced from cloudzy

Top comments (0)