Professional Documents
Culture Documents
Lab 2 - Linux Permissions and Redirection
Lab 2 - Linux Permissions and Redirection
and Redirection
What is an operating system?
Main objective of the OS:
1. It provides the programmers a set of abstract resources of hardware.
2. It manages the hardware resources according to the usage of the programs.
Linux Basics
General commands:
whoami : prints the current user
who : display a list of all users
uptime : display the duration
date : display the current date and time
man <command> : manual of the linux
commands
Linux Basics
Path and Directory commands:
pwd : print working directory
cd : change directory
cd .. it goes to a single file above the
current directory
mkdir –p : creates
multiple subdirectories
at the same time
Linux Basics
Directory / file creation and manipulation
rmdir : remove directory
rm : removes files /
directories
rm –i : removes file /
directory by prompting
Linux Basics
Directory / file creation and manipulation
cp : copy file / directory
cp –r : recursive copy, which is
used to copy directories
cp <file_name> <path> : it
copies a file to a certain
directory
Linux Basics
Directory / file creation and manipulation
cp <file_name>
<another_name> : it copies the
file with a new name in the same
directory
mv : move or rename file /
directory
Linux Basics
More linux commands:
pipe ( | ) : it is used as an inter process communication, to join multiple commands.
grep : it is used to search for a certain pattern in a file
ls –l | grep file this command is used to list all files / directories, where the file /
directory name contains “file”.
Linux Basics
More linux commands:
grep –i : it searches for lines that contain a certain pattern
grep –n : it searches and display the number of the lines that contain a certain
pattern
Linux Basics
More linux commands:
grep ^string : it searches for the lines that start with a certain pattern
grep string$ : it searches for the lines that end with a certain pattern
Sudo user:
A normal user with root privileges
It has permission to control, read and execute every file on
the system
Normal user:
Any user that isn’t a root user
It has a limited control on the files
Linux permissions and users
Each user has its own username, password, and permissions.
All users have a user ID (UID) and a group ID (GID).
Group is set of users that has permission to access special files (read, write,
execute) and that owner and the root can manage level of accesses to them.
Every user must belong to at least one group
Every file and directory is marked with a UID and GID
Linux permissions and users
The SU command:
su : switch user, it is used to switch to the home directory of different users
This command changes the UID and GID of the existing user
The sudo command:
It gives to the certain users only a few superuser permissions.
it enables the user to issue some commands that only the root can issue
The sudo command caches the password for 5 minutes
Linux permissions and users
Root user
UID 0 (zero)
Can access any file, regardless of UID or GID
To set the root password: