Skip to main content

Day 3 Task: Basic Linux Commands

Day 3 Task: Basic Linux Commands




Task: What is the linux command to



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

Solution:-

ls - The ls is the list command in Linux. It will show the full list or content of your directory.

ls -a - you can see the whole list of files, including the hidden files.

ls -l - The ls command will only display the files.

ls -d */ - If you only want to display the sub-directories excluding all other files, you can

use this command

ls -g - If you don't want to display the owner information in your list

ls -lg - f you don't want to display the group information in your list

ls --color=[VALUE] - This command is used to colourize and decolourize the list.

**ls ~ -**it shows the contents of the home directory.

ls ../ - This command contains the list of the parent directory.

sudo - The Linux sudo command stands for Super User Do.

Sudo -V - It stands for version.

sudo -l - It stands for list.

sudo -h - The h stands for help in this option.

pwd - stands for Print Working Directory. It prints the path of the working directory, starting from the root.

$cat filename

it will show the content of the given file

cat file1 file2

This will show the content of file1 and file2

cat -n filename

It will show content with line number

cat > newfile

Will create a file named newfile

$cat "filename1" "filename2" "filename3" > "merged_filename"

The content will be copied in destination file

$cat file1 >> file2

Will append the contents of one file to the end of another file

$tac filename

Will display content in reverse order

$cat "filename1" "filename2" "filename3" > "merged_filename"

Will merge the contents of file in respective order and will insert that content in "merged_filename".

$cat *.txt

Will show the content of all text files present in the folder.

$cat >> safia.txt

The newly added text.

Will append the text "The newly added text." to the end of the file.

1.To view what's written in a file.

cat - This is the simplest and perhaps the most popular command to view a file in Linux.

nl - The nl command is almost like the cat command. The only difference is that it prepends line numbers while displaying the text in the terminal.

less - Less command views the file one page at a time.

**head-**head command is another way of viewing text files but with a slight difference. The head command displays the first 10 lines of a text file by default.

tail - it is similar and yet opposite to the head command. While the head command displays the file from the beginning, the tail command displays the file from the end.

2.To change the access permissions of files.

chmod +rwx filename to add permissions

chmod -rwx directory name to remove permissions.

chmod +x filename to allow executable permissions.

chmod -wx filename to take out write and executable permissions.

To check which commands you have run till now.
history - command is used to view the previously executed command.

To remove a directory/ Folder.
Use the rmdir or rm -d command to remove empty directories.

Use the rm -r command to remove non-empty directories.

5.To create a fruits.txt file and to view the content.

vim fruits.txt

apple

banana

mango

pineapple

guava

:wq

6.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

vim devops.txt

apple

mango

banana

Comments

Popular posts from this blog

Bash Scripting

  How to Create Your First Bash Scrip touch hello_world.sh Find the path to your bash shell. where bash is located which bash touch hello.sh ls -al Permission of file #! bin bash #! /bin/bash echo "hello" for execute ./hello.sh Comment # before line of comment it give more information about script ++++++++++++++++++++++++++++++++++++++++++++++ when ever we define a Variable it can store somedata string data any no or any other kind of data 1 System variable 2 Userdefine variable System variable echo $BASH echo $BASH_VERSION echo $HOME echo $HASH_VERSION echo $PWD 2. USERDEFINE VARIABLE name = Mark echo $name echo "this is my $name +++++++++++++++++++++++++ #To take the input from user echo "enter name: " read name echo "entered name $name" ++++++++++++++++++ for multiple name echo "enter name: " read name1 name2 echo "Names: entered $name, $name1, $name2" +++++++++++ to print on same line read -p 'usena...

let's start the python journey

  About Python What is Python?           Python is a high-level, general-purpose programming language.

Devops on AWS

  SDLC Model - Software Development Life Cycle Waterfall Model Agile Model Waterfall Model Disadvantages of Waterfall Model It is difficult to estimate time and cost for each phase of the development process.  Once an application is in the testing stage, it is very difficult to go back and change something that was not well-thought out in the concept stage.  Not a good model for complex and object-oriented projects.  Not suitable for the projects where requirements are at a moderate to high risk of changing. Agile Model Agile development model is also a type of Incremental model. Software is developed in incremental, rapid cycles. This results in small incremental releases with each release building on previous functionality. Each release is thoroughly tested to ensure software quality is maintained. Agile software development method emphasis on iterative, incremental, and evolutionary development. Delay In spite of the Model, still delay? Gap between development tea...