Day 3 Task - Basic linux commands

Table of contents
Introduction
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.πππ
To Show only top three fruits from the file.π
To Show only 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 file.π
Introduction
Welcome to day3 of #90daysofdevopschallange let's explore the new commands of linux which is makes learning very easierπnow we move towards are next level of linux learning. so let's go!ππ
1. To view what's written in a file π
To view the content of files we use "cat" cammand.
eg. you create a file new.txt and want to know what's written in file type cat new.txt

2. To change the access permissions of files π
Change in access permission of file is done by using "chmod" Command.
In linux there three permission of every file i.e. read(r), write(w), execute(x).also we can give permission to user in user, group and other manner.
Syntax for change access permission in file
chmod <u,g,o><+,-,=><r,w,x> <filename>
u : owner permission + : add permission
g : group permission - : remove permission
o : other user permission = : assign permission
suppose we have file new.txt, this file has no execute permission so we can assign permission to execute the file.

3. To check which commands you have run till now π
To view our command whatever we are run on our linux terminal we use "history" command.

4. To remove a directory/ Folder ποΈ
To remove the directory we have to create directory using "mkdir" command.and for removing the directory we are using rmdir command.
Note : Don't use rm -rf command it will delete forcefully your all valuable data.

5. To create a fruits.txt file and to view the content π
To create file we use "touch" command then to view the content of file we are using "cat" command.

6. Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guavaπππ
We can use "vi editor" to enter the fruits name.

Now your fruits.txt files filled with fruitsππ₯ππππ
7. To Show only top three fruits from the fileπππ
To display only the top three fruits from the "fruits.txt" file, you can use the "head" command with the "-n" option, specifying the number of lines you want to see. In this case, we want to see the first three lines, which represent the top three fruits in the file. ππ₯π

8. To Show only bottom three fruits from the fileππ
To display only the bottom three fruits from the "fruits.txt" file, you can use the "tail" command with the "-n" option, specifying the number of lines you want to see from the end of the file. In this case, we want to see the last three lines, which represent the bottom three fruits in the file. π₯ππ

9. To create another file Colors.txt and to view the content π
To create the file colors.txt we are using "touch" command which creates empty file. to view the contents of file we use "cat" command.

10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey βͺβ«π΅
Vi editor is used to add colors nameβ€π in file and to view the content we are using cat command.

11. To find the difference between fruits.txt and Colors.txt file πππ
To find the difference between the contents of two files, such as "fruits.txt" and "Colors.txt," you can use the "diff" command. Here's an example,

ππππ¨ This command will compare the contents of "fruits.txt" and "Colors.txt" files. If there are any differences between the two files, the diff command will show them in the output.
With the diff command, you can easily spot the variations between two files and manage your data more efficiently. ππ
Conclusion
π We are completed are essential linux commands list. In which we are using cat, head, tail command in various aspects.π by using the cat, more, less command you are effectively and easily read the files and creating the files. π You've even created "fruits.txt" and "Colors.txt" and learned to display top and bottom items with "head" and "tail." The "diff" command aids in identifying file differences. πππPractice this linux commands and makes linux more easy.π
stay connect with my latest articles on linuxπAWSβ and Devops Blog.
Thank you for readingπ Keep learning and Keep growing!



