DevOps-Day'04 & '05 Linux Commands

Linux is case sensitive.

Command :

Command is a piece of code that is executed when we perform a certain task.

These actions can include managing files, installing software, monitoring system status, and more.

Command Syntax

command [options] [arguments]

  • command: The name of the tool or utility (e.g., ls, cd, mkdir)

  • options: Flags that modify the behavior of the command (e.g., -l, --help)

  • arguments: Targets like files, directories, usernames, etc.

list of commands that are used in Linux:

ls : It displays the list of files and directories

  • ls -l : To display the long listing in the screen

  • ls -h : To display the text in human understandingformat

  • ls -r : To display reverse order listing

  • ls -t :To know the modified time

  • ls -i : To identify and locate the file in desk (in in-line command (ls -i) we can see the text file name)

pwd(print working directory) : It displays the present working directory in the desk

cd(Chnage Directory) : To change the Directory in the desk

cd .. : To come back to one directory

cd ../.. : To come back to two directories

cd - : To back to the previous directory

cd / : Root directory

ctrl++ : To increase the font size

ctrl-- : To decrease the font size

clear : To clear the screen

~ : Take to user home Directory

<arg> --help : To get to know the details of, that is passed in the argument

man <arg> : To get to know the details of, that is passed in the argument

history : To display the history of all the commands that are used in the desk

history <N> : It displays the no of commands that are used in the desk, like if we enter N as 3, it shows last 3 commands that are used.

history -c : To clear the history

history -d < N> : To clear the particular ‘N’ command

!<N> : To execute any command that is in the history list for eg: want to delete the 3 line “!3”

uname : To display system information

uname -a : To displays detailed information

uname -r : Kernal structure is displayed

uname -m : Hardware architecture is displayed

who : To know which user logged in to the system

whoami : To know the present system

mkdir(Make Directory) : To create the directory

snx : mkdir <name of the directory>

eg: mkdir devops

-p : To create the directory path directly by using parent directory

NOTE : To create directory within a directory we need to change the directory first then create the directory

for eg:1. Have to create demo directory within the devops directory first change the path to devops

cd devops

mkdir demo

2.Another way is directly we can do

mkdir devops/demo

3.Or we can use the -p to create the directory directly by using parent directory

mkdir -p devops/demo/demo1

-v : To get the message like folder is created eg: mkdir -v devops, it displays the message ‘devops is created’

touch : To create the text file in the directory

snx : touch <name of the file>

eg : touch file.txt

touch devops/file.txt (it creates file.txt in the devops directory)

cat : To see the content of the file

eg: cat file.txt

vi : To add the text in the file

eg: vi file.txt

a text file is open when we the above query, enter ‘i’ to insert the text, for exit from the file press→esc→:wq

some commands :

[ec2-user@ip-172-31-3-60 demo]$ ls

ravi.txt sweety.txt

[ec2-user@ip-172-31-3-60 demo]$ pwd

/home/ec2-user/devops/linux/demo

[ec2-user@ip-172-31-3-60 home]$ cd ~

[ec2-user@ip-172-31-3-60 ~]$ mkdir -v devops

mkdir: created directory 'devops'

[ec2-user@ip-172-31-3-60 demo]$ touch sweety.txt

[ec2-user@ip-172-31-3-60 demo]$ vi sweety.txt

[ec2-user@ip-172-31-3-60 demo]$ cat sweety.txt

hello sweety

[ec2-user@ip-172-31-3-60 demo]$ cat *

hello sweety

0
Subscribe to my newsletter

Read articles from Sandhya Kalikiri directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sandhya Kalikiri
Sandhya Kalikiri