Day 2 #90DaysOfDevOps

Day 2 #90DaysOfDevOps

Topics for #day2

  • What is Command in general and in technical terms?

  • Basic Linux Commands

What is Command in general and in technical terms?

In general:

A command is an instruction or order given to someone or something to do something.

Examples: "Stand Up", "Sit Down", "Talk To Me"

In technical terms:

A command is a specific instruction given to a computer or other electronic device to perform a particular action. Commands are often entered using a command line interface (CLI), which allows the user to interact with the computer by typing in text-based commands rather than using a graphical user interface (GUI).

Examples:

  • In the Windows Command Prompt, the command "dir" is used to display a list of files and folders in the current directory.

  • In Unix and Linux systems, the command "ls" is used to list the files and directories in the current working directory.

  • The command "cd" is used to change the current working directory in both Windows and Unix-based systems.

  • In Git, the version control system, the command "git commit" is used to save changes to a repository.

  • In Python programming language, the command "print" is used to output text or data to the console.

Basics Linux command

Listing commands

ls option_flag arguments --> List the subdirectories and files available in the present directory

Examples:

  • ls -l--> List the files and directories in long list format with extra information

  • ls -a --> List all including hidden files and directory

  • ls *.sh --> List all the files having .sh extension.

  • ls -i --> List the files and directories with index numbers inodes

  • ls -d */ --> List only directories.(we can also specify a pattern)

Directory commands

  • pwd --> print work directory. Gives the present working directory.

  • cd path_to_directory --> change directory to the provided path

  • cd ~ or just cd --> change directory to the home directory

  • cd - --> Go to the last working directory.

  • cd .. --> change directory to one step back.

  • cd ../.. --> Change directory to 2 levels back.

  • mkdir directoryName --> to make a directory in a specific location

Examples:

mkdir newFolder              # make a new folder 'newFolder'

mkdir .NewFolder              # make a hidden directory (also . before a file to make it hidden)

mkdir A B C D                  #make multiple directories at the same time

mkdir /home/user/Mydirectory   # make a new folder in a specific location

mkdir -p  A/B/C/D              # make a nested directory

Check your present working directory.

pwd --> Print work directory.

Saurabh@ubandupc:~$ pwd
/home/Saurabh

List all the files or directories including hidden files.

Saurabh@ubandupc:~/Desktop$ ls -la
total 17372
drwxr-xr-x 12 Saurabh Saurabh     4096 Mar 20 13:59  .
drwxr-xr-x 27 Saurabh Saurabh     4096 Mar 17 17:17  ..
drwxrwxr-x  2 Saurabh Saurabh     4096 Jul 20  2022  Ansible
-rw-rw-r--  1 Saurabh Saurabh 17209836 Feb 15 13:41 'AWS Hand Written Notes.pdf'
drwxrwxr-x  2 Saurabh Saurabh     4096 Feb 15 13:45  AWS
drwxrwxr-x  2 Saurabh Saurabh     4096 Dec  5 10:29 'Devops Full Course'

Create a nested directory A/B/C/D/E

Saurabh@ubandupc:~/Desktop/day2$ mkdir -p A/B/C/D/E

Saurabh@ubandupc:~/Desktop/day2$ tree
.
└── A
    └── B
        └── C
            └── D
                └── E