Day 3 Tasks: 3/90 Days

Day 3 Tasks: 3/90 Days


Day 3 Task: Basic Linux Commands

Task: What is the linux command to

  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.

Answer 1)

┌──(root?kali)-[~]

└─# cat abcd.txt

Hello my name is pranav

--------------------------

there are two types we can change permission of files in linux

1)=> first is by using charter symbols

> 'r' for read 'w' for write 'x' for execute

> there are three types of permission to particular user , group and public

> with each having 3 type of permission read,write,execute

> we have to give evry individual so it contains

9 fields 3 for each usertype

> first 3 for user , seccond 3 fields for group and last 3

fields for public access

> so we give first initials to specify the type of user

> o=public access/others

> g=group

> u=user

> a=all

ex: 1)we want to give only read permission to user we write cmd as follows and

2)if we want to give some permission for all we write

1)=> #chmod +r filename

2)=> #chmod +rwrwrw filename //here we gave only needed permission with combinations of user group and public

--------------

Answer 2)

before::

-rwxr-xr-x 1 root root 24 Feb 20 10:13 abcd.txt

so output::

┌──(root?kali)-[~]

└─# chmod a+rwx abcd.txt

op::mode of 'abcd.txt' retained as 0777 (rwxrwxrwx)

---------------------------------------------------

now seocnd way is by giving number system for permission

as follows"

here are only 3 fields

first=user/owner

second=group

third=public/other access

number-system is :: 4=read ,2=write ,1=execute

so its combination of 7

if we gave 777 it means all permissions granted

like wise..

---------------------------

Answer 3)

history command is used to get the history of commands

or to search specific command press ctrl + r multiple times or single time and search for command used

┌──(root?kali)-[~]

└─# history

1 hostname screamy

2 pwd

3 su kali

4 exit

5 touch abcd.txt

6 ls

7 vim abcd.txt

8 cat abcd.txt

9 ls -all

10 chmod -g +rwx abcd.txt

11 chmod a+rwx abcd.txt

22 chmod -v a+rwx abcd.txt

-----------------

Answer 4)

to remove directory or folder we use

rm -r path_ordir_name-------------here -r means recursive as a dir can contain multiple files in it

rm-rf path ---------used to delete/ remove dir or file without permission

::┌──(root?kali)-[~]

└─# rm -vr abcd/bb

removed directory 'abcd/bb'

--------------

aNSER 5)

┌──(root?kali)-[~]

└─# touch fruits.txt

┌──(root?kali)-[~]

└─# vim fruits.txt

┌──(root?kali)-[~]

└─# cat fruits.txt

abcddasdnandasndad

asdadasda

w

------------------

aNSWER 6)

──(root?kali)-[~]

└─# vim devops.txt

--file created above and save using wq!

--first three line to be printed

Answer 7)

┌──(root?kali)-[~]

└─# head -3 devops.txt

Apple

mango

banana

-------------------------------

Answer 8)

---last three content of file

┌──(root?kali)-[~]

└─# tail -3 devops.txt

kiwi

orange

guava

------------------

Answer 9)and 10)

┌──(root?kali)-[~]

└─# vim colors.txt

--added content and created too

--to show content used cat cmd

┌──(root?kali)-[~]

└─# cat colors.txt

red

pink

white

black

blue

orange

purple

grey

---------------------

Answer 11)

┌──(root?kali)-[~]

└─# diff fruits.txt colors.txt

1,3c1,9

< abcddasdnandasndad

< asdadasda

< w

---

> red

> pink

> white

> black

> blue

> orange

> purple

> grey

>


要查看或添加评论,请登录

Pranav Lahitkar的更多文章

  • LINUX BOOT PROCESS

    LINUX BOOT PROCESS

    Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login…

  • DevOps tools: Jenkins and GitLab CI/CD.

    DevOps tools: Jenkins and GitLab CI/CD.

    Let's compare two popular DevOps tools: Jenkins and GitLab CI/CD. ### Jenkins 1.

    2 条评论
  • TOP 3 Cloud service providers comparison

    TOP 3 Cloud service providers comparison

    Let's compare the top three cloud service providers: Amazon Web Services (AWS), Microsoft Azure, and Google Cloud…

  • Role of Automation in DevOps

    Role of Automation in DevOps

    Introduction DevOps, a cultural and technical movement within organizations, emphasizes collaboration, integration, and…

    2 条评论
  • Myths About DevOps as a Career

    Myths About DevOps as a Career

    Introduction Title: Understanding DevOps: Myths and Realities Introduction: Brief overview of DevOps and its…

    1 条评论
  • Title: Ensuring Cloud Security: Best Practices and Steps to Achieve Them

    Title: Ensuring Cloud Security: Best Practices and Steps to Achieve Them

    First of all here are some basic terminologies in cloud security: Here are explanations of some important terminologies…

    3 条评论
  • Title:Ansible: Automating IT Infrastructure with Ease

    Title:Ansible: Automating IT Infrastructure with Ease

    Introduction: In today's rapidly evolving technological landscape, efficiency and automation have become paramount for…

  • Title: Amazon Route 53

    Title: Amazon Route 53

    Introduction to Amazon Route 53 Amazon Web Services (AWS) has become the backbone of countless online services…

    1 条评论
  • Title: Building a Basic VPC on AWS Using Terraform

    Title: Building a Basic VPC on AWS Using Terraform

    Are you diving into the world of cloud infrastructure and looking to set up your Virtual Private Cloud (VPC) on AWS?…

    1 条评论
  • Title: Harnessing Automation: Streamlining Operations with Linux and Ansible

    Title: Harnessing Automation: Streamlining Operations with Linux and Ansible

    :: Introduction to Linux and Ansible In the ever-evolving landscape of IT infrastructure management, Linux has emerged…

社区洞察

其他会员也浏览了