Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Monday, January 2, 2017

File Permissions and Access Rights 2

File Permissions and Access Rights 2

Special Access Rights Setuid and Setgid

To allow a user who is not authorized to access a file to temporarily access the file, the setuid and setgid programs are authorized to execute the programs. Setuid works with the authority of the user who owns the program for the duration of the program. A program marked with setgid works with the authority of the group that owns it for the duration of the program.

To give setuid access: "chmod u+s file_name"
To give setgid access: "chmod g+s file_name"

The "setuid" and "setgid" private study authorities apply only to compiled program files. The setuid or setgid run permission for a shell program is not different from the normal run permission.

Sticky "t" is a special case for the privileged directories. A directory with the "t" privilege can be written by all users, but can not be deleted or updated other users' writes (unless they are given write permissions on a file basis). However, a directory with an access rights of "rwxrwxrwx" is writable by everyone and they can also delete others' files.



It would not have been possible for ordinary users to change their passwords stored in /etc/passwd and /etc/shadow without the setuid scheme. Since the information stored in these files can only be accessed by the root user, the passwd program is setuid as root.




As it can be seen in the example above owner of the /etc/passwd file is the root user. However binary file located at /usr/bin/passwd has the setuid access right which means anyone can execute this file with the root authority.

For security reasons, setuid/setgid should not be done despite all these benefits, unless it is needed.

Sticky 't' Right


Sticky bit prevents other users to delete a file created by another user in the temporary file writing directories required by all user programs. In such directories, no user can delete another user's file or directory through sticky special authority, even though the user, group and others have all the permissions (read, write, execute). A temporary file created by a user in a directory such as "/tmp" without the "Sticky" special authority could easily be deleted by another user for the reason that all the permissions were granted to everyone else.

Setuid, setgid and sticky bit is set just like regular file permissions. For setuid we use 4, for setgid we use 2 and for sticky bit we use 1. For example:

All rights are given to a file including setuid, setgid and sticky bit:
chmod 7777 example_file

A file is given read permission to owner and group only and has sticky bit:
chmod 1440 example_file

Changing Owner and Group of a File/Directory

"chown" command is used for changing the owner of a file or directory and "chgrp" command is used for changing the group of a file or directory.


If the "chown" or "chgrp" command is used with the "-R" option, the entire directory and filename under the command directory will be applied if the given parameter is an directory. If the "-R" option is not given, the command is applied only to the directory/file given as parameter.

chown -R newOwner:newGroup directory_name: This command sets newOwner and newGroup as the owner and group of every file and directory under directory_name recursively.

Ordinary users can not use the "chown" command. If they change ownership of a file of their own, they lose their authority over the file and can not take ownership of the file without the help of "root". The "chown" command can not be used by ordinary users to prevent this, whereas ordinary users have limited use of the "chgrp" command.

To read my previous article: File Permissions and Access Rights 1

Tuesday, November 29, 2016

Free Software Philosophy GPL and BSD

Free Software Philosophy GPL and BSD

Richard Stallman and GPL

Richard Stallman, who worked as a researcher in the artificial intelligence lab at MIT in 1984, has set out the philosophy of free software and he has brought the philosophy and products in a place where they are today with the support he found. Stallman's starting point was a contradiction between the way scientific development is achieved and the production and development of industrial computer software.

Scientific innovation is only possible through the sharing of inventions, experiences and all other conclusions of academic researchers with the public. These scholarly publications, where all details are shared, allow an investigator to conduct studies that may be the continuation of previous researchers' work. If this sharing were not so clear and widespread, the pace of scientific progress and the level of our society today would be much lower.

Stallman also implements the Free Software Foundation (FSF), which foresees that software must be "free" and distributed freely and with all the details (source code, etc.). The GNU General Public License (GPL) is intended to promote and use the software license. This license is a license that allows software to be freely distributed and to make the software public domain.

The FSF has adopted the goal of producing a "free operating system" consisting entirely of free software components. All critical components, including text editor, kernel, compiler, etc. has been developed or is being developed by the FSF.  

 BSD License

UNIX is being developed at AT&T Bell Laboratories. After the division of AT&T, AT&T, the proprietor of UNIX, announces that they abandoned to distribute UNIX freely (while the operating system is initially distributed free to all clients) and plans to sell the software for a license fee,  resembling the definition of "free software".


Until then, the academic environment that uses UNIX and contributes to its development is not delayed in finding its own way out. A group of developers from Berkeley pick up UNIX from where AT&T left off free distribution and continue to produce and distribute a free UNIX with the support of other contributors. From this point on, UNIX is divided into two main branches; "AT&T UNIX" and "BSD UNIX".

BSD UNIX is distributed under the "BSD Software License". This license is a more liberal license than the GPL. The BSD license defines the software literally as "fountain". The software is free to use, as you wish. The condition of sharing the changes made with the public of GPL License is not subject to the BSD license. The person receiving the software can do whatever they want and does not have to share what they do with others.

Today, many popular software are distributed under the BSD license. The Apache web server is distributed under a BSD license and many vendors (Oracle, IBM, etc.) re-name Apache as their web server.

BSD UNIX, which was discontinued to develop by Berkeley in the mid-90s, was later broken down into many branches. Each of these branches (FreeBSD, OpenBSD, NetBSD) is still being maintained and distributed under the BSD license.

To read my previous article: What is Unix and Linux ?

 

Monday, November 28, 2016

What is Unix and Linux ?

What is Unix and Linux ?

What is an operating system ?

An operating system is a system software who is responsible for direct inspection and management of computer hardware and running application programs. Operating systems enable all other software to access memory, I/O devices, etc.

Kernel can be considered as brain of an operating system. Existing of an operating system without a kernel is impossible. All the other programs communicate via kernel. Kernel gains value when it becomes together with other programs. It enables programs to communicate with hardware and other programs uniformly, which means independent from hardware and software.

One of the most interesting examples of operating systems is Debian GNU/Linux. Currently, Debian is composed of Linux kernel and GNU tools, but now it is being updated in such a way that it could run on Hurd kernel. Main purpose of the Debian team is to prepare an operating system which provides users the opportunity of running the same GNU tools on different kernel alternatives.

What is UNIX ?

In 60's and 70's, there were operating systems which are developed for a specific computer in assembly language. For every new computer system, a new operating system was being developed in order to make users benefit from computers in a more comfortable manner.

Only a little part of the UNIX was developed in assembly language. It was developed in late 60's. Major part of the operating system was developed in C language which is also developed in almost the same years. Developing an operating system in a high-level language like C compared to assembly, provided computer manufacturers with the mobility, which means moving UNIX in their computer systems. So, it was a major technological improvement.

Application programming interface (API) which is provided with UNIX, enabled all the applications to be developed without any problem on all UNIX systems. An application that is developed for one UNIX can be transferred to other UNIX systems using re-compiling without any problem.

Properties of UNIX

Multi-tasking

It is the ability of running more than one task concurrently. Multiple tasks can be run in parallel if there are multiple CPU's or they can be run as if they are parallel if there is one CPU. For example, while working with a word processor like WPS Writer, it is possible to back-up the disk.

Multi-user

It means multiple users can use a computer system concurrently. For example, while a user is watching a movie, other one can surf on the web.

Time Sharing

Thanks to this feature, all the jobs on the system can be maintained even if a computer has only a single CPU. Every user has a priority on the system and the time taken  from CPU to processes for those users is assigned according to those priorities. Super user can change the priority of the users and tasks.

Portability

It is the ability to move to a computer system with a different architecture with only a little change in the code. This broad compatibility allows architecture dependency to be reduced and variety to be increased.

High Performance

In the UNIX world which simplicity is preferred over visuality, many applications can be run with a better performance. Even though it is an operating system that is developed in the early 70's it is preferred by most companies on critical duties.


What is Linux ?

Linux is manifested as a result of experiments of a second year student at University of Finland, whose name is Linus Torvalds. He has done his work on a computer system based on a Intel 80386 architecture. Linux has tried to make his computer to open without an operating system and make it run applications. 0.02 version which is the first product of Linus is completed in 1991. Linus has attended a lecture whose topic was MINIX and he decided to create a better operating system than it. His message which is sent to internet groups, attracted a lot of attention and gained support. Volunteers who supported Linus and his project which is called 'Linux' has contributed it to become real.

Linux is distributed under GNU General Public License which enables its source code to belong everyone and open to every person. Linux is only a kernel of an operating system and it becomes meaningful with other free software which makes it useful.

Message from Linus

From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroups: comp.os.minix
Subject: What would you like to see most in minix?
Summary: small poll for my new operating system
Message-ID: <1991Aug25.205708.9541@klaava.Helsinki.FI
Date: 25 Aug 91 20:57:08 GMT
Organization: University of Helsinki
Hello everybody out there using minix -
I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing
since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same
physical layout of the file-system (due to practical reasons) among other things). I've currently ported bash(1.08) and gcc(1.40),and
things seem to work.This implies that I'll get something practical within a few months, andI'd like to know what features most people would
want.
Any suggestions are welcome, but I won't promise I'll implement them :-)
Linus (torvalds@kruuna.helsinki.fi)
PS. Yes - it's free of any minix code, and it has a multi-threaded fs. It is NOT protable (uses 386 task switching etc), and it probably never will
support anything other than AT-harddisks, as that's all I have :-(

Properties of Linux

The most important feature of Linux is it belongs to public. Corporations that want to use Linux don't have to pay any license fees. Even if people and companies who contributed to development of Linux give up some day, other volunteers can continue developing it as long as it belongs to public. That way, dangers like producer changing the strategy, end the product or offering severe conditions after creating a product dependency are eliminated.

Source code of the system is open for anyone who wants to view and modify. Any person who wants to view, download, modify or distribute the modified version can reach the source code from here. Because of source code is open like this, it is very easy to trace and find the bugs. If we think there are thousands of people viewing the source code, we can understand how easy it is to find a bug in the code.

Another advantage of having the source code open is that new features can easily be added and the corporations can meet their unique expectations.

Apart from the addition of the new feature, the system can be shaped according to the sub-level settings and it is possible to disable unnecessary parts. Thus, a system suitable for the job can be obtained.

Linux can be run on different hardware platforms like HP-Compaq Alpha, Sun Sparc ve UltraSparc, Motorola PowerPC and StrongARM in the same way. An application that is running on a specific architecture can be moved to another Linux without any problems.  For example, if the server used for Intel Pentium architecture is insufficient a migration is possible to an IBM with many PowerPC processors, or a Sun computer system with a number of UltraSparc processors. Re-compilation of applications on new architectures is enough for this process.

Linux is in great harmony with other UNIX variants. Linux environment which has the features of both AT&T and BSD, has the ability to run other UNIX applications on itself. In this case, for example, an application developed on Sun Solaris systems can be re-compiled and run on Linux almost without change.



Linux Distributions

The software, which basically uses the Linux kernel and is bundled with the kernel, is called the Linux distribution as a whole. There are many companies and / or non-governmental organizations that prepare paid and free Linux distributions. 


Distributions can be used to make changes to the settings of the Linux kernel,
applying custom patches with preferences, and putting different free software into the distribution package. To differentiate, placing commercial licensed applications in the package, offering paid technical support and putting local language support at the forefront is another way to go.


RedHat, Ubuntu, Suse, Debian GNU / Linux and TurboLinux are Linux distributions, all showing differences with the qualities summarized in the previous paragraphs, despite having the same kernel (Linux) at the core.



Comments system

Disqus Shortname