Basic Linux Commands for DevOps (PART-1)

Share via:
Dear Readers,

In this article,we will see Basic Linux Commands for DevOps.

First, we need to AWS Console page by using below link.

https://aws.amazon.com/console/

Click on sign in to Console button.

Logging to aws account

Login using username & password and click on sign in.

Enter to AWS Management Console

We can see the AWS Management Console Dashboard.

Go to Services, under the compute module click EC2 service to open.

Launch Linux EC2 Instance

Please check below link to Launch Linux Server.

Launch Linux Launch Linux Server

We can see Linux Server “My Linux” which was created earlier.

Connect to Linux Server through putty.

Open Linux Server terminal,.

 Open Linux Terminal

Switch to root user

Install server Updates

Create Files and Directories

cat
we can create files by using cat command.

Create a new file “ktexperts1”

Note 

Press ctrl+d to quit.

To display the content of the file

Add content to an existing file “ktexperts1”

To display the content of the file

touch

we can create empty files by using touch command.

Create a empty file “ktexperts2”

To see list of files

Creating multiple empty files

To see list of files in the current directory

nano

We can create and edit files using nano command.

Edit a existing file “ktexperts2”

Note 

press ctrl + x  and Y to quit.

To see list of files in the current directory

vi/vim

We can create files using vi/vim command.

Create a new file “ktexperts3”

Note : Press esc and wq! then enter to quit.

To see list of files in the current directory

tree

tree is a recursive directory listing program that produces a depth-indented listing of files.
tree lists all the files and/or directories.
tree returns the total number of files and/or directories listed.
Install tree Package
By default the tree command is not installed. Type following command to install tree command

To see list files in tree format

Create a Directory

mkdir
We can create a directory using mkdir Command.

Create a new directory “ktexperts”

Create Multiple Directories

Create multiple directories inside a directory.

Verify Directories

Bu using cd command we can go inside/change  another directory.

cd change directory
Go forward step by step

pwd

It prints the path of the working directory, starting from the root.

pwd – print working directory

Go backward step by step

Go forward directly

Go backward directly

ls

The ls command is a command-line utility for listing the contents of a directory or directories.

To see long list of files and directories

ls -l

It will show size, modified date and time, file or folder name and owner of file and its permission.

Create a hidden file 

To see all files and directories including hidden files
[root@ip-172-31-43-80 ec2-user]# ls -a

To see long list of all files and directories including hidden files

Copy

Create a new file

Copy file to directory

Go inside directory and verify the file

Move

Move file to directory

Move multiple files to one directory

Go inside directory and verify the files

Rename

Rename an existing file 

Remove

Using rm command

Remove a single directory

Remove all files and directories

grep

The grep command which stands for “global regular expression print”.

By default, grep displays the matching lines.

Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines.
Using grep for search files.

grep is a powerful file pattern searcher in Linux.
To see the list of users

To search /etc/passwd file for the user “ec2-user”.

To search /etc/passwd file for the user “root”.

less

The less command is used to see the output line wise or page wise.

Note 

press Enter key to scroll down line by line.

Use d to go to next page.

Use b to go to previous page.

Use / to search for a word in the file.

Use v to go vi mode where you can edit the file and once you save it you will back to less command.

press q to quit from the prompt.

.more

The less command is used to see the output line wise or page wise.

Note

press Enter key to scroll down line by line.

Use d to go to next page.

Use b to go to previous page.

Use / to search for a word in the file.

Use v to go vi mode where you can edit the file and once you save it you will back to more command.

press q to quit from the prompt.

head

It is used to display the top 10 lines of the file.

By default it will top 10 lines.
To see top 10 lines of the file

To see top 5 lines of the file

tail

It is used to display the last 10 lines of the file
To see last 10 lines of the file

To see last 5 lines of the file

sort
It is used to sort the output in numeric or alphabetic order.

Create a new file “Ram”

Sorting in Alphabetical order

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTEXPERTS is always active on below social media platforms.

 

Facebook: https://www.facebook.com/ktexperts/
LinkedIn  : https://www.linkedin.com/company/ktexperts/
Twitter     : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform

Follow Me
Ramesh’s Linkedin : Ramesh Atchala

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

2 thoughts on “Basic Linux Commands for DevOps (PART-1)

Add Comment