Structure of the GNU/Linux Operating System

Provido

Katılımcı Üye
21 Eki 2015
477
1
Hello TurkHackTeam Family, today I will talk about “Structure of the GNU/Linux Operating System”. It will feel like a lesson and I won’t keep it long.


THSe2J.png



Titles of Subject

• Root
• GID
• UID
• Group Management
• Creating Group
• Change the Group ID
• Add User to Group
• Delete User from Group
• Setting Password to a Group
• Delete Group
• User Management
• Creating User
• Setting Password to a User
• Changing the User ID
• Delete User
• Getting Information About User
• Shadow Directory
• Difference Between Su and Sudo
• Switch to root user with Su command
• Switch to root user with Sudo Su command
• Switch to another user
• File Ownership and permissions


First, let me talk about the meanings of some terms that I will talk about in my lesson.


Root

They are users that have full authority on Linux/Unix systems. Root users have unlimited power.

GID

GID stands for Group ID. If group IDs are defined as “0”, group has root permissions.

UID

UID stands for User ID. IF user IDs are defined as the same way “0”, the user have root permissions.


First, as you know Linux distributions have a multi user system. Therefore, we don’t only process with only one user, but we can open more than one user and make operation. The most important thing for us is the User ID. If you say what is this User ID; Access rights are granted according to this ID. There can be more than one user with this ID. If “Administrator” can be more than one in Windows, Linux systems have more than one “root” user. Generally, the reason for opening more than one user with the same access rights as the root in Linux systems is if the root user’s password is forgotten, the other backup users who have root user rights can log in the system.

On Linux systems, default users come automatically. We have a code to see these default users. In fact, we can use this code to see all users (Root etc.).

First, we open terminal and


Kod:
cd /etc/


We are writing.


0OVV2S.jpg



Then


Kod:
cat passwd


We are writing this. Here “passwd” is the file where the users are located. We can get the necessary information here.


NPKz6T.jpg



All default users and users that have Root permissions are shown.


9Nzz6U.jpg



You saw “root:x:0:0”. If you say what this is; it means username(root), password(x), user ID(0), group ID(0). If you have noticed that users at the bottom, it says “/nologin” on the right side. This means that they can’t login in the background. If you scroll down, you will see your own username on above the bottom side. We have made a little entrance with you and we have looked what is and what isn’t. Now let’s get to our lesson.


Group Management


We use some commands to perform operations on group. I will show you their usage but first let me talk you about where these groups are.


Groups


Kod:
/etc/group


are located in this.

Now let’s see, but first


Kod:
cat group


We are typing this.


Nb4eOd.jpg



Then all the groups appear.


Creating Groups


Let’s create a group together.


Kod:
groupadd grupismi


We are writing this.


a6OxOa.jpg



After typing, our group is created. Let’s look at our group. For this;


Kod:
cat group


we are writing this.


LdOMV9.jpg



At the bottom, our group came out. Now we have seen our group at the bottom but, we may not always want to go to the bottom side.
For this first;


Kod:
cat /etc/group | grep grupismi


we are writing this. Grep is a command that gives use results according to the criteria we are looking for in a particular section.


NAbUWA.jpg



As you can see, it showed us our group and our GIP and UID.


QxdTOL.jpg



As you can see, we have seen how to create a group and learn how to find it. Now we have come to perform through this group we have created.


Changing the Group ID

First from the terminal


Kod:
sudo su


We are taking root authorization with this. Then


Kod:
cd /etc/


we log in to the etc directory with this code. After that


Kod:
groupmod –g groupID grupismi


we are typing this.


I8QP1A.jpg



We finished. Now to see our group


Kod:
catcat /etc/group | grep grupismi


we are writing this.


Q6LMTf.jpg



BPK5d3.jpg



Whatever group ID you have typed, that number will appear.

Now let’s assume we want to change the name of the group. What are we gonna do? For this;


Kod:
groupmod –n yenigrupismi değiştirilecekgrubunismi


We are writing this.


3AKML3.jpg



Now our group name has changed. To see


Kod:
cat /etc/group


we are writing this.


eIRSAU.jpg



68P5BS.jpg



As you can see at the bottom after writing, there is a group called “New” and we see that the group ID is “2002”.

Now let’s move on to the Add,Remove and set password commands to the group.


Add User to the Group

First,


Kod:
gpasswd –a kullanıcıismi grubunismi


We are writing this. “-a” parameter means “add” here.


5Wf0S6.jpg



After writing this, we received a notification that the user had been added.


eGJ7NC.jpg



We received a notification that the user had been added. Let’s see.


Kod:
cat /etc/group  |grep grupismi


We are writing this.


6SOMRG.jpg



As you can see, the user we added appears at the end of the group.


6dLPGy.jpg



Removing User From Group

First,


Kod:
gpasswd –d kullanıcıismi grubunismi


we are writing this. “-d” parameter here means “delete”.


aUcfPc.jpg



It shows us that the user has been deleted. Let’s check it.


I7b96a.jpg



Kod:
cat /etc/group  |grep grupismi


We are writing this.


5JT53C.jpg



As you can see, when we added user, the user name appeared on the right side but now we couldn’t see.

We learned how to add and remove users. Now we will learn how to set password to the group.


Setting Password to Group


First,


Kod:
gpasswd grupismi


We are writing this.


0xJdQI.jpg



It asks us for the new password. What you write here won’t appear on your screen so don’t worry about it.


W0d4W6.jpg



Then it wants us to write password again.


01yRRP.jpg



After writing, our group has a password protection.


Delete Group


We learned how to add, remove and setting password in group. Now we will learn how to delete a group.


First,


Kod:
groupdel grupismi


We are doing this.


R2Gy3C.jpg



Then it finishes the process without warning us.


xUa0aT.jpg



Let’s check if group is deleted. For this,


Kod:
cat /etc/group


We are writing this.


cRK18e.jpg



0Nd1Qd.jpg



As you see, group has been deleted.
Now let’s get to the User Management.


User Management


We use some commands for user management, I will talk about them. First, let’s talk about where these users are.

User information is found in “etc/passwd”.


Kod:
cat /etc/passwd


With this command, you can list user information.


HSSdHO.jpg



MPeW1z.jpg



Creating User


First,


Kod:
useradd kullanıcıismi


we are writing this.


TCJ82d.jpg



It created without warning.


ac4UMz.jpg



Let’s check if the user has been added. For this,


Kod:
cat /etc/passwd



we are writing this and we can see the user that we created at the bottom.


5UzSWQ.jpg




Setting Password to User


First of all, like we did in the group


Kod:
passwd kullanıcıismi


we are writing this.


ydMy2a.jpg



After that it will ask for a password.


xB0Qz5.jpg



It asks for a password again after that process will be completed successfully.


JVIGR3.jpg



Changing User ID


First,


Kod:
usermod –u ıdgiriyoruz kullanıcıismi


we are writing this.


xB0Qz5.jpg



It accepted without warning.


VU6LA6.jpg



Let’s check what happened.


Kod:
cat /etc/passwd


We are writing this to see “passwd”.


4yVyHN.jpg



After writing, as you can see at the bottom, our user and ID value appear.


I9f3J2.jpg



Deleting User


To delete user,


Kod:
userdel kullanıcıismi


we are writing this.


P58C6e.jpg



After that, let’s check if the user has been deleted.


Kod:
cat /etc/passwd


WK978W.jpg



As you can see, our user has been deleted.


QddW5J.jpg



Adding User to a Group While Creating


First,


Kod:
useradd kullanıcıismi –u ıddeğeri –g grupismi


we are writing this.


MdB85M.jpg



And that’s it. Our user was formed at the id value that we identified in the group called “New”.


Getting Information About User


To get information about user,


Kod:
chage –l kullanıcıismi


we are writing this.


AHyR2J.jpg



Then it gives us information about the user.


PLRd6M.jpg



View Files After Creating A User


Informations about users after creating them


Kod:
/etc/skel


are written in this file (information about the authorities). Now to learn and edit the information,


Kod:
ls –al /etc/skel


we write this.


c8844Q.jpg



AabTzL.jpg



Shadow Directory


Shadow Directory


Kod:
/etc/shadow


is defined as this. Shadow directory has te same functions as “passwd”, but it is more reliable directory. Because it is encrypted in MD5. On the other hand, “Passwd” isn’t like this. It is a text file.


Difference Between Su and Sudo


The difference between Sudo and Su is, in the “su” command, when you exit the terminal or when you write “exit”, it also exits the root user but, in the “sudo” command let’s say that you are doing an operation when this operation is finished, the “sudo” command loses its function and switches to the normal user.


Switching Root User With Su Command


To switch root user,


Kod:
su


we are writing this and asks us for our password. After writing password, we are switching to root.


7J07LG.jpg



Switching Root User With Sudo Command


To switch root user with sudo command


Kod:
sudo root


we are writing this.


dPfU92.jpg



It asks for our password.


2LPTHI.jpg



After writing, you will switch to the root user.


Switching Root User With Sudo Su Command


The feature of Sudo su command is this, it switches directly to the root user without asking for any password.


Kod:
sudo su


ySV6H7.jpg



Switching to Another User


To switch to another user


Kod:
su kullanıcıismi


we are writing this and if it doesn’t have a password, it will switch directly.


BbL5dz.jpg



File Ownership and Permissions


To change File Ownership and Permissions, we are using “chmod”, “chown” and “unmask” command.


Chmod Command


R35Q2T.jpg



The chmod command is a slightly more complex command than others. First, let me tell what is this command. It is a command used to determine Linux users’ access rights to files.


2 : w => Writing Permission
4 : r => Reading Permission
1 : x => Running Permission


Example of Chmod;

rwx : All read, write and run Access permissions exist.
rw- : It has read and write permissions, no run permission.
r-x : It has read and run permissions, no write permission.
wx : It has write and run permission, no read permission.
-x : Only has run permission.
-w- : Only has write permission.
r- : Only has read permission.
-- : has no access.



If you say how do we know if to a file is allowed to us,


Kod:
ls –all dosyaismi


If you write this, the file’s permissions will be seen.


GNNx93.jpg



b4J9KV.jpg



For example, its permissions appeared.


O3aGKS.jpg



Kod:
chmod 000 dosyaismi


If we write this, we have no rights in that file. So no right to read, write or view.


2AU24G.jpg



Kod:
chmod 001 dosyaismi


If we write this, we have no right to read and write but we have the right to run.


S3KQVa.jpg



Kod:
chmod 010 dosyaismi


If we write this, we have no read and run permission but we have write permission.


N7LxzS.jpg



Kod:
chmod 011 dosyaismi



If we write this, we have no read permission, but we have write and run permissions.


PA51CW.jpg



Kod:
chmod 100 dosyaismi


If we write this, we have no write and run permissions but we have read permission.


112xT7.jpg



Kod:
chmod 101 dosyaismi



If we write this, we have read and run permissions but have no write permission.


7MN4Az.jpg



Kod:
chmod 110 dosyaismi


If we write this, we have read and write permissions but we have no run permission.


3OOQI4.jpg



Kod:
chmod 111 dosyaismi



If we write this, we have all the permissions.


Chown Command


1MAMPO.jpg



Chmod command is a command used to change a file’s permission system. With this command, you have the right to use and manage the file among other users.


xd1M7M.jpg



Kod:
chmod kullanıcıadı dosyaadı


To do that we are writing this. Which user you want to give authority to, you write that username.


1UGCfy.jpg



Unmask Command


2z2dS7.jpg



Unmask command is a command that is used as a permission restriction. On Linux systems, files and directories have default permissions. These permissions are set as 022 in unmask.


58GUOQ.jpg



You can see like that. This number system comes from the “x, r, w” that I explained in chmod. We can change these values and we will do it like this;


bWeQ3T.jpg



Kod:
umask değer


We will write this.

For example, let’s create a file and directory;


zyGV4N.jpg



Kod:
touch dosyaismi 
mkdir dizinismi 
ls –l


We are writing this and looking at the permissions.


Q4JCz1.jpg



As you can see, the values “r, x, w” have also changed because we have changed the values of the permissions.


That’s all friends. If you learned something, I am very happy about that.




 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.