DevOps Learning Notes

  Edwiki Trainings

2 Followers

Linux Introduction


In this lecture you are learning LINUX basic commands and Linux Directory Structure:

In Linux, data will stored into files and files are organized into directories. Files and Directories are organized into hierarchical format with parent and child relationship to the directories, called the file system.

Directory Structure:

Linux uses a hierarchical directory structure, with root (/) at the base of all other directories, which is called as root directory.

A LINUX directory is a collection of files and directories with below properties:

  • / is the  root  directory which contains other files and directories
  • Each file or directory is uniquely identified by its name, the directory in which it resides
  • Following are the top level directories that exist on the major versions of LINUX:

 

File Management:

         In LINUX there are three basic types of files:

  1. Ordinary Files: Its Regular File used to save the data like text, command instructions etc. 
  2. Directories: Directories are like Folders to keep Files and sub-directories. 
  3. Special Files: Special files are files used to store the hardware definitions and device drive information to identify and handle the hardware operation. 

Directory Management:

Home Directory:

It’s the default directory where User is placed in once User logged in to the Linux server. User get complete access to their Home Directory as the user is owner of Home Directory.

Absolute/Relative Path:

Directories are arranged in a hierarchy with root (/) at the top. Any file placed in a directory is located by its path name.

Pathname are separated by a / and pathname started with / is called as Absolute Path and the path starting with . Or .. is called as Relative Path.

Relative Paths are always start with . or .. Referencing the path from current or parent directory. 

Linux Users:

In Linux, User is the one who uses the system to perform any tasks. Linux has three type of users to access the system.

  1. Root User: root user also called as super user and would have complete access to the system. Root account can run any commands without any restriction hence this user called as System Administrator user and its default user created with the Linux installation. 
  2. System User: System Users are those needed for the operation of system-specific components for example mail accounts and the sshd accounts. These System Users are created automatically with the specific software installation to manage the software programs. Usually we should not edit any property of System Users as that would affect the system behaviour. 
  3. Normal User: User Accounts that are created manually to access the system called as Normal Users. Normal Users granted with interactive shell access to type commands to complete certain tasks. Usually Normal Users are created to grant and restrict access to certain files are directories within the Linux System.

Linux Basic Commands:

Linux command accepts arguments and flags to process your request. Note that arguments and flags are not mandate and you provide these based on the requirement. 

Linux arguments an argument, also called command line argument, can be defined as input given to command line to process that input with help of given command. The argument can be a file or directory.

Providing flag to the command changes the execution behaviour and your output changes when using different flags .

Examples: mkdir <dir_name as argument>

                  ls –l           ->       Here –l is the flag

 

Below are the some basics commands with examples that you must know 

whoami: Check who currently logged in to the Linux server

[edwiki@@ip-172-31-53-92 ]$whoami

ec2-user

[edwiki@@ip-172-31-53-92 ]$


date: Check current timestamp with server timezone

[edwiki@@ip-172-31-53-92 ]$date

Tue Jan 31 06:24:29 UTC 2023

[edwiki@@ip-172-31-53-92 ]$


mkdir: Create directory

[edwiki@@ip-172-31-53-92 ]$mkdir dir1

touch: create zero size regular file

[edwiki@@ip-172-31-53-92 ]$touch f1

rmdir: remove directory

[edwiki@@ip-172-31-53-92 ]$rmdir dir1

rm: remove files

[edwiki@@ip-172-31-53-92 ]$rm f1

ls: list files and directories

[edwiki@@ip-172-31-53-92 ]$ls

dir1  f1

[edwiki@@ip-172-31-53-92 ]$

 

[edwiki@@ip-172-31-53-92 ]$ls -l

total 0

drwxrwxr-x 2 ec2-user ec2-user 6 Jan 31 06:25 dir1

-rw-rw-r-- 1 ec2-user ec2-user 0 Jan 31 06:25 f1

[edwiki@@ip-172-31-53-92 ]$

NOTE: Here line starts with ‘d’ states that this is directory – dir1 and starts with ‘-‘ states that this is file – f1


pwd: Shows your present working directory

[edwiki@@ip-172-31-53-92 ]$pwd

/home/ec2-user

[edwiki@@ip-172-31-53-92 ]$


cd: To change the present working directory path

[root@ip-172-31-53-92 ~]# pwd

/root

[root@ip-172-31-53-92 ~]# cd /var

[root@ip-172-31-53-92 var]# pwd

/var

[root@ip-172-31-53-92 var]#


sudo su -:  Switch to root user

[edwiki@@ip-172-31-53-92 ]$sudo su -

[root@ip-172-31-53-92 ~]# whoami

root

[root@ip-172-31-53-92 ~]#


Previous Next