Académique Documents
Professionnel Documents
Culture Documents
PRINCIPLES OF UNIX
As you know each operating system has minimum three parts which are hardware, Kernel &
shell.
HARDWARE: – All the peripherals which are present inside your system (Processor,
Motherboard, RAM, etc) all are comes under the hardware.
KERNEL: – UNIX kernel is the heart of the Operating system. It is the master program
which controls the computer’s resources, allots them to users and to different task.
SHELL: –UNIX shell is the command interpreter for the commands input by the user. Each
user has its own shell; multiple users may not be having the same shell.
Functions of shell
A It acts as the command interpreter between the user & hardware (Kernel).
B It expands the various meta characters used in file operations
C It is responsible for the redirection output of one command as the input for
the other.
D It is responsible for executing the shell scripts which uses the
programming language. (Commands)
E It is responsible to setting the environment for the user.
LINUX
FEATURES OF LINUX
1. IT IS AN UNIX LIKE OPERATING SYSTEM
2. IT HAS WIDE HARDWARE SUPPORT
3. IT HAS SUPPORT FOR SMALL AS WELL AS LARGE APPLICATION
4. IT SUPPORTS MANY NETWORKING PROTOCOLS & CONFIGRATIONS
5. IT HAS SIX VIRTUAL CONSOLE (ALT+F(1–6)) & ONE GRAPHICAL
CONSOLE ON (ALT+F7)
2. touch –to create a blank file & to modify the date & time of file & directory
touch <filename (the file should be in the working directory only)>
18. who to see the information about the users logon to local machine
1. man <command>
2. info <command>
3. <command> ––help
4. whatis <command>
5. In GUI mode the help application is present inside the panel in the start menu
The Red Hat Enterprise Linux has the hierarchy structure for the file system.
In the RHEL each and every file’s address start from only the “/”.(slash )
Like Window in RHEL also some system directories are made from system side at the time
of installation like,
/boot : – Kernel & booting related files
/bin : – Binary files related to user
/dev : – Storage device related files
/etc : – Configuration files
/home : – home directory for all the users
/lib : – Library files
/media : – By default mount point for the removable storage when you mount
from GUI mode
/misc : – Miscellaneous files
/mnt : – Mount point for the removable storage
/opt : – Mount point for the removable storage
/proc : – System information (Hardware)
/root : – Home directory of user root (Administrator)
/sbin : – Binary files related to system
/selinux : – Selinux related (Security enhanced Linux like firewall)
/srv : – Server related
/sys : – System information only used by the system only
/tmp : – Application & user buffer
/usr/bin : – User related binary files
/usr/sbin : – System related binary files
/usr/share : –Sample configuration files
/var : –Variable files
As you all know in Red Hat we do our maximum on the console (command prompt) so we
do not have the icons and pictures from where we will know which one is file or directory.
For that we use the command ls –l which gives us the output like,
In the above case you will some different characters at the starting, from where you will
the kind of file.
BASH SHELL
As you know the role of shell in system, you also know that every user has its own shell.
There are many shells present in your system like,
/bin/bash, /bin/ksh, /bin/csh, /sbin/nologin, etc.
But the most of the work is done on the Bash shell & it is also the by default shell.
One of the most important features of Linux is the streaming nature of data known as
standard input, standard output & standard error. This allows the input from program to
come from any source and the output to go to any source.
PIPES: –
Two of the basic tenets of UNIX philosophy are make small programs that do thing well and
expect the output of every program to become the input to another.
Command1 | Command2
Any command that writes to standard output can be used on left–hand side of a pipe.
Any command that’s read from standard input can be used on the right–hand side.
Multiple commands can be chained together with pipes.
VI editor: –
The vi is standard editor under Linux & Unix systems. And the newer vim editor is improved
editor, standard Red Hat editor.
To start vi,
vi <filename> If the filename exists, the file is opened the content are displayed, If file does
not exist it creates the file when the edits are saved for first time.
In Insert mode, your keystrokes are actually data entered into your document rather than
commands.
In command mode you will get to do the actions like cursor movement , change, delete,
yank(copy), put & search.
In final ex mode, you will going to do configuring, exiting, saving, search and replace.
Command mode
ndd deletes the “n” number of lines, Any number can be precede any of the change, delete, and
yank or put commands.
Undoing changes
u undoes most recent change
<ctrl–r> redo last undone change
EX MODE: –
USER MANAGEMENT: –
User: –The application or service or resource which controls the system in efficient manner
with some authentication process is user. There are three types of user,
Group: –If we want give the same permissions or rights to multiple user, we create a group of
that users, to decrease the administrator load.
There are two types of group
Primary
Secondary
root:x:0:0:root:/root:/bin/bash
Where root is username, x stand for the link to shadow file, 0 is stand for UID, 0 is stand
for GID, root is stand for the comment, /root is the home directory, /bin/bash is the shell
of that user.
5. cat /etc/shadow: – to see the encrypted password for the entire user.
9. cat /etc/group: – to see the list of all groups on that local machine with all the
members.
group: x:503:usera, userb
Where ‘group’ is group name, ‘x’ is the link to the shadow file, 503 is gid and
usera & userb are the members of that group.
As all you know is, Linux has one of the most powerful features as secure
operating system. So to keep that, we need to implement some permission on files & directories.
There are three modes of file accessing,
a. Read only
b. Write
c. Execute
But as you know Linux is secured operating system so you have to give permissions as per
requirement & as per the security concern. So in Linux, by default we need to remove
permissions from file & directory. For that we set user mask to assign by default permission,
umask is the command with you can see the user mask of particular user & also you can set
the user mask.
By default umask of user root is 0022 & for normal user it is 0002.
So now default permission for any file or directory will be,
Default permissions – umask.
In this example you are getting 10 permissions which you have to divide
in 4 categories which will be like follows
d | rwx | r–x | r–x
special owner group other
permissions owner
To change the permissions we require giving the command in the following syntax.
chmod <permissions which you have to assign in no’s> <filename with full path>
EX. chmod 0777 /home/user1/test/
Symbolic
In symbolic method you have to assign the permissions with the help of characters.
User or owner =u Read=r
Group owner=g Write=w
Other=o Execute=x
To change the permission we require giving the command in the following syntax
EX. chmod u+w,g+w,o+r /home/user1/test
“+” is used to add the permission
“–“ is used to remove the permission
“=” is used to assign the permission
3. chown: – to change owner of file or directory.
chown <new owner name> <filename with full path>
* IMPORTANT NOTE
FOR PRACTICE: –
1. groupadd group
2. useradd –G group user1
3. useradd –G group user2
4. useradd user3
5. passwd user1
6. passwd user2
7. passwd user3
8. login with user’s user1,user2 & user3 on different console
(F1=root, F2=user1, F3=user2, F4=user3)
9. On F1,
mkdir /share
chmod 0777 /share
10. On F2
mkdir /share/user1
ls –l /share
chgrp group /share/user1
ls –l /share
cat > /share/user1/file
ls –l /share/user1/file
chgrp group /share/user1/file
ls –l /share/user1/
11. On F3
cat /share/user1/file (READ)
cat >> /share/user1/file (WRITE)
12 On F4
cat /share/user1/file (READ)
cat >> /share/user1/file (Permission Denied)
12. On F2
chmod 0646 /share/user1/file
ls –l /share/user1/
13. On F3
cat /share/user1/test (READ)
cat >> /share/user1/file (Permission Denied)
14. On F4
cat /share/user1/file (READ)
cat >> /share/user1/file (WRITE)
INODES: –
ext2 & ext3 file systems keep a list of the files they contain in a table called
an inode table. An in individual entry in inode table is inode.
An inode table contains a list of all files in an ext2 & ext3 filesystems
An inode table contains information about file (the metadata): –
- file type, permissions, UID & GID
- link count (count of path names pointing to this file)
- the file size with modification date & time
- pointers to the files data blocks on disk
- other data about the file
DIRECTORIES: –
We commonly think of a directory as a container for files & other
directories, in fact directories is a mapping between the file names that humans use to reference
files and inode numbers
cp & inode
1. Allocates a free inode number, placing a new entry in a inode table
2. Copies data into a new file
EXAMPLE: –
1. cat > /root/file1
2. ls –il /root/file1
3. cp /root/file1 /
4. ls –il /file1
EXAMPLE: –
1. cat > /root/file2
2. ls –il /root/file2
3. mv /root/file2 /
4. ls –il /file2
5. ls –il /root
rm & inode
1. Decrements the link count, thus freeing the inode number to be reused
EXAMPLE
1. cd /root
2. touch filea fileb filec
3. ls –il /root
4. rm –rf filea fileb filec
5. ls –il
6. touch file1 file2 file3
7. ls –il
Inode no of files file1, file2 & file3 will be same as the inode no of filea,
fileb & filec.
EXAMPLE: –
1. cat > /root/file
2. mkdir /root/dir
3. ln /root/file /root/dir/file
4. ls –il /root
5. ls –il /root/dir
Inode no will same for both files, because they are hard linked to each
other.
Archiving files: –
Archiving files is the process of incorporating a copy of those files into a
single archive file. These makes easier to back up, store & transfer.
Compressing file: –
Compression is used to make the file size less, and used save the
hard–disk size.
Example
To look your bash shell like follows;
[root@server~] you should give command;
PS1=”[\u@\h\w]”
Aliases
Aliases let you create shortcuts to commands.
alias command is used to see the set aliases.
alias c=clear
After this command you does not require to type whole command to clear
the screen just say “c”.
To make the aliases permanent we have to make the entry of aliases into
file .bashrc which is present in user’s home directory.
/etc/profile
/etc/profile.d/
~/.bash_profile
~/.bashrc
Example
8. To find files in GUI mode, you will get tab in start/system/Search for
files
crontab –e