- 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 wont keep it long.
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 dont 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 users 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
We are writing.
Then
We are writing this. Here passwd is the file where the users are located. We can get the necessary information here.
All default users and users that have Root permissions are shown.
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 cant 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 isnt. Now lets 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
are located in this.
Now lets see, but first
We are typing this.
Then all the groups appear.
Creating Groups
Lets create a group together.
We are writing this.
After typing, our group is created. Lets look at our group. For this;
we are writing this.
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;
we are writing this. Grep is a command that gives use results according to the criteria we are looking for in a particular 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 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
We are taking root authorization with this. Then
we log in to the etc directory with this code. After that
we are typing this.
We finished. Now to see our group
we are writing this.
Whatever group ID you have typed, that number will appear.
Now lets assume we want to change the name of the group. What are we gonna do? For this;
We are writing this.
Now our group name has changed. To see
we are writing this.
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 lets move on to the Add,Remove and set password commands to the group.
Add User to the Group
First,
We are writing this. -a parameter means add here.
After writing this, we received a notification that the user had been added.
We received a notification that the user had been added. Lets see.
We are writing this.
As you can see, the user we added appears at the end of the group.
Removing User From Group
First,
we are writing this. -d parameter here means delete.
It shows us that the user has been deleted. Lets check it.
We are writing this.
As you can see, when we added user, the user name appeared on the right side but now we couldnt 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,
We are writing this.
It asks us for the new password. What you write here wont appear on your screen so dont worry about it.
Then it wants us to write password again.
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,
We are doing this.
Then it finishes the process without warning us.
Lets check if group is deleted. For this,
We are writing this.
As you see, group has been deleted.
Now lets get to the User Management.
User Management
We use some commands for user management, I will talk about them. First, lets talk about where these users are.
User information is found in etc/passwd.
With this command, you can list user information.
Creating User
First,
we are writing this.
It created without warning.
Lets check if the user has been added. For this,
we are writing this and we can see the user that we created at the bottom.
Setting Password to User
First of all, like we did in the group
we are writing this.
After that it will ask for a password.
It asks for a password again after that process will be completed successfully.
Changing User ID
First,
we are writing this.
It accepted without warning.
Lets check what happened.
We are writing this to see passwd.
After writing, as you can see at the bottom, our user and ID value appear.
Deleting User
To delete user,
we are writing this.
After that, lets check if the user has been deleted.
As you can see, our user has been deleted.
Adding User to a Group While Creating
First,
we are writing this.
And thats 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,
we are writing this.
Then it gives us information about the user.
View Files After Creating A User
Informations about users after creating them
are written in this file (information about the authorities). Now to learn and edit the information,
we write this.
Shadow Directory
Shadow Directory
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 isnt 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 lets 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,
we are writing this and asks us for our password. After writing password, we are switching to root.
Switching Root User With Sudo Command
To switch root user with sudo command
we are writing this.
It asks for our password.
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.
Switching to Another User
To switch to another user
we are writing this and if it doesnt have a password, it will switch directly.
File Ownership and Permissions
To change File Ownership and Permissions, we are using chmod, chown and unmask command.
Chmod Command
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,
If you write this, the files permissions will be seen.
For example, its permissions appeared.
If we write this, we have no rights in that file. So no right to read, write or view.
If we write this, we have no right to read and write but we have the right to run.
If we write this, we have no read and run permission but we have write permission.
If we write this, we have no read permission, but we have write and run permissions.
If we write this, we have no write and run permissions but we have read permission.
If we write this, we have read and run permissions but have no write permission.
If we write this, we have read and write permissions but we have no run permission.
If we write this, we have all the permissions.
Chown Command
Chmod command is a command used to change a files permission system. With this command, you have the right to use and manage the file among other users.
To do that we are writing this. Which user you want to give authority to, you write that username.
Unmask Command
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.
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;
We will write this.
For example, lets create a file and directory;
We are writing this and looking at the permissions.
As you can see, the values r, x, w have also changed because we have changed the values of the permissions.
Thats all friends. If you learned something, I am very happy about that.
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 dont 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 users 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.
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.
All default users and users that have Root permissions are shown.
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 cant 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 isnt. Now lets 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 lets see, but first
Kod:
cat group
We are typing this.
Then all the groups appear.
Creating Groups
Lets create a group together.
Kod:
groupadd grupismi
We are writing this.
After typing, our group is created. Lets look at our group. For this;
Kod:
cat group
we are writing this.
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.
As you can see, it showed us our group and our GIP and UID.
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.
We finished. Now to see our group
Kod:
catcat /etc/group | grep grupismi
we are writing this.
Whatever group ID you have typed, that number will appear.
Now lets 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.
Now our group name has changed. To see
Kod:
cat /etc/group
we are writing this.
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 lets 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.
After writing this, we received a notification that the user had been added.
We received a notification that the user had been added. Lets see.
Kod:
cat /etc/group |grep grupismi
We are writing this.
As you can see, the user we added appears at the end of the group.
Removing User From Group
First,
Kod:
gpasswd d kullanıcıismi grubunismi
we are writing this. -d parameter here means delete.
It shows us that the user has been deleted. Lets check it.
Kod:
cat /etc/group |grep grupismi
We are writing this.
As you can see, when we added user, the user name appeared on the right side but now we couldnt 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.
It asks us for the new password. What you write here wont appear on your screen so dont worry about it.
Then it wants us to write password again.
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.
Then it finishes the process without warning us.
Lets check if group is deleted. For this,
Kod:
cat /etc/group
We are writing this.
As you see, group has been deleted.
Now lets get to the User Management.
User Management
We use some commands for user management, I will talk about them. First, lets 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.
Creating User
First,
Kod:
useradd kullanıcıismi
we are writing this.
It created without warning.
Lets 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.
Setting Password to User
First of all, like we did in the group
Kod:
passwd kullanıcıismi
we are writing this.
After that it will ask for a password.
It asks for a password again after that process will be completed successfully.
Changing User ID
First,
Kod:
usermod u ıdgiriyoruz kullanıcıismi
we are writing this.
It accepted without warning.
Lets check what happened.
Kod:
cat /etc/passwd
We are writing this to see passwd.
After writing, as you can see at the bottom, our user and ID value appear.
Deleting User
To delete user,
Kod:
userdel kullanıcıismi
we are writing this.
After that, lets check if the user has been deleted.
Kod:
cat /etc/passwd
As you can see, our user has been deleted.
Adding User to a Group While Creating
First,
Kod:
useradd kullanıcıismi u ıddeğeri g grupismi
we are writing this.
And thats 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.
Then it gives us information about the user.
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.
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 isnt 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 lets 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.
Switching Root User With Sudo Command
To switch root user with sudo command
Kod:
sudo root
we are writing this.
It asks for our password.
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
Switching to Another User
To switch to another user
Kod:
su kullanıcıismi
we are writing this and if it doesnt have a password, it will switch directly.
File Ownership and Permissions
To change File Ownership and Permissions, we are using chmod, chown and unmask command.
Chmod Command
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 files permissions will be seen.
For example, its permissions appeared.
Kod:
chmod 000 dosyaismi
If we write this, we have no rights in that file. So no right to read, write or view.
Kod:
chmod 001 dosyaismi
If we write this, we have no right to read and write but we have the right to run.
Kod:
chmod 010 dosyaismi
If we write this, we have no read and run permission but we have write permission.
Kod:
chmod 011 dosyaismi
If we write this, we have no read permission, but we have write and run permissions.
Kod:
chmod 100 dosyaismi
If we write this, we have no write and run permissions but we have read permission.
Kod:
chmod 101 dosyaismi
If we write this, we have read and run permissions but have no write permission.
Kod:
chmod 110 dosyaismi
If we write this, we have read and write permissions but we have no run permission.
Kod:
chmod 111 dosyaismi
If we write this, we have all the permissions.
Chown Command
Chmod command is a command used to change a files permission system. With this command, you have the right to use and manage the file among other users.
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.
Unmask Command
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.
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;
Kod:
umask değer
We will write this.
For example, lets create a file and directory;
Kod:
touch dosyaismi
mkdir dizinismi
ls l
We are writing this and looking at the permissions.
As you can see, the values r, x, w have also changed because we have changed the values of the permissions.
Thats all friends. If you learned something, I am very happy about that.