Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Commands

1. man: Displays the manual pages of a command. It provides information about command usage, options,
and examples.
2. pwd: Prints the current working directory. It shows the path of the directory you're currently in.
3. cd: Changes the current directory. It allows navigation between different directories.
4. ls: Lists directory contents. It shows the files and directories within the current directory.
5. clear: Clears the terminal screen. It removes all previous commands and output from the terminal
window.
6. mkdir: Creates a new directory. It is used to make a new folder or directory.
7. rmdir: Removes an empty directory. It deletes a directory if it's empty.

For Nano Editor:

1. Copy and Paste Text:


Use yy to copy a line and p to paste it.
Navigate to the desired line, copy it with yy , move to the bottom, and paste with p .
2. Undo Previous Modification:
Press Ctrl + R or use the Undo shortcut to revert the last change.
3. Replace Text with Prompts:
Navigate to the top of the file and initiate replace with Ctrl + .
Enter the text to find ("514") and its replacement ("1024").
Respond to each prompt with "y" for yes or "n" for no.
4. Search and Add Text:
Use Ctrl + W to search for "kernel" at line 1.
Move to the end of the line and insert text as needed.
5. Exit without Saving:
Press Ctrl + X to exit.
Choose "N" for "No" when prompted to save changes.

For Vi Editor:

1. Copy and Paste Text:


Press yy to copy a line and p to paste it.
Navigate to line 12, copy three lines with 3yy , move to the bottom, and paste with p .
2. Undo Previous Modification:
Press u to undo the last change made.
3. Replace Text with Prompts:
Use :%s/514/1024/gc to replace "514" with "1024" with prompts for each occurrence.
Respond to prompts with "y" for yes or "n" for no.
4. Search and Add Text:
Search for "kernel" with /kernel .
Move to the end of the line and insert text as needed.
5. Exit without Saving:
Press Esc to ensure you're in command mode.
Type :q! and press Enter to exit without saving changes.
6. File/directory management:
ls -l : Displays detailed information about files and directories.
ls -R : Recursively lists subdirectories.
ls -a : Shows hidden files and directories.
cp -r : Copies directories recursively.
mv : Used for renaming files or moving them to a different directory.
7. Wild Cards:
* : Represents any string of characters (including an empty string).
? : Represents any single character.

8. Useful keyboard shortcuts:


None mentioned explicitly but commonly used in terminal navigation and editing.
9. Running Commands Sequentially, Redirection, Piping:
> : Redirects output to a file, overwriting existing content.
>> : Redirects output to a file, appending to existing content.
< : Redirects input from a file.
| : Pipes the output of one command as input to another.
10. Basic operations on text files:
None mentioned explicitly, but common commands used such as less , head , tail , wc , and
grep have various options for controlling output.
11. File compression:
tar -cvf : Creates a new tar archive (with verbose output).
tar -tf : Lists the contents of a tar archive.
tar -czf : Creates a compressed tar archive (with gzip compression).
tar -xzf : Extracts files from a compressed tar archive.

12. -i, --ignore-case: Ignores case distinctions in both the pattern and input files. This allows searching
without differentiating between uppercase and lowercase letters.
13. -n, --line-number: Prefixes each line of output with the 1-based line number within its input file.
14. -C NUM, --context=NUM: Prints NUM lines of leading and trailing context surrounding each match. This
shows additional context around the matched lines.
15. -r, --recursive: Recursively searches subdirectories. This option is typically used when searching within
directories for specific patterns.
16. -l, --files-with-matches: Suppresses normal output and instead prints the names of files containing
matches.
17. -v, --invert-match: Inverts the sense of matching, selecting non-matching lines.
18. -w, --word-regexp: Searches for the expression as a whole word. This ensures that matches are not part
of larger words.
19. -E, --extended-regexp: Interprets the pattern as an extended regular expression (ERE). This provides
more powerful pattern matching capabilities.
20. Command alias:
alias : Lists or sets aliases.
alias -p : Prints all defined aliases.
alias [name]='[value]' : Defines a new alias.
21. Command sort:
sort : Sorts lines of text files.
sort -f : Performs a case-insensitive sort.
sort -n : Sorts numerically.
sort -r : Sorts in reverse order.
sort -u : Removes duplicate lines.
sort -t ',' : Specifies the delimiter in CSV files.
sort -k : Sorts based on a specific column.

22. Command cut:


cut : Extracts specific sections from each line of a file.
cut -f : Selects specific fields.
cut -b : Selects specific bytes or characters.
cut -d : Specifies a delimiter.

You might also like