- The path command in Linux displays the list of directories that the shell searches for executable programs.
- This information is important for the shell to know where to find the program you want to run.
This output shows that the shell will search for programs in the following directories:
If you type a program name at the command prompt without specifying its full path, the shell will search each of these directories in order until it finds the program.
- The pwd command in Linux stands for “print working directory.”
- It displays the absolute path of the current directory you are working in.
This output shows that the current working directory is /home/bard.
- The wc command in Linux stands for “word count.”
- It counts the number of lines, words, and bytes in a file or files.
$ wc file.txt
10 25 123 file.txt
This output shows that the file file.txt has:
- 10 lines
- 25 words
- 123 bytes
You can also use the wc command with options to count specific types of characters or bytes.
$ wc -c file.txt
This output shows that the file file.txt has 123 bytes.
The wc command is a versatile tool that can be used for a variety of tasks, such as checking the size of a file, counting the number of lines in a code file, or checking the number of words in a document.
grep is used to search for lines in a file that match a specified pattern. It is a powerful tool for filtering and analyzing text data.
$ grep "error" file.txt
This command searches the file file.txt for lines containing the word “error”.
Line 10: An error occurred while processing the data.
Line 25: Error: File not found.
echo is used to print text to the standard output. It is a simple but versatile command with various use cases.
$ echo "Hello, world!"
This command will print the text “Hello, world!” to the console.
cat is used to read and display the contents of one or more files. It can also be used to concatenate files.
$ cat file1.txt file2.txt
This command will display the contents of both file1.txt and file2.txt consecutively.