Greetings TurkHackTeam members, Today I'm going to talk about the Structure of the GNU/Linux Operating System. It will be like a lecture and I will try not to keep this topic too long.

Subject Headings
? Root
? GID
? UID
? Group Management
? Creating A Group
? Changing the Group ID
? Adding Users to a Group
? Deleting Users from a Group
? Setting a Password to a Group
? Deleting a Group
? User Management
? Creating a User
? Setting Passwords for Users
? Changing User ID
? Deleting User
? Getting Information About the User
? Shadow Directory
? Differences Between Su and Sudo
? Switching to Root User with Su Command
? Switching to Root User with Sudo Su
? Switching to Another User
? File Ownership and Permissions
First of all, let me talk about the meanings of some of the terms I will talk about in the tutorial;
Root
These are users with full authority on Linux/Unix systems. Root users have unlimited privileges.
GID
This is the Group ID. If the group IDs are defined as "0", they have the root user, ie root authority.
UID
This is the User ID. If the user IDs are defined as "0" in the same way, they have the root user, that is, root authority.
First of all, as you know, Linux distributions have a multi-user system. In other words, we do not only operate with one user, but we can open multiple users and perform transactions. The most important thing for us is the User ID. What is this User ID, if you ask; Access rights are given according to this ID. There can be more than one user with this ID. However, if the "Administrator" can be more than one in Windows, the "root" user can be more than one in Linux systems. Generally, in Linux systems, the reason for opening more than one user with the same access rights as the root administrator is that if the password of the root user is forgotten, it is created by other backup users with root user rights so that they can log into the system.
Default users come automatically on Linux systems. We have a code to view these default users. Actually, it is used to see all users (Root etc.).
First of all, we open the Terminal and Kod:
cd /etc/
write this command.

After that, we write this. Kod:
cat passwd
Here, "passwd" is the file where the users are. We can get the necessary information from here.

All predefined users and users with root authorization come across us.

You saw "root: x: 0: 0". Now if you want to know what this is, it means username (root), password (x), user ID (0) and group ID (0). If you have noticed the users below, it says "/nologin" on the far right. This means they cannot login in the background. If you scroll down, you will see your own username on the bottom one. Now, we made a small introduction with you, looked what is what is not, now let's start our tutorial.
Group Management
Now we use some commands to do operations on groups. I will show you their usage, but first let me tell about where these groups are.
Groups are can be found in Kod:
/etc/group
Now let's see; Firstly, we write Kod:
cat group
.

Later, all groups appear.
Creating A Group
Let's do the Group Creation process together.
We write as
Kod:
groupadd groupname

After writing, our group was formed. Now let's look at our group and for this we are writing this Kod:
cat group

The group we created at the bottom is out. Now, when we got to the bottom like this, we saw our group, but we may not always want to go to the bottom. For this;
Firstly we write Kod:
cat /etc/group | grep grupismi
. Grep is a command that brings us the results according to the criteria we look for in a certain section.

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

As you can see, we have seen how to create groups and learn it. Now we came to make transactions through this group that we created.
Changing The Group's ID
First of all, we get root privileges from the terminal. Kod:
sudo su
Later we log into the etc directory by typing Kod:
cd /etc/
Then we write this. Kod:
groupmod ?g groupID grupismi

We have a transaction, now we write this to see our group. Kod:
catcat /etc/group | grep grupismi

Whatever group ID you have typed, that number will appear.
Let's say we want to change the name of the group. What are we going to do? Now, we are writing this command.
Kod:
groupmod ?n newgroupname currentgroupname

Now our group name has changed. We write this to see. Kod:
cat /etc/group


As you can see at the bottom after writing, there is a group named "yeni" and we see that the group ID is "2002".
Now let's move on to the commands for adding and removing users to the group and adding a password.
Adding Users To The Group
First, we write this. Kod:
gpasswd ?a username groupname
?-A? parameter here means ?add?.

After writing, we received a notification that the user was added.

Now we have received the notification that the user has been added, let's take a look. Kod:
cat /etc/group |grep groupname

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

Deleting A User From The Group
First of all, we write this. Kod:
gpasswd ?d username groupname
"-d" parameter means "delete" here.

It shows us that the user has been deleted. Let's check it out now.

Kod:
cat /etc/group |grep groupname
we write as this.
As you can see, when we added a user, the username appeared on the right, but now it is not.
We learned how to add and remove users, now we will learn how to set a password to the group.
Setting a Password To The Group
Firstly, we write this. Kod:
gpasswd groupname

Then it asks us for the new password, what you write here will not appear on your screen, so don't worry. :trl

It then asks us to retype the password.
After writing, our group is now encrypted.
Deleting The Group
We have now seen adding, removing users and encrypting the group. We'll see how to delete the group right now.
Firstly we write this command. Kod:
groupdel groupname
Then it finishes the process without warning us.

Let's check it then by writing this. Kod:
cat /etc/group


As you can see the group has been deleted.
Now let's move on to user management.
User Management
We use some commands for user management, I shall mention them. First of all, let me talk about where these users are.
User information is located in "etc/passwd". Kod:
cat /etc/passwd
You can list user information with the command.


Creating A User
First of all, we write as like here. Kod:
useradd username

It created it directly without warning.

Let's see if the user has been added. Kod:
cat /etc/passwd
And at the bottom the user we created comes out.

Setting a User Password
Firstly, we write this command just like in the groups. Kod:
passwd username

It will then ask us for a password.

It will ask for a password again and after typing it the process will be completed successfully.

Changing The User ID
First, we write this. Kod:
usermod ?u enteranID username

It accepted without warning

Let's check if it is done, we print "passwd". Kod:
cat /etc/passwd

As you can see at the bottom after printing, our user and ID value appear.

Deleting a User
To delete a User, we write this command. Kod:
userdel username

After writing, let's check if our user is deleted. Kod:
cat /etc/passwd

As you can see, the user has been deleted.

Adding A User To A Group When Creating
Firstly, write this command. Kod:
useradd username ?u IDvalue ?g Groupname

And that's it. Our user has been created at the id value we set in the group named "yeni".
Getting Information About The User
To get some information about the user, we write this. Kod:
chage ?l username

It then gives us information about the user.

Viewing User Files After Creating
After we create our users, information about them is written in the /etc /skel file (ie the information about the authorities). Now let's write this to learn and organize information
Kod:
ls ?al /etc/skel


Shadow Directory
The shadow directory is defined as Kod:
/etc/shadow
. The shadow directory has the same functions as "passwd" but it is a more reliable directory. Because it is encrypted in an MD5-based way. ?Passwd? is a text file that is not like this.
Difference Between Su And Sudo Commands
The difference between sudo and su is that when you exit the terminal or when you say "exit" in the "su" command, you exit the root user, but in the "sudo" command, let's say you do something, when that process is finished, the "sudo" command loses its functionality and switches to the normal user. .
Switching To Root User With Su Command
We write Kod:
su
to switch to the root user and asks us for our password, after typing the password, we switch to the root user.

Switching to Root User with Sudo Command
We write Kod:
sudo root
to switch to root with sudo.

It will ask us for our password
After writing, you will be the root user.
Switching to Root User with Sudo Su
The feature of the sudo su command is as follows, it switches directly to the root user without asking for any password. Kod:
sudo su

Switching To Another User
To switch to another user, we write Kod:
su username
and if there is no password, it will switch directly.

File Ownership and Permissions
We use a few commands "chmod", "chown" and "unmask" to change file ownership and permissions.
Chmod Command

The chmod command is a bit more complex than other commands. First, let me talk about what it is; It is a command used to set Linux users' access rights to files.
2 : w => Writing permission
4 : r => Reading permission
1 : x => Runningpermission
Chmod Examples;
rwx : Read, write and run access permissions are all available.
rw- : You have read and write permissions, you do not have permission to run.
r-x : You have read and run permissions, you do not have permission to write.
wx : No permission to read, write and run permissions.
?x : It only has the permission to run.
-w- : It only has the permission to write.
r? : It only has the permission to read.
? : It has no permissions.
Now if you ask how we can tell if a file is allowed or not, when you write Kod:
ls ?all as filename
, the permissions of the file will appear.


For example, the permissions appeared.

Kod:
chmod 000 filename
when we write this, it means it has no permissions. So neither the permission to read, write nor view.

Kod:
chmod 001 dosyaismi
when we write this, we do not have the permissions to read and write, but we have the permission to run

Kod:
chmod 010 dosyaismi
when we write this, no read permissions, no run permissions, but write permissions.

Kod:
chmod 011 dosyaismi
when we write this, we do not have read permission, but we have write and run permissions.

Kod:
chmod 100 dosyaismi
when we write this, We have read permission but not write or run permission.

Kod:
chmod 101 dosyaismi
when we write this, We have permission to read and run, but not write.

Kod:
chmod 110 dosyaismi
when we write this, We have read and write permissions, but we do not have permission to run.

Kod:
chmod 111 dosyaismi
when we write this, we can see that we have all the permissions.
Chown Command

The chmod command is the command used to change the permissions system of a file. With this command, you have the authority to use and manage the file among other users.

Kod:
chmod username filename
You must write the user which you want to give permissions.

Umask Command

The umask command is a command used as a permission restriction. In Linux systems, files and directories have default permissions. These permissions are determined as 022 in the umask.

You can see it this way. This number system comes from the "x, r, w" part I explained in chmod. We can change these values and we will do it as follows;

We'll write as Kod:
umask value
For example, let's create a file and directory;

We write these commands and we look at their permissions.
Kod:
touch filename
mkdir directoryname
ls ?l

As you can see, "r, x, w" values have also changed because we changed the values of the permissions.
This was the tutorial. Friends, if you are informed, I'd be very glad :))
Source: https://www.turkhackteam.org/linux/1...pisi-p4rs.html
Translator: @Dolyetyus

Subject Headings
? Root
? GID
? UID
? Group Management
? Creating A Group
? Changing the Group ID
? Adding Users to a Group
? Deleting Users from a Group
? Setting a Password to a Group
? Deleting a Group
? User Management
? Creating a User
? Setting Passwords for Users
? Changing User ID
? Deleting User
? Getting Information About the User
? Shadow Directory
? Differences Between Su and Sudo
? Switching to Root User with Su Command
? Switching to Root User with Sudo Su
? Switching to Another User
? File Ownership and Permissions
First of all, let me talk about the meanings of some of the terms I will talk about in the tutorial;
Root
These are users with full authority on Linux/Unix systems. Root users have unlimited privileges.
GID
This is the Group ID. If the group IDs are defined as "0", they have the root user, ie root authority.
UID
This is the User ID. If the user IDs are defined as "0" in the same way, they have the root user, that is, root authority.
First of all, as you know, Linux distributions have a multi-user system. In other words, we do not only operate with one user, but we can open multiple users and perform transactions. The most important thing for us is the User ID. What is this User ID, if you ask; Access rights are given according to this ID. There can be more than one user with this ID. However, if the "Administrator" can be more than one in Windows, the "root" user can be more than one in Linux systems. Generally, in Linux systems, the reason for opening more than one user with the same access rights as the root administrator is that if the password of the root user is forgotten, it is created by other backup users with root user rights so that they can log into the system.
Default users come automatically on Linux systems. We have a code to view these default users. Actually, it is used to see all users (Root etc.).
First of all, we open the Terminal and Kod:
cd /etc/
write this command.

After that, we write this. Kod:
cat passwd
Here, "passwd" is the file where the users are. We can get the necessary information from here.

All predefined users and users with root authorization come across us.

You saw "root: x: 0: 0". Now if you want to know what this is, it means username (root), password (x), user ID (0) and group ID (0). If you have noticed the users below, it says "/nologin" on the far right. This means they cannot login in the background. If you scroll down, you will see your own username on the bottom one. Now, we made a small introduction with you, looked what is what is not, now let's start our tutorial.
Group Management
Now we use some commands to do operations on groups. I will show you their usage, but first let me tell about where these groups are.
Groups are can be found in Kod:
/etc/group
Now let's see; Firstly, we write Kod:
cat group
.

Later, all groups appear.
Creating A Group
Let's do the Group Creation process together.
We write as
Kod:
groupadd groupname

After writing, our group was formed. Now let's look at our group and for this we are writing this Kod:
cat group

The group we created at the bottom is out. Now, when we got to the bottom like this, we saw our group, but we may not always want to go to the bottom. For this;
Firstly we write Kod:
cat /etc/group | grep grupismi
. Grep is a command that brings us the results according to the criteria we look for in a certain section.

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

As you can see, we have seen how to create groups and learn it. Now we came to make transactions through this group that we created.
Changing The Group's ID
First of all, we get root privileges from the terminal. Kod:
sudo su
Later we log into the etc directory by typing Kod:
cd /etc/
Then we write this. Kod:
groupmod ?g groupID grupismi

We have a transaction, now we write this to see our group. Kod:
catcat /etc/group | grep grupismi


Whatever group ID you have typed, that number will appear.
Let's say we want to change the name of the group. What are we going to do? Now, we are writing this command.
Kod:
groupmod ?n newgroupname currentgroupname

Now our group name has changed. We write this to see. Kod:
cat /etc/group


As you can see at the bottom after writing, there is a group named "yeni" and we see that the group ID is "2002".
Now let's move on to the commands for adding and removing users to the group and adding a password.
Adding Users To The Group
First, we write this. Kod:
gpasswd ?a username groupname
?-A? parameter here means ?add?.

After writing, we received a notification that the user was added.

Now we have received the notification that the user has been added, let's take a look. Kod:
cat /etc/group |grep groupname

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

Deleting A User From The Group
First of all, we write this. Kod:
gpasswd ?d username groupname
"-d" parameter means "delete" here.

It shows us that the user has been deleted. Let's check it out now.

Kod:
cat /etc/group |grep groupname
we write as this.

As you can see, when we added a user, the username appeared on the right, but now it is not.
We learned how to add and remove users, now we will learn how to set a password to the group.
Setting a Password To The Group
Firstly, we write this. Kod:
gpasswd groupname

Then it asks us for the new password, what you write here will not appear on your screen, so don't worry. :trl

It then asks us to retype the password.

After writing, our group is now encrypted.
Deleting The Group
We have now seen adding, removing users and encrypting the group. We'll see how to delete the group right now.
Firstly we write this command. Kod:
groupdel groupname

Then it finishes the process without warning us.

Let's check it then by writing this. Kod:
cat /etc/group


As you can see the group has been deleted.
Now let's move on to user management.
User Management
We use some commands for user management, I shall mention them. First of all, let me talk about where these users are.
User information is located in "etc/passwd". Kod:
cat /etc/passwd
You can list user information with the command.


Creating A User
First of all, we write as like here. Kod:
useradd username

It created it directly without warning.

Let's see if the user has been added. Kod:
cat /etc/passwd
And at the bottom the user we created comes out.

Setting a User Password
Firstly, we write this command just like in the groups. Kod:
passwd username

It will then ask us for a password.

It will ask for a password again and after typing it the process will be completed successfully.

Changing The User ID
First, we write this. Kod:
usermod ?u enteranID username

It accepted without warning

Let's check if it is done, we print "passwd". Kod:
cat /etc/passwd

As you can see at the bottom after printing, our user and ID value appear.

Deleting a User
To delete a User, we write this command. Kod:
userdel username

After writing, let's check if our user is deleted. Kod:
cat /etc/passwd

As you can see, the user has been deleted.

Adding A User To A Group When Creating
Firstly, write this command. Kod:
useradd username ?u IDvalue ?g Groupname

And that's it. Our user has been created at the id value we set in the group named "yeni".
Getting Information About The User
To get some information about the user, we write this. Kod:
chage ?l username

It then gives us information about the user.

Viewing User Files After Creating
After we create our users, information about them is written in the /etc /skel file (ie the information about the authorities). Now let's write this to learn and organize information
Kod:
ls ?al /etc/skel


Shadow Directory
The shadow directory is defined as Kod:
/etc/shadow
. The shadow directory has the same functions as "passwd" but it is a more reliable directory. Because it is encrypted in an MD5-based way. ?Passwd? is a text file that is not like this.
Difference Between Su And Sudo Commands
The difference between sudo and su is that when you exit the terminal or when you say "exit" in the "su" command, you exit the root user, but in the "sudo" command, let's say you do something, when that process is finished, the "sudo" command loses its functionality and switches to the normal user. .
Switching To Root User With Su Command
We write Kod:
su
to switch to the root user and asks us for our password, after typing the password, we switch to the root user.

Switching to Root User with Sudo Command
We write Kod:
sudo root
to switch to root with sudo.

It will ask us for our password

After writing, you will be the root user.
Switching to Root User with Sudo Su
The feature of the sudo su command is as follows, it switches directly to the root user without asking for any password. Kod:
sudo su

Switching To Another User
To switch to another user, we write Kod:
su username
and if there is no password, it will switch directly.

File Ownership and Permissions
We use a few commands "chmod", "chown" and "unmask" to change file ownership and permissions.
Chmod Command

The chmod command is a bit more complex than other commands. First, let me talk about what it is; It is a command used to set Linux users' access rights to files.
2 : w => Writing permission
4 : r => Reading permission
1 : x => Runningpermission
Chmod Examples;
rwx : Read, write and run access permissions are all available.
rw- : You have read and write permissions, you do not have permission to run.
r-x : You have read and run permissions, you do not have permission to write.
wx : No permission to read, write and run permissions.
?x : It only has the permission to run.
-w- : It only has the permission to write.
r? : It only has the permission to read.
? : It has no permissions.
Now if you ask how we can tell if a file is allowed or not, when you write Kod:
ls ?all as filename
, the permissions of the file will appear.


For example, the permissions appeared.

Kod:
chmod 000 filename
when we write this, it means it has no permissions. So neither the permission to read, write nor view.

Kod:
chmod 001 dosyaismi
when we write this, we do not have the permissions to read and write, but we have the permission to run

Kod:
chmod 010 dosyaismi
when we write this, no read permissions, no run permissions, but write permissions.

Kod:
chmod 011 dosyaismi
when we write this, we do not have read permission, but we have write and run permissions.

Kod:
chmod 100 dosyaismi
when we write this, We have read permission but not write or run permission.

Kod:
chmod 101 dosyaismi
when we write this, We have permission to read and run, but not write.

Kod:
chmod 110 dosyaismi
when we write this, We have read and write permissions, but we do not have permission to run.

Kod:
chmod 111 dosyaismi
when we write this, we can see that we have all the permissions.
Chown Command

The chmod command is the command used to change the permissions system of a file. With this command, you have the authority to use and manage the file among other users.

Kod:
chmod username filename
You must write the user which you want to give permissions.

Umask Command

The umask command is a command used as a permission restriction. In Linux systems, files and directories have default permissions. These permissions are determined as 022 in the umask.

You can see it this way. This number system comes from the "x, r, w" part I explained in chmod. We can change these values and we will do it as follows;

We'll write as Kod:
umask value
For example, let's create a file and directory;

We write these commands and we look at their permissions.
Kod:
touch filename
mkdir directoryname
ls ?l

As you can see, "r, x, w" values have also changed because we changed the values of the permissions.
This was the tutorial. Friends, if you are informed, I'd be very glad :))
Source: https://www.turkhackteam.org/linux/1...pisi-p4rs.html
Translator: @Dolyetyus