100 Linux Errors & Solution With Explanation
1. Error: Permission denied
Example command:
$ sudo rm /etc/sensitive_file
Solution: This error occurs when a user tries to execute a command that requires higher privileges than what they currently have. The solution is to use the sudo command before the original command to execute it with superuser privileges.
Corrected command:
$ sudo rm /etc/sensitive_file
2. Error: Command not found
Example command:
$ some_command
Solution: This error indicates that the system cannot find the specified command or program in the directories listed in the PATH environment variable. The solution is to either provide the full path to the command or check if the command is installed and available in the system’s PATH.
Corrected command (if the command is installed):
$ /path/to/some_command
Or install the command if it’s missing:
$ sudo apt-get install some_package
3. Error: File or directory not found
Example command:
$ cat /path/to/nonexistent_file
Solution: This error occurs when the specified file or directory does not exist in the given path. To resolve this issue, ensure that the file or directory exists or provide the correct path.
Corrected command: Ensure the file exists or provide the correct path.
4. Error: Syntax error near unexpected token
Example command:
$ for i in {1..5}
Solution: This error typically occurs in scripts when there’s a syntax error. In this example, it could be due to a missing do keyword after the loop declaration. Check the syntax of the command or script and correct any errors accordingly.
领英推荐
Corrected command:
$ for i in {1..5}; do echo $i; done
5. Error: Segmentation fault (core dumped)
Example command:
$ ./my_program
Solution: A segmentation fault occurs when a program tries to access memory that it doesn’t have permission to access. This could be due to a bug in the program. To fix this, you’ll need to debug the program’s source code to identify and fix the issue causing the segmentation fault.
Corrected solution: Debug the program’s source code to identify and fix the issue causing the segmentation fault.
6. Error: Unable to resolve host
Example command:
$ ping nonexistent_host
Solution: This error indicates that the DNS resolver cannot resolve the hostname to an IP address. Check the hostname spelling and verify DNS configuration in /etc/resolv.conf. Additionally, ensure that the host is reachable and DNS servers are configured correctly.
Corrected command: Check hostname spelling and DNS configuration.
7. Error: Connection refused
Example command:
$ ssh user@remote_host
Solution: This error occurs when the remote server actively refuses a connection
attempt. Check if the SSH service is running on the remote host and ensure that you have the correct credentials and permissions to access it.
Corrected solution: Ensure SSH service is running on the remote host and credentials are correct.
Example command:
$ touch /mnt/full_disk/file
Solution: This error indicates that the filesystem where the command is trying to
write does not have enough space left. You need to free up space on the device or allocate more space to the filesystem.
Corrected solution: Free up space on the device or allocate more space to the
filesystem.