50 Useful Linux Commands

Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. The following is a list of 50 useful Linux commands:

50 Useful Linux Commands
Photo by Gabriel Heinzer / Unsplash

Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds.

The following is a list of 50 useful Linux commands:

  1. ls: list files and directories in the current directory.
  2. cd: change the current directory.
  3. pwd: print the current working directory.
  4. mkdir: create a new directory. For example, to create a new directory called "mydir", you would use the following command: mkdir mydir
  5. rm: remove files or directories. By default, it does not prompt for confirmation before deleting files, so it should be used with caution. For example, to remove a file called "myfile", you would use the following command: rm myfile
  6. cp: copy files or directories. For example, to copy a file called "myfile" to a new location called "mydir", you would use the following command: cp myfile mydir/
  7. mv: move or rename files or directories. It can also be used to rename files and directories. For example, to move a file called "myfile" to a new location called "mydir", you would use the following command: mv myfile mydir/
  8. cat: concatenate files and print on the standard output. For example, to display the contents of a file called "myfile", you would use the following command: cat myfile
  9. grep: search for a specific pattern in a file. It can be used with various options to perform different types of searches. For example, to search for the word "hello" in a file called "myfile", you would use the following command: grep hello myfile
  10. sed: stream editor for filtering and transforming text. For example, to replace all occurrences of "foo" with "bar" in a file called "myfile.txt", you could use the following command: sed 's/foo/bar/g' myfile.txt
  11. awk: pattern scanning and processing language. For example, to print the second field of a file called "myfile.csv", which is separated by commas, you could use the following command: awk -F ',''{print $2}' myfile.csv
  12. ssh: secure shell protocol for remote access. For example, to connect to a remote computer with the IP address "192.168.1.100" as the user "myuser", you could use the following command: ssh myuser@192.168.1.100
  13. scp: secure copy protocol for transferring files securely over a network. For example, to copy a file called "myfile.txt" from the local computer to a remote computer with the IP address "192.168.1.100" as the user "myuser", you could use the following command: scp myfile.txt myuser@192.168.1.100:/path/to/destination/
  14. tar: archiving utility for creating and manipulating tar archives.
  15. gzip: compression utility for compressing files.
  16. gunzip: decompression utility for decompressing gzip files.
  17. df: report file system disk space usage. For example, to display information about the available disk space on the system, you could use the following command: df -h
  18. du: estimate file space usage. For example, to display the disk usage of all files and directories in the current directory, you could use the following command: du -h
  19. top: display system processes in real time.
  20. ps: report a snapshot of the current processes. For example, to display information about all processes running on the system, you could use the following command: ps aux
  21. kill: send a signal to a process to terminate it.
  22. ping: test the reachability of a network host.
  23. ifconfig: configure network interfaces. For example, to display information about all network interfaces on the system, you could use the following command: ifconfig -a
  24. route: show or manipulate the IP routing table.
  25. netstat: print network connections, routing tables, and interface statistics.
  26. traceroute: print the route packets take to network host.
  27. ssh-keygen: generate, manage and convert authentication keys.
  28. useradd: create a new user account. For example, to add a new user called "myuser", you could use the following command: useradd myuser
  29. passwd: change user password.
  30. sudo: execute a command with superuser privileges.
  31. chown: change ownership of a file or directory. For example, to change the ownership of a file called "myfile.txt" to the user "myuser", you could use the following command: chown myuser myfile.txt
  32. chmod: change file mode bits. For example, to give read, write, and execute permissions to the owner of a file called "myfile", you would use the following command: chmod u+rwx myfile
  33. find: search for files and directories. For example, to find all files in the current directory and its subdirectories that have the extension ".txt", you could use the following command: find . -name '*.txt'
  34. locate: The locate command is used to search for files and directories that match a specified pattern. It is faster than the find command but may not show the most recent results. For example, to find all files in the system that contain the word "example", you could use the following command: locate example
  35. diff: compare two files. For example, to compare the contents of two files called "file1.txt" and "file2.txt", you could use the following command: diff file1.txt file2.txt
  36. tar: archiving utility for creating and manipulating tar archives.
  37. uname: print system information. For example, to display the name of the operating system, you could use the following command: uname -s
  38. uptime: show how long the system has been running.
  39. history: display the command history.
  40. echo: display a message on the standard output.
  41. date: print or set the system date and time.
  42. sleep: pause for a specified amount of time.
  43. head: output the first part of files.
  44. tail: output the last part of files. For example, to display the last 10 lines of a file called "myfile.txt", you could use the following command: tail -n 10 myfile.txt
  45. wc: print the number of lines, words, and bytes in a file. For example, to count the number of lines in a file called "myfile.txt", you could use the following command: wc -l myfile.txt
  46. sort: sort lines of text files. For example, to sort the lines in a file called "myfile.txt" in alphabetical order, you could use the following command: sort myfile.txt
  47. cut: remove sections from each line of a file.
  48. paste: merge lines of files.
  49. tee: read from standard input and write to standard output and files. For example, to display the output of a command called "mycommand" on the terminal and also save it to a file called "output.txt", you could use the following command: mycommand | tee output.txt
  50. alias: create or display command aliases. For example, to create an alias called "ll" for the "ls -l" command, you could use the following command: alias ll='ls -l' After creating this alias, you could use the "ll" command to display a long listing of the files in the current directory.