TOPIC 1: INTRODUCTION TO LINUX (PART 1)
FUNDAMENTALS OF ICT – ETC 2191 UTHPALA SAMARATUNGA
TOPIC 1 (PART 1): CONTENT
What is Linux?
Linux Filesystem
Basic Linux Commands
File Management
User Management
OPERATING SYSTEM
Manages activities and resources of a computer.
• software that acts as an interface between
hardware and user
• provides a layer of abstraction for application
developers
OPERATING SYSTEM
Features provided by an operating system:
• ability to execute programs (and multi-tasking)
• memory management (and virtual memory)
• file systems, disk and network access
• an interface to communicate with hardware
• a user interface (often graphical)
Kernel: The lowest-level core of an operating system.
LINUX
Linux: A kernel for a Unix-like operating system.
Unix is a family of operating systems that derive
from the original AT&T Unix.
• Development started at Bell Labs by Ken Thompson,
Dennis Ritchie, and others.
• Written in C
LINUX
Linux: A kernel for a Unix-like operating system.
• Commonly seen/used today in servers, mobile/embedded
devices, ...
• An operating system kernel first released on September 17,
1991, by Linus Torvalds.
GNU: A "free software" implementation of many Unix-like
tools
• Many GNU tools are distributed with the Linux kernel
Distribution: A pre-packaged set of Linux software
• Examples: Ubuntu, Fedora, …
LINUX DISTRIBUTIONS
https://upload.wikimedia.org/wikipedia/commons/b/b5/Linux_Di
stribution_Timeline_21_10_2021.svg
OPERATING SYSTEM
Key features of Linux:
• Open-source software: source can be downloaded
• Free to use
• Constantly being improved/updated by the community
LINUX DESKTOP
Desktop environments: Gnome, KDE, MATE, XFCE, Cinnamon, …
SHELL
Shell: An interactive program that uses user input to manage the
execution of other programs.
• A command processor, typically runs in a text window.
• User types commands, the shell runs the commands
• Several different shell programs exist:
• bash: the default shell program on most Linux/Unix systems
Other shells: Bourne, csh, tsch, …
SOME BASIC SHELL COMMANDS
command description
exit logs out of the shell
ls lists files in a directory
pwd print the current working directory
cd changes the working directory
man brings up the manual for a command
LINUX
FILESYSTEM
SPECIAL FILE NAMES
/ root directory
. The current directory
.. The parent (previous) directory
~ My home directory (~username for other users home directories)
Examples:
/home/myuser/hello
./a
../fot/egt
LINUX TERMINAL
The “prompt”
The current directory (“path”)
The host
LINUX COMMANDS: BASICS
To execute a command,
type the command name ls -l /etc
followed by flags (optional)
and arguments
Command Arguments
name Flags
(optional)
BASIC COMMANDS: FILESYSTEM
pwd command is used to
display the current working
directory (print working
directory)
BASIC COMMANDS: FILESYSTEM
ls command lists the files of
the current working
directory
ls command can be
combined with many
options to list the files in
different ways (e.g.: ls -la
command shows a detailed
list of files, including hidden
files)
BASIC COMMANDS: FILESYSTEM
cd command is used to
change the working
directory.
BASIC COMMANDS: FILESYSTEM
cd command can be used
with .. to traverse to the
parent directory.
cd command can be used
with ~ to traverse to the
home directory.
. represents the current
working directory.
BASIC COMMANDS: WILDCARDS (METACHARACTERS)
* and ? can be used as a
wildcard for many
commands to filter the
output of commands.
* is used to match 0 or
more characters while ?
matches with a single
character.
BASIC COMMANDS: DIRECTORIES
mkdir can be used to create directories.
mkdir mydir
mkdir mydir mydir2
mkdir ./mydir/testdir
mkdir –p ./mydir/testdir (creates mydir if not available)
mv command can be used to move/rename directories.
mv mydir mydir2
cp command can be used to copy directories.
cp -r mydir mydir2
BASIC COMMANDS: DIRECTORIES
rmdir can be used to remove directories. Directories should be empty if this
command is used.
rmdir mydir
rmdir mydir mydir2
rm –rf mydir (-f flag hides the confirmation for every file and directory)
BASIC COMMANDS: HELP
man command displays the manual of a command if available.
man mkdir
--help argument can be used after a given command to display supported arguments
of that command.
mkdir --help
BASIC COMMANDS
echo command dumps the entire file into standard output and displays it in the
terminal.
clear command clears the terminal screen.
FILE MANAGEMENT
To easily create, edit and save files in Linux, a simple editor can be used
• nano
• gedit
• vim
• emacs
To create a file in the current working directory:
nano examplefile.txt
To create a file in the current working directory without the use of a text editor:
touch examplefile.txt
FILE MANAGEMENT: VIEW FILES
There are multiple commands to display the contents of a file in the terminal itself.
cat command dumps the entire file into standard output
cat examplefile.txt
less command displays the file allowing forward, backward movement within it
less examplefile.txt
head command displays the top part of the file
head examplefile.txt
head –n50 examplefile.txt (displays the first 50 lines)
tail command displays the last part of the file
tail examplefile.txt
FILE MANAGEMENT: COPY/MOVE/DELETE FILES
cp command can be used to make copies of files
cp file1.log file2.log
cp file1.log ./examplefolder/ (copies the file into the
examplefolder in the current working directory)
mv command can be used to move a file
cp file1.log ./examplefolder/ (moves the file into the
examplefolder in the current working directory)
mv command can also be used to rename a file
mv file1.log file2.log
rm command can be used to delete a file
rm file1.log file2.log
USER MANAGEMENT
adduser command creates a new user. Its better to use the adduser command instead
of the useradd command since it configures the user related settings for you.
adduser exampleuser
passwd command can be used to change the password of users.
who command shows the users who are logged in the system currently while whoami
command shows the user that you are currently logged in as.
USER MANAGEMENT
su command allows you to switch to new account while in the terminal. You will be
prompted for the password for the requested user. Type exit to return back to the
previous user.
su exampleuser
su command can be used without arguments to switch to the root user account.
When you are the root user, you don’t need to enter passwords to switch accounts.
su
By default, the root account is not enabled by default in Ubuntu. To enable the root
account:
sudo passwd root
SUDO
sudo is a program for Unix-like computer operating systems (e. g. Linux) that allows
users to run programs with the security privileges of another user, by default the
superuser. It originally stood for "superuser do" as the older versions of sudo were
designed to run commands only as the superuser.
To run a command with sudo, simply add the sudo command before the command
you desire to run.
You may need to enter the current password of the user when running the sudo
command. The current user should also have the privileges to run the sudo
command.
BASIC COMMANDS: SYSTEM
logout command can be used to logout from the current user.
shutdown command can be used to shutdown the system.
shutdown -h now
shutdown -h +3
shutdown -h 00:45
shutdown -h +5 “System is going to shut down in 5
minutes”
Alternatively, the following commands can also be used to shutdown the system.
halt, init 0, poweroff
BASIC COMMANDS: SYSTEM
shutdown command can be used to reboot the system as well.
shutdown -r now
shutdown -r 0
shutdown -r +6
shutdown -r 22:00 “System is going to reboot!!”
Alternatively, the following commands can also be used to reboot the system.
halt, init 6, reboot
Q &A