0% found this document useful (0 votes)
9 views33 pages

(CC - 23) Lab 2

Uploaded by

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

(CC - 23) Lab 2

Uploaded by

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

Cloud Computing

Lab 2
(2022-2023)
Agenda

● Linux Essentials
● What is Linux ? Why ?
● Basic Command Syntax
○Command
○Arguments
○Options
● Basic Linux Command
● Package Management
What is Linux ? Why ?

• Linux is operating system software that runs on a


hardware computer system.

• Cell phone, tablet, laptop and desktop all need an operating system
to run applications.

• Linux is used on desktop and laptop computers, web servers,


mobile devices (Android), public cloud technology (i.e., Google,
Amazon, etc), Chromebooks, and networking (i.e., Cisco Networks).
What is Linux ? Why ?
• Linux desktops use a GUI, but it also has a more
efficient tool for carrying out the same actions as a GUI,
the command-line interface (CLI).

• CLI is a text-based
interface that accepts
commands that you
type into it.
Basic Command Syntax
• Command is a software program that when executed on
the CLI, performs an action on the computer.
• A command runs a process on the operating system,
which then causes the computer to perform a job.
• Most commands follow a simple pattern of syntax:

command [option(s)] [argument(s)]


 Command is the command’s name that you want to perform.
 Option or flag modifies a command’s operation.
 Argument or parameters specifies any necessary information for the
command.
Basic Command Syntax (Cont.)
command [options…] [arguments…]
• Simple command to list information about the
files/directories.

• Argument can be used to specify something for the


command to act upon.
Basic Command Syntax (Cont.)
command [options…] [arguments…]
• Options can be used to alter the behavior of a command.
• To invoke it, use (-) or (--).
sysadmin@localhost:~$ ls -l
total 32
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Desktop
drwx------ 4 sysadmin sysadmin 4096 Dec 20 2017 Documents

drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Videos
sysadmin@localhost:~$ ls -r # ls --reverse (both apply the same behavior)
Videos Templates Public Pictures Music Downloads Documents Desktop
sysadmin@localhost:~$ ls -rl # ls -lr or ls -r -l
total 32
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Videos
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Templates
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Public
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Pictures
drwx------ 2 sysadmin sysadmin 4096 Dec 20 2017 Music

Basic Linux Command
Printing Working Directory pwd [options…]
• The pwd command prints your current location within the
filesystem.

sysadmin@localhost:~$ pwd
/home/sysadmin
Basic Linux Command (Cont.)
Changing Directories cd [options…] [path]
- Relative Paths:
▪ A relative path gives directions to a file relative to your
current location in the filesystem.

sysadmin@localhost:~$ cd Documents
sysadmin@localhost:~/Documents$
Basic Linux Command (Cont.)
Changing Directories cd [options…] [path]
- Absolute Paths:
▪ Specify exact location of a file/directory in the
filesystem.
▪ It always starts at the root directory
begins with ‘/’

sysadmin@localhost:~$ cd
/home/sysadmin/Documents
sysadmin@localhost:~/Documents$
Basic Linux Command (Cont.)
Changing Directories cd [options…] [path]
- Here are some shortcuts to help you
navigate:
sysadmin@localhost:~/Documents/School$ cd ~
▪ (cd ~sysadmin@localhost:~$
or just cd) goes to user’s home directory.

sysadmin@localhost:~/Documents/School$ cd ..
▪ (cd ..) moves one directory up.
sysadmin@localhost:~/Documents$

▪ (cd -) moves to your previous directory. (Like press on


Back)
Basic Linux Command (Cont.)
Listing Files
sysadmin@localhost:~$ ls -l

total 36

drwx------ 4 sysadmin sysadmin 4096 Dec 20 2017 Documents


▪ d/-  directory / regular file
▪ -rw-rw-r--
-rw-rw-r-- 1 sysadmin sysadmin 21 Feb 24 11:58 file1.txt
 Permissions (user, group, others)
• ‘r--’ refers to read-only.
• ‘rw-’ refers to read and write.
• ‘---’ refers no read or write.
• ‘--x’ refers allowed for execution.
• ‘21’ refers file size.
• ‘sysadmin sysadmin’ refers (user owner , group owner).
Basic Linux Command (Cont.)
Administrative Access
sudo [OPTIONS] COMMAND
• The sudo Commands:
• Stands for superuser do.
• Let's you perform tasks that require administrative
or root permissions.

sysadmin@localhost:~$ sudo ls
[sudo] password for sysadmin:
Basic Linux Command (Cont.)
Changing File Permissions
chmod [<SET><ACTION><PERMISSIONS>]... FILE
• <SET>:
• ‘u’  user, ‘g’  group, ‘o’  others, ‘a’  all
• <ACTION>:
• ‘+’ / ‘-’  Add/Remove permission, ‘=’  Specify exact
permission
• <PERMISSION>:
• ‘r’  read, ‘w’  write, ‘x’  execute
-rw-r--r-- 1 sysadmin sysadmin 647 Dec 20 2017
hello.sh
sysadmin@localhost:~$ chmod u+x hello.sh
Basic Linux Command (Cont.)
Changing File Permissions
• Permissions can be represented by masks:
• rw-r--r--  represented with decimal as 644 (110100100 binary)
• rwxr-xr-x  represented with decimal as 755 (110101101 binary)
• So, you can set permissions bits directly by using masks as
follow:
-rw-r--r-- 1 sysadmin sysadmin 647 Dec 20 2017
hello.sh
sysadmin@localhost:~$ chmod 750 hello.sh
-rwxr-x--- 1 sysadmin sysadmin 647 Dec 20 2017
hello.sh
Basic Linux Command (Cont.)
Viewing Files cat [OPTIONS] [FILE]
• The cat Commands:
• Stands for concatenate.
• Displays the entire contents of the file, hence why it
is mainly recommended for smaller files.

sysadmin@localhost:~$ cat file.txt


This is my test file
sysadmin@localhost:~$
Basic Linux Command (Cont.)
Create File
• Using touch Command touch [OPTIONS] FILE
sysadmin@localhost:~/test$ touch mynotes.txt
sysadmin@localhost:~/test$ ls
mynotes.txt

• Using > “Redirecting Standard Output”


sysadmin@localhost:~/test$ > mytest.txt
sysadmin@localhost:~/test$ ls
mynotes.txt mytest.txt
Basic Linux Command (Cont.)
Copying Files
cp [OPTIONS] SOURCE DESTINATION
# Copy file to Documents directory
sysadmin@localhost:~$ cp file.txt /Documents

# Copy file to the current directory


sysadmin@localhost:~/Documents$ cp /home/sysadmin/file.txt .

# Copy and rename file


sysadmin@localhost:~$ cp /Desktop/file.txt
/Documents/newFile.txt

# Copy entire directory


Basic Linux Command (Cont.)
Removing Files rm [OPTIONS] FILE
Remove file:
sysadmin@localhost:~$ rm file.txt
sysadmin@localhost:~$ ls file.txt
ls: cannot access file.txt: No such file or
directory
Remove directory:
sysadmin@localhost:~$ rm Directory_backup
rm: cannot remove 'Directory_backup': Is a directory
sysadmin@localhost:~$ rm –r Directory_backup
sysadmin@localhost:~$ ls Directory_backup
ls: cannot access Directory_backup: No such file or
directory
Basic Linux Command (Cont.)
Create Directories mkdir [OPTIONS] DIRECTORY
Create directory:
sysadmin@localhost:~/Desktop$ mkdir my_directory
sysadmin@localhost:~/Desktop$ ls
my_directory

Passing -p to create parent directory if not exists:


sysadmin@localhost:~/Desktop$ mkdir –p
my_directory/Test
sysadmin@localhost:~/Desktop$ ls
my_directory
Basic Linux Command (Cont.)
Removing Directoriesrmdir [OPTIONS] DIRECTORY
For empty directory:
sysadmin@localhost:~$ rmdir Directory_backup
sysadmin@localhost:~$ ls Directory_backup
ls: cannot access Directory_backup: No such file or
directory
For not empty directory:
sysadmin@localhost:~$ rmdir Directory_backup
rmdir: failed to remove 'Directory_backup': Directory not
empty
sysadmin@localhost:~$ rm –r Directory_backup
sysadmin@localhost:~$ ls Directory_backup
ls: cannot access Directory_backup: No such file or
Basic Linux Command (Cont.)
Filtering Input grep [OPTIONS] PATTERN [FILE]
The grep command is a text filter that will search input and return
lines which contain a match to a given pattern.
sysadmin@localhost:~$ grep 'root' /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:1000:37::/root:
sysadmin@localhost:~$ grep '^root' /etc/passwd
root:x:0:0:root:/root:/bin/bash
sysadmin@localhost:~$ grep '[0-9]' Documents/profile.txt
I am 37 years old.
3121991
I have 2 dogs.
sysadmin@localhost:~$ grep -i "TEst" file.txt
This is my test file
Basic Linux Command (Cont.)
Viewing Processes ps [OPTIONS]
The ps command will display the processes that are
running in the current terminal by default.
sysadmin@localhost:~$ ps
PID TTY TIME CMD
87 pts/0 00:00:00 bash
102 pts/0 00:00:00 ps
# The -e option will display every process
sysadmin@localhost:~$ ps -e
PID TTY TIME CMD
33 ? 00:00:00 rsyslogd
37 ? 00:00:00 cron
39 ? 00:00:00 sshd
103 pts/0 00:00:00 ps

Basic Linux Command (Cont.)
Check Connectivity
ping [OPTIONS] [hostname_or_IP_address]
The ping command is used for checking whether a network
or a server is reachable.
sysadmin@localhost:~$ ping google.com
PING google.com (142.251.37.174) 56(84) bytes of data.
64 bytes from 142.251.37.174: icmp_seq=1 ttl=116 time=49.3 ms
64 bytes from 142.251.37.174: icmp_seq=2 ttl=116 time=46.5 ms
64 bytes from 142.251.37.174: icmp_seq=3 ttl=116 time=46.6 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 13067ms
rtt min/avg/max/mdev = 46.543/47.337/49.258/1.021 ms
Package Management
Package Management
• Package management is a system by which
software can be installed, updated, queried or
removed from a filesystem.

• There are many different software package


management systems.

• For this course we use Ubuntu, a derivative of


Debian.
Package Management (Cont.)

Package Management
• The apt-get (Advanced Package Tool) is a front-end
program to the dpkg tool (Debian package management
system) which makes management of packages even
easier.
Package Management (Cont.)
Package Management
• Update Packages List
▪ Package files are commonly installed by downloading them
directly from repositories located on Internet servers.
▪ The Debian repositories contain more than 65,000 different
packages of software.
▪ Before installing a package, it is good practice to refresh the list
of available packages using the apt-get update command.
sysadmin@localhost:~$ sudo apt-get update
[sudo] password for sysadmin:
Ign file: amd64/ InRelease
Ign file: amd64/ Release.gpg
Ign file: amd64/ Release
Reading package lists... Done
Package Management (Cont.)
Package Management
• Search Package
▪ To search for keywords within these packages, you can use the
apt-cache search command.
apt-cache search [keyword]
sysadmin@localhost:~$ apt-cache search nano
nano - small, friendly text editor inspired by Pico

sysadmin@localhost:~$ apt-cache search ssh


ssh - secure shell client and server (metapackage)
openssh-
server - secure shell (SSH) server, for secure access from remote machines
openssh-
client - secure shell (SSH) client, for secure access to remote machines
Package Management (Cont.)
Package Management
• Installing Packages
▪ You can install the package you found by use the apt-get
install command.
sudo apt-get install [package]
sysadmin@localhost:~$ sudo apt-get install nano
[sudo] password for sysadmin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
filters
The following NEW packages will be installed:
nano
0 upgraded, 1 newly installed, 0 to remove and 0 not
Package Management (Cont.)
Package Management
• Updating Packages
▪ For updating all packages of the system:
1. Update the cache of all packages with apt-get update.
2. Execute the apt-get upgrade command and all packages
and dependencies will be updated.

sysadmin@localhost:~$ sudo apt-get update



sysadmin@localhost:~$ sudo apt-get upgrade

Package Management (Cont.)
Package Management
• Removing Packages
▪ apt-get purge: Deletes all package files.
▪ apt-get remove: Deletes all but the configuration files
for the package.
sysadmin@localhost:~$ sudo apt-get purge nano
Reading package lists... Done

Building dependency tree

Reading state information... Done

The following packages will be REMOVED:


Any Questions

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy