0% found this document useful (0 votes)
78 views5 pages

Linux Commands Hamza

Uploaded by

ghulamhamzaa10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views5 pages

Linux Commands Hamza

Uploaded by

ghulamhamzaa10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

LINUX COMMANDS AND THEIR USE

1-Find:
The find command in Linux is a powerful utility used to search for files and directories within a specified directory hierarchy based on various
criteria. It's one of the most versatile tools available for file searching and manipulation on Unix-like operating systems. Here's a brief overview
of its usage and functionalities: The basic syntax of the find command is : find [path...] [expression] You can use find to search for files or directories
based on their names. : find /path/to/search -name "filename"

“find” allows you to search for files based on their type, such as regular files, directories, symbolic links, etc. find /path/to/search -type f. This command
will search for regular files under the specified path.

2-Which:
The which command in Linux is used to locate the executable file associated with a given command by searching through directories listed in the user's
PATH environment variable. It helps to determine the full path of the executable file that would be executed if the command were run. Basic Usage: Simply
provide the command name as an argument to which: which command_name

For example: “which ls “ This command will output the full path to the ls command, typically /bin/ls.
3-Whereis:
The whereis command is used to locate the binary, source, and manual page files for a specified command. It searches standard binary directories and
manual page directories. It's primarily used to find the locations of executable files, source code, and manual pages related to a command. whereis ls This
command will output the locations of the ls command binary, its source code (if available), and its manual page.

4-Locate:
The locate command is used to find files by name quickly. It works by searching a pre-compiled index of file names generated by the updatedb command
(usually run periodically by the system). It's much faster than find but might not find files created after the last database update..

locate filename_pattern

Example: locate [Link] This command will output the path(s) to any file(s) with the name [Link].
5-Grep:
The grep command is used for searching text or regular expressions inside files or input streams. It stands for "Global Regular Expression Print." It's one of the
most powerful and commonly used utilities in Unix-like operating systems for text [Link] filename_pattern

Example grep "keyword" [Link] This command will search for occurrences of the word "keyword" in the file [Link]

6-Sort:
The sort command is used to sort lines of text files or data streams. It arranges the lines alphabetically by default, but it can also perform numeric or custom
sorting. Example sort [Link] This command will sort the contents of [Link] alphabetically.
7-Cmp:
The cmp command is used to compare two files byte by byte and display the first mismatch. It's particularly useful for binary files or non-text files.

Example cmp [Link] [Link] This command will compare [Link] and [Link] and output the first byte where they differ, if any.

8-Diff:
The diff command is used to compare two text files line by line and report the differences between them. It's commonly used for finding changes made to
files, especially in software development. diff file1 file2

Example diff [Link] [Link] This command will output the differences between [Link] and [Link] line by line.

You might also like