Day3 - Basic Linux Command
Mastering the Linux Command Line: Essential Commands for Efficient Navigation
Table of contents
- To view what's written in a file.
- To change the access permissions of files.
- To check which commands you have run till now.
- To remove a directory/ Folder.
- To create a fruits.txt file and to view the content.
- Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
- Show only the top three fruits from the file.
- Show only the bottom three fruits from the file.
- To create another file Colors.txt and to view the content.
- Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
- To find the difference between fruits.txt and Colors.txt files.
Task: What is the Linux command to
To view what's written in a file.
Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives its content as output. It helps us to create, view, and concatenate files.
cat file_name
To change the access permissions of files.
There are three kinds of file permissions in Linux:
Read (r): Allows a user or group to view a file.
Write (w): Permits the user to write or modify a file or directory.
Execute (x): A user or group with execute permissions can execute a file or view a directory.
chmod u+rwx new_file.txt
To check which commands you have run till now.
The history command in Linux is a built-in shell tool that displays a list of commands used in the terminal session. history allows users to reuse any listed command without retyping it.
To remove a directory/ Folder.
To delete a directory with "rmdir", type the command followed by the name of the directory you want to remove. For example, to delete a directory named "directory1" you would type:
rmdir directory1
To create a fruits.txt file and to view the content.
vim fruits.txt
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
Show only the top three fruits from the file.
Use the Unix head command to read the first few lines of an input file and send them to standard output (that is, your terminal screen). The format for the head command is:
head -3 fruits.txt
Show only the bottom three fruits from the file.
Use the Unix tail command to read the last few lines of an input file and send them to standard output (that is, your terminal screen). The format for the tail command is:
tail -3 fruits.text
To create another file Colors.txt and to view the content.
vim colors.txt
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt files.
Use the "diff" command to compare text files. It can compare single files or the contents of directories.
diff fruits.txt colors.txt
Stay in the loop with my latest insights and articles on cloud โ๏ธ and DevOps ๐ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.