Linux For DevOps

Linux For DevOps

·

6 min read

Greetings everyone !!!

Linux is the backbone of modern computing and in this blog, I delve into Linux and have started my journey of learning Linux from scratch, watching youtube videos of Shubham Londhe and Kunal Kushwaha and also documenting my learnings. I have compiled my understanding of Basic Linux commands. Feel free to add or correct me if wrong.

Linux

Operating System  - Open source, multiuser & multiprocessing, security

Ubuntu

Distibution of linux. Other distributions: CentOS, Amazon Linux, RHEL

Shell

Shell is an environment in which we can run our commands, programs, and shell scripts. (Terminal)

kernel

Heart of the system and manages the CPU and memory. Kernel connects shell to hardware

COMMANDS

$ Whoami

To see the currently logged-in user

$ touch filename.txt

Create a file 

$ nano filename.txt

open the nano editor

$ vi filename.txt

open the vi editor

$ vim filename.txt

open the vim editor

$ ls

list the files in a current directory

$ls -a

list all hidden files (files which start with .<filename> are hidden files )

$ls -al

list all hidden files with details

$ cat <filename>

To display the contents of the file

$ pwd

Present working Directory

$ cd .

Current directory

$ cd ..

Previous directory

$ echo "Hello"

To print 

$ rm filename.txt

To delete file

$ mkdir LinuxForDevops

To create folder

$ rmdir LinuxForDevops

To delete folder

$ mkdir -p Linux/Shell

To create multiple nested folders

$ cp names.txt Folder1/

To copy names.txt file in Folder Folder1

$ mv devops.txt cloud.txt

To rename a file

$ mv cloud.txt ../gcpcloud.txt

To rename and also move to the previous directory

$ find .

To find in the current directory

$ find  . -type d

To find only directories

$ find . -type f

To find only files in the current directory

$ find . -type f -mmin +2

To find files in the current directory which were modified in more than 2 min

$ find . -type f -mtime -2

To find files accessed in the last 2 days

$ find -name "*.txt"

To find all files with .txt

$ find . -empty

To find empty files

GREP Command

Global Regular Expression Print -To search text in file or system

$grep "Ansible" names.txt

To find the text "Ansible" in the names.txt file

$ grep -i "Network"

Not case sensitive

$ grep -w "Network"

To find the complete "Network" in the names.txt file

$ df

Displays the amount of disk space available on the filesystem

$ du

Measures the disk space occupied by files or directories.

$ free

Outputs a summary of RAM usage

$ vmstat

Gives the information about processes, memory, paging, block IO, disk, and CPU scheduling

$ nslookup google.com

To obtain a domain name or IP address mapping

$ ifconfig 

To assign an address to a network interface and to configure or display the current network interface configuration information

Command to give permission to a file :

Command: $ chmod 777 file.txt

To check the permissions: $ls -l

read = 4, write = 2, execute = 1

Examples :

777 = -(rwx)(rwx)(rwx)

577 = -(r-x)(rwx)(rwx)

471 = -(r--)(rwx)(--x)

500 = -(r-x)(---)(---)

screenshot from https://www.geeksforgeeks.org/permissions-in-linux/

There are still a lot of commands left to learn and explore. But here I have started with these basic commands, will learn more and more as I will move forward with learning Devops. In the next blog, I will share the learnings of shell scripting. Till then stay tuned. Happy Learning.