KEMBAR78
Training Linux - 2 | PDF | Secure Shell | Computer File
0% found this document useful (0 votes)
22 views42 pages

Training Linux - 2

The document discusses a Linux fundamentals training course that covers topics like files and directories management, software management using packages and package managers, process and task management, and text editors like Nano and Vim. The course is aimed at IT professionals and those starting their DevOps journey and will involve presentations and hands-on labs over several days.

Uploaded by

Nguyễn Tùng
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)
22 views42 pages

Training Linux - 2

The document discusses a Linux fundamentals training course that covers topics like files and directories management, software management using packages and package managers, process and task management, and text editors like Nano and Vim. The course is aimed at IT professionals and those starting their DevOps journey and will involve presentations and hands-on labs over several days.

Uploaded by

Nguyễn Tùng
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/ 42

Training Course

Linux Fundamentals

8/1/2021 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 1


Course Overview
▪ This course helps you to understand how Linux works from
basics. Once you learn complete this course you can able
to
✔ Fulfill your regular tasks on the Linux server
✔ Easily start learning most of the trending technologies like AWS, Azure, GCP, DevOps, Python,
BigData, DataScience, etc...

▪ Who this course is for


✔ Any IT professional who wants to learn Linux basics quickly
✔ People who don't know why to start their DevOps journey.

8/1/2021 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 2


Course Schedule

Day Presentations Lab


Day 1 Introduction X
Files and Directories
Day 2 Management (User, System, Software) X
Networking and Services, Process management & other
Day 3,4,5 Assignment activities, divide into group to discuss and Test X

8/1/2021 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 3


Linux Fundamentals

DAY 2

8/1/2021 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 4


Linux Fundamentals
Software Management

• Linux uses software called a package manager to manage the


software installed on the Linux system.
• The package manager will be responsible for installing,
upgrading, configuring and removing previously installed
software on the Linux system.

8/1/2021 5
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

• Software for Linux operating systems will now be packaged into


packages for the purpose of easy distribution and storage. Each
package will include:
⮚ Executable file (binary)
⮚ Software-related information (metadata). For example: software name,
software description, version.
⮚ List of software or support libraries necessary for the operation of the
software (dependencies)

8/1/2021 6
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

• Different Linux operating systems have created different


package formats. Eg:

❖ .deb: For Linux Debian operating systems such as: Kali Linux, Ubuntu,
Parrot OS, Mint, etc.
❖ .rpm: For Red Hat Linux operating systems such as: Red Hat, CentOS,
Fedora, etc.

8/1/2021 7
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

• Every Linux operating system will have a list of software


repositories.
• Software repositories are places where you can download
software online to your computer.
• On Kali Linux and Ubuntu, the list of software repositories has
the path /etc/apt/sources.list.

8/1/2021 8
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management
• On Debian Linux operating systems, users are provided with
many options for managing packages. For example we have:

✔dpkg: manage, install, and remove software from Linux systems. The
drawback of dpkg is that it does not install the dependencies that come
with the software, resulting in faulty and inoperable software.
✔To install the software, use the command: dpkg -i <software-name>
✔To remove software, use the command: dpkg –remove <software-name>
✔To list installed software, use the command: dpkg -l

8/1/2021 9
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management
• On Debian Linux operating systems, users are provided with
many options for managing packages. For example we have:

✔apt or apt-get: install not only the package, but also the dependencies
that the software needs to run properly.
✔In fact, when user uses apt or apt-get to install a package, it will use dpkg
to install the software and apt or apt-get will take care of the
dependencies.
✔This is also the most commonly used command to manage packages on
Linux Debian operating systems.
8/1/2021 10
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

❖ apt or apt-get

✔ To install the software, use the command: apt install <software-name>


✔ To remove software, use the command: apt remove <software-name>
✔ To delete all packages used as dependencies of the software to be deleted, use
the command: apt autoremove <software-name>
✔ To delete everything related to the software to be deleted, use the command:
apt purge <software-name>
✔ To list the installed packages we use the command we use the command: apt list

8/1/2021 11
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management
Question?

?
Difference between apt and apt-get?

8/1/2021 12
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

• Use the following 3 commands to update and upgrade the software installed
in the Linux system:
• sudo apt update
The apt update command will find and update the latest versions of the
packages in the /etc/apt/sources.list list.
• sudo apt upgrade
The apt upgrade command will rely on the updated /etc/apt/sources.list
list to install the latest versions of the software inside the Linux system.

8/1/2021 13
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Software Management

• sudo apt dist-upgrade

• The dist-upgrade command, besides performing the function of the


upgrade command, also updates the latest version for the dependencies
of the updated software.
• Or if there are dependencies that conflict with each other, the dist-
upgrade command will remove these conflicting dependencies.

8/1/2021 14
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Task Management

Linux provides us with several tools to manage the tasks running on the system
similar to the Task Manager
ps <options-flag>

• PID (Process ID): The identifier of the process in the system. Each process will carry a
PID and this number is unique. That is, there will never be 2 processes with the same
process at the same time
• TTY (TeleTYpewriter): The name of the terminal that executes the command
• TIME: CPU time needed to process the above process in minutes and seconds
• CMD: Name of the command that started the processs operating system

8/1/2021 15
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Task Management

Linux provides us with several tools to manage the tasks running on the system
similar to the Task Manager
• To print out all processes running in the system: ps -e
• To print the task with the PID of the task parent and the UID running the task: ps –ef
▪ UID: Username running the task
▪ PPID (Parent PID): ID of the task's parent
▪ C: Number of CPU cycles used by each task
▪ STIME: The time the process starts

8/1/2021 16
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Task Management

Linux provides us with several tools to manage the tasks running on the system
similar to the Task Manager

• To print all processes running in the system will be displayed as follows: top
• To print all information of all columns: press “f”
• Tick or untick: press “space”
• Quit: press “q” or “ECS”

8/1/2021 17
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Editor: Nano & Vim

Editor basic command: echo “Hello World” > Hello.txt


Very difficult to:
• Edit a long text
• Change
• Storage
• Work with other
• Take time

8/1/2021 18
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Editor: Nano & Vim

Nano
• Nano is a command-line text editor that comes pre-installed on many Linux
distri.
• Nano is very suitable for those who are just getting started with the command
line interface on Linux.

• Create a file: nano “filename”


• Save and exit: Ctrl + x > Y
• Practice with create a file personal and introduce
yourself!!!
8/1/2021 19
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Editor: Nano & Vim

Vim
• Like Nano, Vim is also a pre-installed text editor on many Linux distri
• Vim is somewhat more difficult to use than Nano because you will have to
learn a lot of keyboard shortcuts to be able to manipulate easily on vim.
• Vim is somewhat more popular than Nano
• Create a file: vi “filename” + insert
• Save and exit: esc + wq!
✔ w: Short for write – Writes content to memory
✔ q: Short for quit – Quit the Vim program
✔ ! : Used to force Vim to perform w and q

8/1/2021 20
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Editor: Nano & Vim

Bash Scripting

• A Bash scripting is a program written in Bash that is used to perform a certain


task on a Linux system.
• In other words, when you write Bash scripting, you are creating new software
for the Linux system.
• Sometime support Crontab

8/1/2021 21
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Editor: Nano & Vim

Bash Scripting #!/bin/bash

• Simple bash scripting name=“Micheal”


echo “My name is $name"
• Start with #!/bin/bash
• The ending is .sh
• Remember chmod for scripting
• Let’s Practice!!!

8/1/2021 22
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
find command in Linux with examples
• The find command in UNIX is a command line utility for walking a file hierarchy.
• It can be used to find files and directories and perform subsequent operations on
them.
• It supports searching by file, folder, name, creation date, modification date,
owner and permissions.
• By using the ‘-exec’ other UNIX commands can be executed on files or folders
found.

8/1/2021 23
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

find command in Linux with examples


• View folder by: tree
• Find a file or folder: find + “foldername/filename”

8/1/2021 24
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
SSH

• The SSH protocal (also referred to as Secure Shell) is a method for secure remote login
from one computer to another.
• It provides serveral alternative options for strong authentication and it protect the
communications security and integrity with strong encryption.

Port Number : 22
Daemon : sshd
Conf file : /etc/ssh/ssh_config

8/1/2021 25
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

SSH
• SSH command: ssh user@destination-ipaddress
• Practice ssh to the ec2-instance (linux server) using Putty or Superputty

8/1/2021 26
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Copy file between servers

Windows to Linux
Mobaxterm or winscp
Linux to linux
SCP (secure copy) is a command –line utility that allows you to securely copy
files and directories between two systems.

scp source_file_name username@destination_host:destination_folder

Example: scp file1 root@10.20.30.40:/tmp


scp root@10.20.30.40:/tmp /home/ec2-user/

8/1/2021 27
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Copy file between servers

Practice with WinSCP to transfer file between Window and Linux ec2-Instance (AWS)
Requirement

1. ec2-instance
2. Key pair to access ec2-instance
3. Winscp
4. Temporary-file

Now, Let’s practice!!!

8/1/2021 28
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File Permissions

Permissions are applied at 3 level


• Owner or User level
• Group level
• Othes level

Permissions are applied in 3 types


• r – Read only
• w – Write/Edit/Append/Delete
• x- Execute/Run

8/1/2021 29
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

File Permissions

Access modes are different on file and directory

Permissions File Directory


R Open the file ‘ls’ the contents of dir
W Write, edit, append, delete file Add/Del/Rename contents of dir
X To run a command/shell script To enter into dir using ‘cd’

8/1/2021 30
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File types

Symbol Type of file


- Normal file
b Block file (Harddisk, Floppy disk)
c Character file (Keyboard, Mouse)
d Directory
| Link files (short cut)

8/1/2021 31
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File Permissions
Unix/Linux files have 8 attributes that can be seen with ls –l command

8/1/2021 32
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File Permissions
Unix/Linux files have 8 attributes that can be seen with ls –l command

8/1/2021 33
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File Permissions
Permission can be set on any file/dir by using two methods:
• Symbolic method (ugo)
• Absolute method (number)

Symbolic method Absolute method

# chmod [who][+/-/=][permissions] file We use numbers instead of using symbols


Who: To whom the permissions to be assigned Read – 4
Permissions: User/owner (u); group (g); others (o) Write – 2
Example: Execute – 1
#chmod u=rwx,g=rw,o=r <file_name> #chmod 764 <file_name>
#chmod ugo=rwx <file_name> #chmod 777 <file_name>

8/1/2021 34
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
File Permissions
Permission can be set on any file/dir by using two methods:
• Absolute method (number)

8/1/2021 35
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
User Management
In Linux there are three types of users.
1. Super or root user: User is the most powerful user. He is the administrator user.
2. Sytem user: User created by the softwares or applications.
3. Normal user: Normal users are the users created by root user.

Type Example Home Directory Shell


Super User Root /root /bin/bash
System User ftp, ssh, apache /var/ftp, etc /sbin/nologin
Normal User Visitor, ec2-user /home/username /bin/bash

8/1/2021 36
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

SELF-STUDY!!!

8/1/2021 37
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals
Link Files
There are 2 types of link files
Soft link and Hard link

Soft link Hard link


SHORTCUT FILE BACKUP FILE
Size of link file is equal to no. of characters in the Size of both file is same
name of original file
If original file is deleted, link is broken and data is If orginal file is deleted then also link will
lost contain data
Command: ln –s <src_file> <dest_file> Command: ln <src_file> <dest_file>

8/1/2021 38
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

Sed command (Extend)

Stand for stream editor, which is used to search a word in the file and replace it with the word
required to be in the output.
Note: it will only modify the output, but there will be no change in the origin file.

Example:
sed ‘s/old_text/new_text/’ file_name
sed ‘s/old_text/new_text/g’ file_name
sed –I ‘s/old_text/new_text/’ file_name
sed –n ‘5,10p’ file_name
sed ‘10,20d’ file_name

8/1/2021 39
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

Wget in Linux

• Wget developed by GNU helps you to download the content of a web page or
download files.
• It can be downloaded via FTP, SFTP, HTTP, and HTTPS, it can be used on any
platform like Linux, Windows, MacOS.

8/1/2021 40
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Linux Fundamentals

DAY 2
SUMMARY

8/1/2021 41
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Thank you

8/1/2021 09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 42

You might also like