50 Linux Commands for every day use

Created on January 16, 2023 at 11:07 pm

Here are 50 Linux commands that every developer should know, along with a brief description and an example of each command:

  1. ls – Lists the contents of a directory.
    • Example: ls will list the contents of the current directory. ls /usr/local will list the contents of the /usr/local directory.
  2. pwd – Prints the current working directory.
    • Example: pwd will print the full path of the current working directory.
  3. cd – Changes the current working directory.
    • Example: cd /usr/local will change the current working directory to /usr/local.
  4. mkdir – Creates a new directory.
    • Example: mkdir mydir will create a new directory called mydir.
  5. mv – Moves a file or directory.
    • Example: mv file.txt /usr/local/ will move the file file.txt to the /usr/local directory.
  6. cp – Copies a file or directory.
    • Example: cp file.txt /usr/local/ will copy the file file.txt to the /usr/local directory.
  7. rm – Removes a file or directory.
    • Example: rm file.txt will remove the file file.txt, while rm -r mydir will remove the directory mydir and all of its contents.
  8. touch – Creates a new empty file.
    • Example: touch file.txt will create a new empty file called file.txt.
  9. ln – Creates a link to a file or directory.
    • Example: ln -s /usr/local/file.txt file.txt will create a symbolic link to /usr/local/file.txt called file.txt in the current directory.
  10. cat – Displays the contents of a file.
    • Example: cat file.txt will display the contents of the file file.txt in the terminal.
  11. clear – Clears the terminal screen.
    • Example: clear will clear the contents of the terminal screen.
  12. echo – Prints a message to the terminal.
    • Example: echo "Hello, world!" will print the message "Hello, world!" to the terminal.
  13. less – Views a file with pagination.
    • Example: less file.txt will allow you to view the contents of file.txt one page at a time.
  14. man – Displays the manual page for a command.
    • Example: man ls will display the manual page for the ls command, which describes its usage and options.
  15. uname – Displays information about the current system.
    • Example: uname -a will display all information about the current system, including the kernel version and machine hardware name.
  16. whoami – Displays the current user.
    • Example: whoami will display the username of the current user.
  17. tar – Archives and compresses files and directories.
    • Example: tar -czf archive.tar.gz directory/ will create a compressed archive called archive.tar.gz from the contents of the directory directory.
  18. grep – Searches for a pattern in a file.
    • Example: grep "error" log.txt will search the file log.txt for the pattern "error" and print any lines that match.
  19. head – Displays the first few lines of a file.
    • Example: head -n 10 file.txt will display the first 10 lines of file.txt.
  20. tail – Displays the last few lines of a file.
    • Example: tail -n 10 file.txt will display the last 10 lines of file.txt.
  21. diff – Compares the differences between two files.
    • Example: diff file1.txt file2.txt will compare the contents of file1.txt and file2.txt and print the differences between them.
  22. cmp – Compares the contents of two files byte by byte.
    • Example: cmp file1.txt file2.txt will compare the contents of file1.txt and file2.txt byte by byte and report any differences.
  23. comm – Compares the contents of two sorted files line by line.
    • Example: comm file1.txt file2.txt will compare the contents of file1.txt and file2.txt, which should both be sorted, and print the lines that are unique to each file.
  24. sort – Sorts the lines of a file.
    • Example: sort file.txt will sort the lines of file.txt alphabetically.
  25. export – Exports a shell variable.
    • Example: export VARNAME="value" will create a shell variable called VARNAME with the value "value".
  26. zip – Compresses files into a ZIP archive.
    • Example: zip archive.zip file1.txt file2.txt will create a ZIP archive called archive.zip containing the files file1.txt and file2.txt.
  27. unzip – Extracts files from a ZIP archive.
    • Example: unzip archive.zip will extract the contents of the archive.zip ZIP archive.
  28. ssh – Connects to a remote server using the SSH protocol.
    • Example: ssh [email protected] will connect to the server at example.com as the user user.
  29. service – Controls system services.
    • Example: service apache2 start will start the Apache web server.
  30. ps – Displays information about running processes.
    • Example: ps aux will display a list of all running processes and their resource usage.
  31. kill – Sends a signal to a process to terminate it.
    • Example: kill 12345 will send the signal to terminate the process with the process ID 12345.
  32. killall – Terminates all processes with a specified name.
    • Example: killall firefox will terminate all processes with the name firefox.
  33. df – Displays information about available disk space on mounted filesystems.
    • Example: df -h will display the available disk space in a human-readable format (e.g., in gigabytes or megabytes).
  34. mount – Mounts a filesystem.
    • Example: mount /dev/sda1 /mnt/mydisk will mount the partition /dev/sda1 at the mount point /mnt/mydisk.
  35. chmod – Changes the permissions of a file or directory.
    • Example: chmod 755 file.txt will give read, write, and execute permissions to the owner and read and execute permissions to everyone else for the file file.txt.
  36. chown – Changes the ownership of a file or directory.
    • Example: chown user:group file.txt will change the owner of file.txt to user and the group ownership to group.
  37. ifconfig – Configures network interface parameters.
    • Example: ifconfig eth0 up will enable the network interface eth0.
  38. traceroute – Traces the path of packets to a destination.
    • Example: traceroute example.com will trace the path of packets from the current system to the destination example.com.
  39. wget – Downloads a file from the internet.
    • Example: wget https://example.com/file.zip will download the file file.zip from https://example.com.
  40. ufw – A frontend for managing a firewall.
    • Example: ufw allow ssh will allow incoming connections to the SSH service.
  41. iptables – A firewall management tool for Linux.
    • Example: iptables -A INPUT -p tcp --dport 80 -j ACCEPT will allow incoming connections to TCP port 80 (the default port for HTTP).
  42. apt – A package manager for Debian-based systems.
    • Example: apt update will update the list of available packages.
  43. sudo – Allows a user to run a command with the privileges of the superuser (root).
    • Example: sudo apt update will update the list of available packages with root privileges.
  44. cal – Displays a calendar.
    • Example: cal will display the current month’s calendar.
  45. alias – Creates an alias for a command.
    • Example: alias ll='ls -alF' will create an alias ll that runs the command ls -alF.
  46. dd – Copies data from one location to another.
    • Example: dd if=/dev/sda of=disk.img will create an image file called disk.img of the contents of the device /dev/sda.
  47. whereis – Shows the locations of a command.
    • Example: whereis ls will show the locations of the ls command on the system.
  48. whatis – Shows a short description of a command.
    • Example: whatis ls will show a short description of the ls command.
  49. top – Displays information about running processes.
    • Example: top will display a list of running processes and their resource usage in real-time.
  50. passwd – Changes the password for a user.
    • Example: passwd user1 will prompt you to enter and confirm a new password for the user user1.
Connecting to lzomedia.com... Connected... Page load complete