Skip to main content

Command Palette

Search for a command to run...

Day 3 Task - Basic linux commands

Published
β€’4 min read
Day 3 Task  -  Basic linux commands

Table of contents

Introduction

  1. To view what's written in a file.πŸ‘€

  2. To change the access permissions of files.πŸ“’

  3. To check which commands you have run till now.🧧

  4. To remove a directory/ Folder.🧿

  5. To create a fruits.txt file and to view the content.πŸ‘€

  6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.πŸπŸπŸ’

  7. To Show only top three fruits from the file.πŸ“ƒ

  8. To Show only bottom three fruits from the file.🧧

  9. To create another file Colors.txt and to view the content.πŸ“•

  10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.πŸ§§πŸ“πŸ₯‘πŸŒΆ

  11. 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!

More from this blog

Untitled Publication

7 posts