(CC - 23) Lab 2
(CC - 23) Lab 2
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 ?
• Cell phone, tablet, laptop and desktop all need an operating system
to run applications.
• 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:
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$
total 36
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.
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