Linux Distributions
The main distributions in the field right now are, these distributions have evolved into a similar state. making the management of these different distributions similar and easy than they initially were.
- Red Hat
- OpenSUSE
- Cent OS
- Fedora
- Ubuntu
- Debian
Setting up sudo user
Giving sudo access to users is highly dangerous and a simple typo or a mistake can cause fatal damages. Having sudo access is not always neccessary.
Inorder to enter the sudo root shell, we can use the following command and you will be prompted to enter you root password(not the user password)
1
su
In recent distribution, we can grant sudo permissions to users by navigating to /etc/sudoers.d
sub directory and creating a file the user name that we want the sudo permissions to be granted. However, this is not actually neccessary as sudo will scan all files in this directory as needed. the file can simply contain student ALL=(ALL) ALL
.
As an old practice, we can simply just add a new line at the end of the file /etc/sudoers
.
We also have to make sure that the file has proper permissions set to it.
1
2
## Some linux distributions might need 400 permissions instead of 440
sudo chmod 440 /etc/sudoers.d/student
Linux File Systems
As there are multiple linux distributions, it is important to understand the underlying file system of linux to make sure we have the right locations for creating and developing our applications accross these distributions.
Since linux is UNIX based OS, it consists of one big filesystem tree with root being on top of this tree. Within this, we can have one or more file systems mounted at various points, which appear as sub directories. These distinct file systems are usually on different partitions. Regardless of where they are and how they are mounted, all these filesystems make one big file system.
Linux eco system has been able to establish a standardized procedures for these file system to reduce the development pain when moving from one distribution to an another.
Before moving on to the file and data organization within this tree, the following is the taxanomy on how the kind of information to be read and written. There are basically two kinds of distinctions:
Sharable and Non - Sharable data
As the name suggests, sharable data is something that can be shared accross different hosts where as non sharable is specific to a particular host.
Static and Variable
Static data includes binaries, lib files, documentatino a nd anything else that does not change without system adminstrator’s assistance where as variable data can be changed even without system admin’s help
Filesystem Hierarchy Standard (FHS)
FHS specifies the main directories that need to be present within an operating system and also describes their purpose. By having a standarized layout, it helps with predicting which file location across linux distrubutions keep the functionality of the file constant.
The following link discribes all the different files and their purposes:
The following are some of the important directories and their purposes:
Directory | Purpose |
---|---|
/ | This is the root directory of the entire file system |
/bin | Essential exe programs that must be available in single user mode |
/boot | Files need to boot the system, like kernel, initrd or initramfs images and boot configuration files and bootloader programs |
/dev | Device nodes, used to interact with hardware and software devices |
/etc | system-wide configuration files |
/home | home directories, incl. personal files, settings etc |
/lib | librarires required by executables in /bin and /sbin |
/ lib64 | 64 - bit lib for exe files in /bin and /sbin for system that can run both 32 and 64 bit programs |
/media | mount points for removable media |
/mnt | temporarily mounted filesystems |
/ opt | optional application software packages |
/root | home directory for root users |
/sbin | essential system binaries |
/ tmp | temporary files. on most systems, these files are lost after a reboot |
/usr | multi user application, utilities and data |
/var | varaible data that changes during a system operation |
These are generic directory that can be found across distributions. But there can also be a distribution specific folders like /misc
or /tftpboot
etc.
For root directory, the partition it is contained in is often a dedicated partition while other directories like /home
, /var
etc are mounted later. THe root partition contains the most essential files required to boot the system and mount the other files later. Hence, it needs configurtion files, utilities, boot loader information and other start up essentials.
The root directory must be able to:
- Boot the system
- Restore the system from backups on external devices like NAS or Disk
- Recover or Repair the system – As administrators, we need to have tools and skills to diagnose and reconstruct a damaged system.
/bin
The /bin directory is very important because:
- It contains executable programs and scripts needed by both system administrators and unprivileged users, which are required when no other filesystems have yet been mounted; for example, when booting into single user or recovery mode.
- It may also contain executables which are used indirectly by scripts.
- It may not include any subdirectories.
Required programs which must exist in the /bin/ directory include: cat, chgrp, chmod, chown, cp, date, dd, df, dmesg, echo, false, hostname, kill, ln, login, ls, mkdir, mknod, more, mount, mv, ps, pwd, rm, rmdir, sed, sh, stty, su, sync, true, umount and uname [ and test may be there as well, and optionally, it may include: csh, ed, tar, cpio, gunzip, zcat, netstat and ping.]
Command binaries that are deemed not essential enough to merit a place in the /bin directory go in /usr/bin. Programs required only by non-root users are placed in this category.
Some recent distributions have abandoned the strategy of separating /bin and /usr/bin (as well as /sbin and /usr/sbin) and just have one directory with symbolic links, thereby preserving a two directory view. They view the time-honored concept of enabling the possibility of placing /usr on a separate partition to be mounted after boot as obsolete.
Recent distribution versions of RHEL, CentOS, Fedora, and Ubuntu have symbolically linked /bin and /usr/bin so they are actually the same.