[go: up one dir, main page]

0% found this document useful (0 votes)
0 views31 pages

section_2

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 31

Operating

System
PRESENTED BY SALMA KISHK
Outline
Review
users type
create, delete and switch users
Introduction to linux file system
navigate file system
create, copy, moves, remove directories and files
Linux component

command [-option] [-option] [--option(word)] [argument]


commands
ls
cat
uname
cal 10 2023
date
man
tree
apt
What is a user account?
A user account is a systematic approach to track and monitor the usage of system resources. Each user
account contains two unique identifiers; username and UID.

user account

UID (User ID)


default shell, and
password.

GID (Group ID) home directory

john:x:1002:1002:,,,:/home/john:/bin/bash
Users type
The root user account
This is the main user account in Linux system.
It is automatically created during the installation.
It has the highest privilege in system.
It can do any administrative work and can access any service.
id : 0

The regular user account


This is the normal user account. During the installation, one regular user account
is created automatically.
After the installation, we can create as many regular user accounts as we need.
It can perform only the tasks for which it is allowed and can access only those files
and services for which it is authorized.
id : >= 1000

The service account


Service accounts are created by installation packages when they are installed.
dummy user dosn’t have home directory
id : 0<id<1000
Practice
id user_name
display user id

tail /etc/passwd
get information about users in system

tail /etc/shadow
get users’ password
Practice
sudo su -
switch to root user

su - username
switch to username

useradd -u user_id -d home_directory -s


default_shell_used
add new user
Practice
passwd user
add password for user

adduser user_name
another way to add user

userdel -r username
delete user and home directory
task
Create a user account with the following
attribute:

username: sara
Fullname/comment: sara mohamed
Password: 1234

show user details


File system
Think of
– File system as a building
– Directory is a room
– File is a desk

window vs linux
File system for linux

/etc ==> it holds the configuration files of the system (passwd,


shadows and group)

/var ==> Variable data of the system, these files are dynamically
changed
(database files, mail directory, log files, printer and website content)
File system for linux

/bin ==> user commands (binaries) ==> ls command

/sbin ==> system administration command

/lib ==> The /lib directory contains kernel modules and those shared
library images (the C programming code library) needed to boot the
system and run the commands in the root filesystem
File system for linux

/home/ ==> standard user home (ali, ahmed, sami)


ex. /home/ali, /home/sami, /home/ahmed.

/root ==> super user home


File system for linux

/tmp ==> temp files that is deleted after 10 days

/dev ==> system devices (hard disks)


File system for linux

/dev ==> system devices (hard disks)

/boot ==> to boot the operating system (grub)

/usr ==> shared files between users


navigate file system
pwd
print work directory

cd path
change directory

cd -
last working directory

cd or cd ~
go to home directory

cd ~user_name
go to username home directory

. ===> current working directory


.. ===> parent directory
How to get path

1- Absolute path 2-Relative path

is defined as the path


is defined as the specifying related to the present
the location of a file or working directly(pwd). It
directory from the root starts at your current
directory(/). directory and never starts
with a / .
For example absolute path : /home/cory
relative path : ./../../cory

destination

current directory
For example absolute path : /home/jono/photos
relative path : ./photos

current directory

destination
task

destination

current directory
task
absolute path : /usr/lib
relative path : ./../../../usr/lib

destination

current directory
create, copy, moves, remove directories and
files
file directory

touch file_name1 mkdir dir_name1


file_name2 ..... dir_name2 dir_name3....
create files create directories

cp source_directory
cp source_file directory
destination_file copy dir (if empty)
copy file put -r (recursive) if has
contents
create, copy, moves, remove directories and
files
file directory

rmdir dir_name1 dir_name2


rm file_name1 file_name2
dir_name3....
.....
delete directories if
delete files
empty

rm -r dir_name ------------> delete dir if not empty in this case terminal ask
before delete any of dir contents

rm -rf dir ----> remove with out ask


Task
Create the following hierarchy under your home directory?

then Remove dir11 in one-step.


Task
Copy the /etc/passwd file to your home directory making its
name is mypasswd.

Rename this new file to be oldpasswd.

Hint : search about mv using man


Task
Copy the /etc/passwd file to your home directory making its
name is mypasswd.

Rename this new file to be oldpasswd.

Hint : search about mv using man


Moving and Renaming Files and Directories
mv options source(s) target
-i ---------> Prevents you from accidentally overwriting existing files or
directories
Viewing File Content
cat fname

more fname
• Scrolling keys for the more command
– Spacebar: moves forward on screen
– b: move back one screen
– /string: search forward for pattern
– q: quit and return to the shell prompt

head –n fname
show first n lines

tail -n fname
show last n lines
Editing Files with gedit
1- The gedit text editor is a graphical tool for
editing text files.

gedit new_filename

2- Nano is a user-friendly, simple text editor, Unlike vim


editor or any other command-line editor, it doesn’t have
any mode. It has an easy GUI(Graphical User Interface)
which allows users to interact directly with the text in
spite of switching between the modes as in vim editor.

nano new_filename
task
create text file using gedit or nano
called hello.text and cat the contents
Display the first 4 lines of /etc/passwd

Display the last 7 lines of /etc/passwd


Any questions ?

You might also like