Faster, better AI-powered code reviews. Start your free trial!  
Faster, better AI-powered code reviews.
Start your free trial!

Get high quality AI code reviews

100 Commands in Linux Every Developer Should Know

IML Bito Hero Featured Image for Blogs (1920 × 640 px)

Table of Contents

Get ready to add some powerful Linux commands to your toolkit and take your coding skills up a notch.

Whether you’re an experienced Linux user or just starting out, this list of 100 must-know Linux commands for developers will help you tackle any task with ease. We’ll start out with the basics, and then get to the more interesting ones

By incorporating AI tools like Bito AI, which helps you understand and optimize your code, you’ll be able to work smarter, not harder and become a 10x developer.

So get ready to unlock the power of Linux in your development workflow with these commands!

1. ls – List the contents of the current directory.

  • ls: This will list the files and directories in the current working directory.
  • ls /usr/local: This will list the files and directories in the /usr/loca directory.

2. cd – Change the current working directory.

  • cd /usr/local: This will change the current working directory to /usr/local.
  • cd ..: This will change the current working directory to the parent directory of the current working directory.

3. mkdir – Create a new directory.

  • mkdir mydir: This will create a new directory called mydir in the current working directory.

4. rmdir – Remove an empty directory.

  • rmdir mydir: This will remove the empty directory called mydir from the current working directory.

5. touch – Create a new file.

  • touch myfile.txt: This will create a new, empty file called myfile.txt in the current working directory.

6. cp – Copy a file or directory.

  • cp myfile.txt myfile_copy.txt: This will create a copy of myfile.txt called myfile_copy.txt in the current working directory.
  • cp -r mydir mydir_copy: This will create a copy of the directory mydir called mydir_copy in the current working directory, including all the files and subdirectories in mydir.

7. mv – Move a file or directory.

  • mv myfile.txt mydir: This will move the file myfile.txt from the current working directory to the directory mydir.
  • mv mydir newname: This will rename the directory mydir to newname.

8. rm – Delete a file.

  • rm myfile.txt : This will delete the file myfile.txt from the current working directory.

9. cat – Display the contents of a file.

  • cat myfile.txt: This will display the contents of the file myfile.txt in the terminal.

10. less – View the contents of a file one page at a time.

  • less myfile.txt: This will display the contents of the file myfile.txt one page at a time in the terminal, allowing you to scroll through the file using the arrow keys. Press q to quit.

11. head – Display the first few lines of a file.

  • head myfile.txt: This will display the first 10 lines of the file myfile.txt.
  • head -n 5 myfile.txt: This will display the first 5 lines of the file myfile.txt.

12. tail – Display the last few lines of a file.

  • tail myfile.txt: This will display the last 10 lines of the file myfile.txt.
  • tail -n 5 myfile.txt: This will display the last 5 lines of the file myfile.txt.

13. grep – Search for a pattern in a file.

  • grep "hello" myfile.txt: This will search for the pattern "hello" in the file myfile.txt and print any lines that contain the pattern.
  • grep -r "hello" *: This will search for the pattern "hello" in all files in the current working directory and its subdirectories, and print the names of the files and the lines that contain the pattern.

14. find – Search for a file by name.

  • find . -name "myfile.txt": This will search for a file called myfile.txt in the current working directory and its subdirectories.
  • find / -name "*.txt": This will search for all files with a .txt extension in the entire file system.

15. sort – Sort the lines of a file.

  • sort myfile.txt: This will sort the lines of the file myfile.txt in alphabetical order.
  • sort -n myfile.txt: This will sort the lines of the file myfile.txt in numerical order.

16. uniq – Remove duplicate lines from a file.

  • uniq myfile.txt: This will remove any duplicate lines from the file myfile.txt.
  • uniq -c myfile.txt: This will remove any duplicate lines from the file myfile.txt and print the count of the number of times each line appears in the file.

17. wc – Count the number of lines, words, and characters in a file.

  • wc myfile.txt: This will print the number of lines, words, and characters in the file myfile.txt.
  • wc -l myfile.txt: This will print the number of lines in the file myfile.txt.

18. cut – Extract specific fields from a file.

  • cut -d "," -f 2 myfile.txt: This will extract the second field (delimited by a comma) from each line of the file myfile.txt and print the fields.

19. paste – Combine the lines of two or more files.

  • paste file1.txt file2.txt: This will combine the lines of file1.txt and file2.txt side by side and print the combined lines.
  • paste -d "," file1.txt file2.txt: This will combine the lines of file1.txt and file2.txt and separate them with a comma, and print the combined lines.

20. tr – Translate or delete specific characters from a file.

  • tr "a-z" "A-Z" < myfile.txt: This will translate all lowercase letters in the file myfile.txt to uppercase and print the translated lines.
  • tr -d "0-9" < myfile.txt: This will delete all digits from the file myfile.txt and print the resulting lines.

21. sed – Edit a file using regular expressions.

  • sed "s/hello/hi/" myfile.txt: This will replace all occurrences of the word "hello" with "hi" in the file myfile.txt and print the resulting lines.
  • sed "s/^#//" myfile.txt: This will remove all leading # characters from the beginning of each line in the file myfile.txt and print the resulting lines.

22. awk – Process and analyze a file using patterns and actions.

  • awk '{print $1}' myfile.txt: This will print the first field (delimited by whitespace) of each line in the file myfile.txt.
  • awk -F "," '{print $2}' myfile.txt: This will print the second field (delimited by a comma) of each line in the file myfile.txt.

23. ar – Create or extract a tarball (a compressed archive file).

  • tar -cvf mydir.tar mydir: This will create a tarball called mydir.tar from the directory mydir.
  • tar -xvf mydir.tar: This will extract the contents of the tarball mydir.tar to the current working directory.

24. gzip – Compress or decompress a file using gzip.

  • gzip myfile.txt: This will compress the file myfile.txt using gzip, creating a new file called myfile.txt.gz.
  • gunzip myfile.txt.gz: This will decompress the file myfile.txt.gz using gzip, creating a new file called myfile.txt.

25. bzip2 – Compress or decompress a file using bzip2.

  • bzip2 myfile.txt: This will compress the file myfile.txt using bzip2, creating a new file called myfile.txt.bz2.
  • bunzip2 myfile.txt.bz2: This will decompress the file myfile.txt.bz2 using bzip2, creating a new file called myfile.txt.

26. xz – Compress or decompress a file using xz.

  • xz myfile.txt: This will compress the file myfile.txt using xz, creating a new file called myfile.txt.xz.
  • unxz myfile.txt.xz: This will decompress the file myfile.txt.xz using xz, creating a new file called myfile.txt.

27. zip – Compress or decompress a file using zip.

  • zip myfile.zip myfile.txt: This will create a zip archive called myfile.zip from the file myfile.txt.
  • unzip myfile.zip: This will extract the contents of the zip archive myfile.zip to the current working directory.

28. chmod – Change the permissions of a file or directory.

  • chmod u+x myfile.sh.
  • chmod g-w mydir: This will remove write permission for the group owner of the directory mydir.

29. chown – Change the owner and/or group of a file or directory.

  • chown user1 myfile.txt: This will change the owner of the file myfile.txt to user1.
  • chown user1:group1 mydir: This will change the owner of the directory mydir to user1 and the group owner to group1.

30. passwd – Change the password of a user.

  • passwd: This will prompt the user to enter and confirm a new password.

31. su – Change the current user to another user.

  • su user1: This will change the current user to user1. The user will be prompted to enter the password for user1 .
  • su -: This will change the current user to the root user. The user will be prompted to enter the root password.

32. sudo – Execute a command as another user, usually the root user.

  • sudo apt-get update : This will update the package list for the package manager apt-get as the root user. The user will be prompted to enter their own password.

33. whoami – Print the current username.

  • whoami: This will print the username of the current user.

34. who – Print information about logged-in users.

  • who: This will print the username, terminal, and login time for all logged-in users.
  • who -u : This will print the username, terminal, and login time for all users with processes on the system.

35. last – Print information about previous logins.

  • last: This will print a list of all previous logins to the system.
  • last -f /var/log/wtmp: This will print a list of all previous logins to the system using the file /var/log/wtmp as the source of the login information.

36. history – Print a list of previously executed commands.

  • history: This will print a list of the previously executed commands for the current user.
  • history -c: This will clear the command history for the current user.

37. echo – Print a message.

  • echo "Hello, world!": This will print the message "Hello, world!".
  • echo $SHELL: This will print the path to the current shell.

38. printf – Print a formatted message.

  • printf "Hello, %s!n" "world": This will print the message "Hello, world!".
  • printf "The value of pi is approximately %.2f.n" 3.14159: This will print the message "The value of pi is approximately 3.14."

39. env – Print the current environment variables.

  • export NEWVAR="hello": This will set the environment variable NEWVAR to the value "hello".
  • export NEWVAR: This will print the value of the environment variable NEWVAR.

40. export – Set an environment variable.

  • env: This will print a list of all the current environment variables and their values.
  • env | grep HOME: This will print the value of the HOME environment variable.

41. unset – Unset an environment variable.

  • unset NEWVAR: This will unset the environment variable NEWVAR, removing it from the environment.

42. set – Set shell options.

  • set -o vi: This will set the vi editing mode for the current shell.
  • set -o noclobber: This will set the noclobber option, which prevents the shell from overwriting files with the > operator.

43. unalias – Remove an alias.

  • alias ll="ls -l": Teate an alias callehis will crd ll that is equivalent to the command ls -l.
  • unalias ll: This will remove the alias ll.

44. source – Execute a script in the current shell.

  • source myscript.sh: This will execute the script myscript.sh in the current shell.
  • env | grep HOME: This will print the value of the HOME environment variable.

45. . – Same as source.

46. exec – Replace the current shell with a command.

  • exec vim: This will replace the current shell with the vim text editor. The user will not be able to return to the original shell unless they exit vim.

47. exit – Exit the current shell.

  • exit: This will exit the current shell.

48. shutdown – Shutdown the system.

  • shutdown -h now: This will shut down the system immediately.
  • shutdown -r +5: This will shut down the system and reboot it in 5 minutes.

50. init – Change the system runlevel.

  • init 0: This will shut down the system.
  • init 6: This will reboot the system.

51. mount – Mount a filesystem.

  • mount /dev/sda1 /mnt: This will mount the filesystem on /dev/sda1 to the mount point /mnt.
  • mount -o ro /dev/sda1 /mnt: This will mount the filesystem on /dev/sda1 to the mount point /mnt in read-only mode.

52. umount – Unmount a filesystem.

  • umount /mnt: This will unmount the filesystem mounted on `/mnt
  • umount -l /mnt: This will "lazy unmount" the filesystem mounted on /mnt, allowing it to be unmounted even if there are open files on the filesystem. fdisk – Modify a disk partition table.

53. disk – Modify a disk partition table.

  • fdisk /dev/sda: This will open the fdisk utility for the disk /dev/sda, allowing the user to create, delete, or modify the partitions on the disk.
  • fdisk -l: This will list the partition table for all disks on the system.

54. mkfs – Create a filesystem.

  • mkfs.ext4 /dev/sda1: This will create an ext4 filesystem on the partition /dev/sda1.
  • mkfs.xfs /dev/sdb2: This will create an xfs filesystem on the partition /dev/sdb2.

55. fsck – Check and repair a filesystem.

  • fsck /dev/sda1: This will check and repair the filesystem on /dev/sda1 if necessary.
  • fsck -a /dev/sdb2: This will check and repair the filesystem on /dev/sdb2 if necessary, automatically fixing any errors that are found.

56. tune2fs – Modify the parameters of an ext2 or ext3 filesystem.

  • tune2fs -l /dev/sda1: This will display the current parameters of the ext2 or ext3 filesystem on /dev/sda1.
  • tune2fs -c 5 /dev/sda1: This will set the maximum number of mount counts before a filesystem check is required to 5 for the ext2 or ext3 filesystem on /dev/sda1.

57. dumpe2fs – Display the superblock and blocks group information of an ext2 or ext3 filesystem.

  • dumpe2fs /dev/sda1: This will display the superblock and blocks group information of the ext2 or ext3 filesystem on /dev/sda1.
  • dumpe2fs -h /dev/sda1: This will display the superblock and blocks group information in a more human-readable format for the ext2 or ext3 filesystem on /dev/sda1.

58. resizefs – Resize an ext2 or ext3 filesystem.

  • resizefs /dev/sda1: This will resize the ext2 or ext3 filesystem on /dev/sda1 to fill the entire partition.
  • resizefs -M /dev/sda1: This will resize the ext2 or ext3 filesystem on /dev/sda1 to the minimum size required to hold the current files.

59. pvdisplay – Display information about physical volumes in a LVM setup.

  • pvdisplay: This will display information about all physical volumes on the system.
  • pvdisplay /dev/sda1: This will display information about the physical volume on /dev/sda1.

60. vgdisplay – Display information about volume groups in a LVM setup.

  • vgdisplay: This will display information about all volume groups on the system.
  • vgdisplay vg01: This will display information about the volume group vg01.

61. lvdisplay – Display information about logical volumes in a LVM setup.

  • lvdisplay: This will display information about all logical volumes on the system.
  • lvdisplay /dev/vg01/lvol1: This will display information about the logical volume lvol1 in the volume group vg01.

62. pvcreate – Create a physical volume in a LVM setup.

  • pvcreate /dev/sda1: This will create a physical volume on /dev/sda1.
  • pvcreate /dev/sdb2 /dev/sdc3: This will create physical volumes on /dev/sdb2 and /dev/sdc3.

63. vgcreate – Create a volume group in a LVM setup.

  • vgcreate vg01 /dev/sda1: This will create a volume group called vg01 using the physical volume on /dev/sda1.
  • vgcreate vg02 /dev/sdb2 /dev/sdc3: This will create a volume group called vg02 using the physical volumes on /dev/sdb2 and /dev/sdc3.

64. lvcreate – Create a logical volume in a LVM setup.

  • lvcreate -L 10G -n lvol1 vg01: This will create a logical volume called lvol1 in the volume group vg01 with a size of 10 GB.
  • lvcreate -l 100%FREE -n lvol2 vg01: This will create a logical volume called lvol2 in the volume group vg01 using all remaining free space in the volume group.

65. pvremove – Remove a physical volume from a LVM setup.

  • pvremove /dev/sda1: This will remove the physical volume on /dev/sda1 from the system.
  • pvremove /dev/sdb2 /dev/sdc3: This will remove the physical volumes on /dev/sdb2 and /dev/sdc3 from the system.

66. vgremove – Remove a volume group from a LVM setup.

  • vgremove vg01: This will remove the volume group vg01 from the system.
  • vgremove vg02 vg03: This will remove the volume groups vg02 and vg03from the system.

67. lvremove – Remove a logical volume from a LVM setup.

  • lvremove /dev/vg01/lvol1: This will remove the logical volume lvol1 from the volume group vg01.
  • lvremove /dev/vg02/lvol2 /dev/vg03/lvol3: This will remove the logical volumes lvol2 and lvol3 from the volume groups vg02 and vg03, respectively.

68. lvresize – Resize a logical volume in a LVM setup.

  • lvresize -L +5G /dev/vg01/lvol1: This will increase the size of the logical volume lvol1 in the volume group vg01 by 5 GB.
  • lvresize -l +100%FREE /dev/vg02/lvol2: This will increase the size of the logical volume lvol2 in the volume group vg02 by the amount of free space in the volume group.

69. lvextend – Extend a logical volume with additional physical volumes in a LVM setup.

  • lvextend -L +5G /dev/vg01/lvol1 /dev/sda1: This will extend the logical volume lvol1 in the volume group vg01 by 5 GB using the physical volume on /dev/sda1.
  • lvextend -l +100%FREE /dev/vg02/lvol2 /dev/sdb2 /dev/sdc3: This will extend the logical volume lvol2 in the volume group vg02 by the amount of free space in the volume group using the physical volumes on /dev/sdb2 and /dev/sdc3.

70. lvreduce – Reduce the size of a logical volume in a LVM setup.

  • lvreduce -L -5G /dev/vg01/lvol1: This will reduce the size of the logical volume lvol1 in the volume group vg01 by 5 GB.
  • lvreduce -l -100%FREE /dev/vg02/lvol2: This will reduce the size of the logical volume lvol2 in the volume group vg02 by the amount of free space in the volume group.

71. mkswap – Create a swap area on a device.

  • mkswap /dev/sda1: This will create a swap area on the partition /dev/sda1.
  • mkswap /dev/sdb2 -L swap01: This will create a swap area on the partition /dev/sdb2 with the label swap01.

72. swapon – Enable a swap area.

  • swapon /dev/sda1: This will enable the swap area on the partition /dev/sda1.
  • swapon -L swap01: This will enable the swap area with the label swap01.

73. swapoff – Disable a swap area.

  • swapoff /dev/sda1: This will disable the swap area on the partition /dev/sda1.
  • swapoff -L swap01: This will disable the swap area with the label swap01.

74. chmod – Change the permissions of a file or directory.

  • chmod 755 file.txt: This will set the permissions of file.txt to rwxr-xr-x.
  • chmod u+x file.sh: This will add execute permission for the owner of file.sh.

75. chown – Change the owner and/or group of a file or directory.

  • chown user1 file.txt: This will set the owner of file.txt to user1.
  • chown user1:group1 file.txt: This will set the owner of file.txt to user1 and the group to group1.

76. chgrp – Change the group of a file or directory.

  • chgrp group1 file.txt: This will set the group of file.txt to group1.
  • chgrp -R group1 dir: This will recursively set the group of all files and directories in dir to group1.

77. umask – Set the default permissions for newly created files and directories.

  • umask 022: This will set the default permissions for newly created files and directories to rw-r--r--.
  • umask 077: This will set the default permissions for newly created files and directories to rwx------.

78. su – Change the current user.

  • su user1: This will switch the current user to user1.
  • su -: This will switch to the root user and also load the root user’s environment.

79. sudo – Execute a command as another user, typically the root user.

  • sudo ls /root: This will execute the ls command as the root user, allowing the user to view the contents of the root user’s home directory.
  • sudo -u user1 command: This will execute command as the user user1.

80. passwd – Change the password for a user.

  • passwd: This will change the password for the current user.
  • passwd user1: This will change the password for the user user1.

81. adduser – Add a new user to the system.

  • adduser user1: This will create a new user called user1.
  • adduser --disabled-password user1: This will create a new user called user1 with a disabled password.

82. deluser – Remove a user from the system.

  • deluser user1: This will remove the user user1 from the system.
  • deluser --remove-home user1: This will remove the user user1 from the system and also delete the user’s home directory.

83. addgroup – Add a new group to the system.

  • addgroup group1: This will create a new group called group1.
  • addgroup --system group1: This will create a new system group called group1.

84. delgroup – Remove a group from the system.

  • delgroup group1: This will remove the group group1 from the system.
  • delgroup --only-if-empty group1: This will only remove the group group1 if it is empty.

85. usermod – Modify a user account.

  • usermod -aG sudo user1: This will add the user user1 to the sudo group, allowing the user to execute commands with sudo.
  • usermod -L user1: This will lock the user user1 account, preventing the user from logging in.

86. groupmod – Modify a group.

  • groupmod -n group2 group1: This will rename the group group1 to group2.
  • groupmod -g 2001 group1: This will change the group ID of group1 to 2001.

87. useradd – Create a new user account.

  • useradd user1: This will create a new user called user1.
  • useradd -m -s /bin/bash user1: This will create a new user called user1 with a home directory and the bash shell.

88. userdel – Delete a user account.

  • userdel user1: This will delete the user user1 from the system.
  • userdel --force --remove user1: This will delete the user user1 from the system, including the user’s home directory and files, and force the deletion even if the user is still logged in.

89. groupadd – Create a new group.

  • groupadd group1: This will create a new group called group1.
  • groupadd -r group1: This will create a new group called group1 and mark it as a system group.

90. groupdel – Delete a group.

  • groupdel group1: This will delete the group group1 from the system.
  • groupdel --force group1: This will delete the group group1 from the system, even if the group is not empty.

91. visudo – Edit the sudoers file.

  • visudo: This will open the sudoers file in the default editor, allowing the user to edit the file.
  • visudo -f /etc/sudoers.d/custom: This will open the custom file in the /etc/sudoers.d directory in the default editor, allowing the user to edit the file.

92. apt – Advanced Package Tool. A package manager for Debian and Ubuntu systems.

  • apt update: This will update the list of available packages and their versions.
  • apt install package1 package2: This will install the packages package1 and package2.
  • apt install package1 package2: This will install the packages package1 and package2.

93. apt-get – Advanced Package Tool. A package manager for Debian and Ubuntu systems

  • apt-get update: This will update the list of available packages and their versions.
  • apt-get install package1 package2: This will install the packages package1 and package2.
  • apt-get remove package1 package2: This will remove the packages package1 and package2 from the system.

94. yum – Yellowdog Updater, Modified. A package manager for CentOS, Fedora, and Red Hat systems.

  • yum update: This will update all installed packages to their latest versions.
  • yum install package1 package2: This will iinstalli the packages package1 and package2.
  • yum remove package1 package2 This will removei the packages package1 and package2 from the system.

95. dnf - Dandified Yum. A package manager for CentOS and Fedora systems.

  • dnf update: This will update all installed packages to their latest versions.
  • dnf install package1 package2: This will install the packages package1 and package2.
  • dnf remove package1 package2: This will remove the packages package1 and package2 from the system.

96. pacman – Package Manager. A package manager for Arch Linux and Manjaro systems.

  • pacman -Syu: This will synchronize the package database and update all installed packages to their latest versions.
  • pacman -S package1 package2: This will install the packages package1 and package2.
  • pacman -R package1 package2: This will remove the packages package1 and package2 from the system.

97. zypper – ZYpp Package Manager. A package manager for openSUSE and SLE systems.

  • zypper update: This will update all installed packages to their latest versions.
  • zypper install package1 package2: This will install the packages package1 and package2.
  • zypper remove package1 package2: This will remove the packages package1 and package2 from the system.

98. apk – Alpine Linux Package Manager. A package manager for Alpine Linux systems.

  • apk update: This will update the package database.
  • apk add package1 package2: This will install the packages package1 and package2.
  • apk del package1 package2: This will remove the packages package1 and package2 from the system.

99. emerge – Gentoo Package Manager. A package manager for Gentoo systems.

  • emerge --update world: This will update all installed packages to their latest versions.
  • emerge package1 package2: This will install the packages package1 and package2.
  • emerge --unmerge package1 package2: This will remove the packages package1 and package2 from the system.

100. pkg – Package Manager. A package manager for FreeBSD systems.

Alright, that’s 100! Hope you find it helpful. Please let me know what you think.

Adhir Potdar

Adhir Potdar

Adhir Potdar, currently serving as the VP of Technology at Bito, brings a rich history of technological innovation and leadership from founding Isana Systems, where he spearheaded the development of blockchain and AI solutions for healthcare and social media. His entrepreneurial journey also includes co-founding Bord Systems, introducing a SaaS platform for virtual whiteboards, and creating PranaCare, a collaborative healthcare platform. With a career that spans across significant tech roles at Zettics, Symantec, PANTA Systems, and VERITAS Software, Adhir's expertise is a blend of technical prowess and visionary leadership in the technology space.

Amar Goel

Amar Goel

Amar is the Co-founder and CEO of Bito. With a background in software engineering and economics, Amar is a serial entrepreneur and has founded multiple companies including the publicly traded PubMatic and Komli Media.

Written by developers for developers

This article was handcrafted with by the Bito team.

Latest posts

PEER REVIEW: A New Video Podcast by Engineers, for Engineers

How Can AI Handle My Large Codebase?

Elevate Code Quality with AI: Write Clean, Maintainable Code

Identifying and Fixing Scalability Issues in Pull Requests

Identifying Security Flaws During Pull Request Reviews with AI

Top posts

PEER REVIEW: A New Video Podcast by Engineers, for Engineers

How Can AI Handle My Large Codebase?

Elevate Code Quality with AI: Write Clean, Maintainable Code

Identifying and Fixing Scalability Issues in Pull Requests

Identifying Security Flaws During Pull Request Reviews with AI

From the blog

The latest industry news, interviews, technologies, and resources.

Get Bito for IDE of your choice