Skip to content

Instantly share code, notes, and snippets.

@rambabu-patidar
Created February 27, 2026 19:27
Show Gist options
  • Select an option

  • Save rambabu-patidar/63f48783eb5586a754833bec00b4d565 to your computer and use it in GitHub Desktop.

Select an option

Save rambabu-patidar/63f48783eb5586a754833bec00b4d565 to your computer and use it in GitHub Desktop.
Learning Linux Commands

Linux Notes(TechWorld with NANA)

These notes move from basic commands to more advanced command composition. The goal is to understand how simple commands combine to form powerful pipelines.


Basic Shell Symbols

.

Represents the current working directory.


-

Used to pass optional parameters (flags) to commands to modify their behavior.

Example: ls -R


|

Pipe operator.

Used to chain commands together.
The output of the command on the left becomes the input of the command on the right.


*

Wildcard character.

Matches any number of characters in filenames.

Example: rm *.cpp


xargs

Takes the output from the left side of a pipe and passes it as arguments to the command on the right, one by one.


>

Output redirection.

Sends the standard output of a command into a file.
Overwrites the file if it already exists.


>>

Output redirection (append).

Appends output to a file if it exists.
Creates the file if it does not exist.


\

Escape character.

Forces the shell to treat the next character literally.


;

Command separator.

Marks the end of one command and begins another.

Example: mkdir test; cd test


{}

Placeholder used with the -exec option of the find command.
Represents the currently matched file.

Must be followed by \;


Commands (Building from Simple to Advanced)

1. ls

Lists files and directories in the current working directory.


2. ls <folder_name>

Lists files and directories inside the specified folder.


3. ls -R

Lists files and directories recursively (includes subdirectories).


4. find . -type d

Lists only directories inside the current directory (recursively).
Does not list files.


5. grep ""

Filters input and prints lines containing the given string.

Used mostly with pipes.


6. find . -type f -name "*.cpp"

Finds all files in the current directory (recursively)
that:

  • are regular files (-type f)
  • have extension .cpp

7. cat <file_path>

Prints the content of a file to the terminal.


8. find . -type f -name "*.cpp" | xargs cat

Step-by-step logic:

  • find gets all .cpp files
  • xargs passes each file to cat
  • cat prints their content

This is the first example of command chaining.


9. find . -type f -name "*.cpp" | xargs cat | grep "int"

Building further:

  • Find all .cpp files
  • Print their content
  • Filter only lines containing the word "int"

This shows how commands combine progressively.


10. sort

Sorts input lexicographically (alphabetical order).


11. sort -k3

Sorts lines based on the third column (field).


12. uniq

Removes duplicate consecutive lines.
Best used after sort.


13. uniq -f3

Skips the first three fields and checks uniqueness starting from the fourth field.


14. mkdir <folder_path>

Creates a directory in the specified path.


15. cp <src_directory> <dest_directory>

Copies files or directories from source to destination.


16. find . -type f -name "*.cpp" -exec rsync -R {} <dest_folder> ;

Step-by-step logic:

  • find locates .cpp files
  • -exec runs a command on each file
  • {} represents the current file
  • rsync -R copies files while preserving directory structure
  • \; marks the end of the exec command

This is a more advanced way to operate on matched files.


17. rm *.cpp

Removes all files ending with .cpp in the current directory.

Uses wildcard *.

Be careful — deletion is permanent.


Key Idea

Linux becomes powerful when you combine small, simple commands:

find → pipe → process → filter → sort → unique → redirect

Understanding composition is more important than memorizing commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment