0% found this document useful (0 votes)
12 views

1695714533-1. Basics of Working With Linux Operating System

Basics of working with Linux OS , you'll get know the basics of linux

Uploaded by

K Durga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

1695714533-1. Basics of Working With Linux Operating System

Basics of working with Linux OS , you'll get know the basics of linux

Uploaded by

K Durga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Basics of working with Linux Operating System

Basics of working with Linux


Operating System
Basics of working with Linux Operating System

Disclaimer
The content is curated from online/offline resources and used for educational purpose only
Basics of working with Linux Operating System

Learning Objectives
You will learn in this lesson:

• Operating System

• Linux Operating System

• Linux Kernel

• Basic Linux Commands

• Shell Scripting
Basics of working with Linux Operating System

Scenario

Computer Servers Android Phones

Supercomputers IoT Devices


Basics of working with Linux Operating System

Introduction
• Operating System acts as an interface between the
computer hardware components and the user.

• Performs file management, process management,


and memory management, handling input and output
devices.

• Helps us to communicate with the computer without


us having the knowledge of the computer’s language.

Source: https://upload.wikimedia.org/wikipedia/
Basics of working with Linux Operating System

Operating System Management Tasks

Process Memory Device File


Management Management Management Management

Security Job-
Storage User-Interface
Management accounting Manage
Management Management
ment
Basics of working with Linux Operating System

Desktop Operating Systems Mobile Operating Systems

Embedded Operating Systems Server Operating Systems


Types
Operating
System
Real-Time Operating Systems Mainframe Operating Systems

Special-Purpose Operating Systems


Basics of working with Linux Operating System

What is Linux?
• The Linux OS is free and open-source and behaves
like a Unix-like operating system.

• Linux was conceived and created in 1991 by Linus


Torvalds for his i386-based PC

• Linux was adopted as the kernel for the GNU


operating system, which was created as a free
replacement for UNIX.
Basics of working with Linux Operating System

Linux Features
• UNIX-like kernel.
• Open source.
• Preemptive multitasking
• Portable
• Security
Basics of working with Linux Operating System

Linux Architecture
• Hardware Layer
• Kernel
• Shell
• Utilities

Source: https://media.geeksforgeeks.org/wp-content/uploads/
Basics of working with Linux Operating System

History of Linux

Source: OIP.ogHRO_lpdj0EunHjowo3HwAAAA (474×252) (bing.com)


Basics of working with Linux Operating System

Linux Distributions
• Ubuntu

• Debian

• Fedora

• Kali Linux

• Arch Linux

• Raspberry Pi OS
Basics of working with Linux Operating System

Lab 1: Installing Linux on VirtualBox


Basics of working with Linux Operating System

What is a Linux Kernel?


Kernel runs each processes and provides system
services to processes, provides protected access to
hardware to processes.

The kernel has the following jobs:

• Memory management
• Process management
• Device drivers
• System calls and security

Source: https://blog.digilentinc.com/wp-content/uploads/2015/05/1280px-Kernel_Layout.svg_.png
Basics of working with Linux Operating System

Linux File System


The kernel maintains a single hierarchical directory structure to organize all files in the system. In
Microsoft Windows, each disk device has its own directory hierarchy.
Basics of working with Linux Operating System

Important Directories (Linux File System)


In a Linux file system, there are several important directories that serve specific purposes and hold
essential system and user data.

1. **/** (Root Directory)


2. **/bin (Binary Binaries)
3. **/etc (System Configuration Files)
4. **/home (User Home Directories)
5. **/usr (User Binaries and Libraries)
6. **/var (Variable Files)
7. **/tmp (Temporary Files)
8. **/dev (Device Files)
9. **/boot (Boot Loader Files)
10. **/opt (Optional Software)
Basics of working with Linux Operating System

ls command

ls -a (all) ls -S (size)
Lists all the files (including .* files) Lists the biggest files first

ls -l (long) ls -r (reverse)
Long listing (type, date, size, owner, Reverses the sort order
permissions)

ls -t (time) ls -ltr (options can be combined)


Lists the most recent files first Long listing, most recent files at the end

Lists the files in the current directory, in alphanumeric order, except files starting with the “.” character
Basics of working with Linux Operating System

cd and pwd commands


cd <dir>
Changes the current directory to <dir>.

cd -
Gets back to the previous current directory.

pwd
Displays the current directory ("working directory").
Basics of working with Linux Operating System

cp command
cp <source_file> <target_file>
Copies the source file to the target.

cp file1 file2 file3 ... dir


Copies the files to the target directory (last argument).

cp -i (interactive)
Asks for user confirmation if the target file already exists

cp -r <source_dir> <target_dir> (recursive)


Copies the whole directory.
Basics of working with Linux Operating System

mv and rm commands
mv <old_name> <new_name> (move)
Renames the given file or directory.

mv -i (interactive)
If the new file already exits, asks for user confirm

rm file1 file2 file3 ... (remove)


Removes the given files.

rm -i (interactive)
Always ask for user confirm.

rm -r dir1 dir2 dir3 (recursive)


Removes the given directories with all their contents.
Basics of working with Linux Operating System

Creating and Removing Directories


mkdir dir1 dir2 dir3 ... (make dir)
Creates directories with the given names.

rmdir dir1 dir2 dir3 ... (remove dir)


Removes the given directories

Safe: only works when directories and empty.


Alternative: rm -r (doesn't need empty directories).

© Edunet Foundation. All ri ghts reserved.


Basics of working with Linux Operating System

Lab 2: Operating Linux Using Terminal


Basics of working with Linux Operating System

Working with Files

command function
touch filename1 fileName2 fileName3 ….​ easy way to create a file​

cp file1 file2 or cp fileName filePath copy content of a file to other file​


mv fileName1 fileName2 move file content or file to other dir
or mv fileName1 filePath/dirPath

cp -r dirName1 dirName2​ recursive copy​


cp file1 file2 file3 file4 file5 /dirName cp multiple files to directory​
head display first 10 lines​
tail display last 10 lines
cat display content​
cat > fileName create file with concatenated content (ctrl+d for EOL)​
Basics of working with Linux Operating System

File Access Rights


Use ls -l to check file access rights

3 Types of Access Rights:

• Read access (r)


• Write access (w)
• Execute rights (x)

3 Types of Access Levels:

• User (u): for the owner of the file


• Group (g): each file also has a “group” attribute, corresponding to a given list of users
• Others (o): for all other users

© Edunet Foundation. All ri ghts reserved.


Basics of working with Linux Operating System

Access Right Examples


-rw-r--r--
Readable and writable for file owner, only readable for others

-rw-r-----
Readable and writable for file owner, only readable for users belonging to the file group.

drwx------
Directory only accessible by its owner

-------r-x
File executable by others but neither by your friends nor by yourself. Nice protections for a trap...
Basics of working with Linux Operating System

Lab 3: Practicing File Operations


Basics of working with Linux Operating System

Shell Scripting
Basics of working with Linux Operating System

What is a Shell ?
• A shell is an environment that takes commands
typed by the user and calls the operating system to
run those commands.
• It is a program that acts as the interface between
the user and the Linux system, allowing the user
to enter commands for the operating system
to execute.
• Shell accepts the instruction or commands
in English and translates them into computers
native binary language.

Source: https://www.opensourceforu.com/2020/03/reasons-to-use-linux/
Basics of working with Linux Operating System

Kind of Shells

Kind of Shells

Bourne Shell

C Shell

Korn Shell

Bash Shell

Tcsh Shell
Basics of working with Linux Operating System

Changing Your Default Shell


• Command to find all available shells in your system: $ cat /etc/shells
• The basic Syntax to change your default shell : $ chsh username new_default_shell
Basics of working with Linux Operating System

Shell Scripting
• Shell script is a plain text file that contains a series of command(s).
• Shell script takes input from user, file and output them on screen.
• It saves lots of time by automating routine admin tasks.
Basics of working with Linux Operating System

Why to use Shell Script?


• Shell scripts can be used to automate administrative tasks.

• Encapsulate complex configuration details and get a full power of the operating system.
• The ability to combine commands allows you to create new commands, thereby adding value to your
operating system.
Basics of working with Linux Operating System

Practical Examples of Shell Scripting


• Monitoring the Linux system.
• Data backup and creating snapshots.
• Find out what processes are eating up your system resources.
• Find out available and free memory.
• Find out all logged in users and what they are doing.
• Find out if all necessary network services are running or not.
Basics of working with Linux Operating System

Practical Examples:
write a shell script to use if then else​

#!/bin/bash​
if [ -f isit.txt ]​
then echo isit.txt exists!​
else echo isit.txt not found!​
fi​
Basics of working with Linux Operating System

Practical Examples: if then elif


You can nest a new if inside an else with elif.​

#!/bin/bash​
echo -n Enter the count:​
read count​
if [ $count -eq 42 ]​
then​
echo "42 is correct."​
elif [ $count -gt 42 ]​
then​
echo "Too much."​
else​
echo "Not enough."​
fi
Basics of working with Linux Operating System

Practical Examples: for loop


#!/bin/bash​
for counter in `seq 1 20`​
do​
echo counting from 1 to 20, now at $counter​
sleep 1​
done​
another way:​
#!/bin/bash​
for i in 1 2 4​
do​
echo $i
done
Basics of working with Linux Operating System

Practical Examples: the while loop


while command​
do​
Statement(s) to be executed if command is true​
done​

#!/bin/sh​
a=0​
while [ $a -lt 10 ]​
do​
echo $a​
a=`expr $a + 1`​
done
Basics of working with Linux Operating System

SSH
• SSH stands for “Secure Shell”.
• SSH transfers the data in encrypted form between
the host and the client.
• It transfers inputs from the client to the host and
relays back the output. SSH runs at TCP/IP port 22

ssh user_name@host(IP/Domain_name

Example: ssh [email protected]


Basics of working with Linux Operating System

SSH

https://phoenixnap.com/kb/linux-ssh-commands
Basics of working with Linux Operating System

SCP
• The scp command allows you to copy files over ssh connections.
• This is pretty useful if you want to transport files between computers
Syntax
• scp examplefile yourusername@yourserver:/home/yourusername/
Example
• scp file1.pdf [email protected]:/root/Desktop
Basics of working with Linux Operating System

Lab 4: Shell Scripting and Operations


Basics of working with Linux Operating System

Summary
• We know about the basic of Linux operating systems​

• We are now familiar with basic Linux commands


including the Linux command line, Linux servers, file
systems, and much more.​

• We know about Linux Terminal, and shell scripting.


Basics of working with Linux Operating System

Quiz
1. Who founded Linux Kernel?

a) Ken Thompson and Dennis Ritchie


b) Linus Torvalds
c) Linus Torvalds and Ken Thompson
d) Richard Stallman

Answer: b
Linus Torvalds
Basics of working with Linux Operating System

Quiz
2. Which symbol represents the top-level directory?

a) ~
b) @
c) #
d) /

Answer: d
/
Basics of working with Linux Operating System

Quiz
3. Which symbol represents the user's home directory?

a) ~
b) @
c) #
d) /

Answer: a
~
Basics of working with Linux Operating System

References
• https://en.wikipedia.org/wiki/Linux_kernel
• https://www.tutorialspoint.com/operating_system/os_linux.html
• https://buildmedia.readthedocs.org/media/pdf/lym/latest/lym.pdf
• https://phoenixnap.com/kb/linux-commands-cheat-sheet
• https://www.guru99.com/file-permissions.html
• https://www.hostinger.in/tutorials/linux-commands
Basics of working with Linux Operating System

Thank You

You might also like