Its older version is UNIX, similar to how Windows' early version was DOS. Its development dates back to the 1960s and 1970s.
Developed in the 1960's nd 70's at AT&T Bell Labs by Ken Thompson, Dennis Ritchie, and others. Designed as a portable, multi-tasking, and multi-user system.
- The source code was proprietary, although it had many variants, including BSD ( Berkeley Software Distribution ) and commercial version like AIX, HP-UX, and Server environments.
- Historically dominant in academic, enterprise, and Server environments.
- Popular variants includes IBM AIX, HP-UX and Oracle solaris.
Created by Linus Torevalds in 1991, inspired by the Unix system but not directly derived from its code. It is an open-source operating system kernel licensed under the GNU General Public License ( GPL ). Often combined with GNU software to form a complete operating system ( GNU/LINUX ). Widespread use across servers, desktop, embedded systems, and supercomputer s. -Popular distributions include Ubuntu, Fedora, CentOS, Debian, And Red Hat Enterprise Linux ( RHEL ). So Unix become a Linux overall there's a much difference.
~Operating system is a collection of programs that enables communication between computer Hardware and Software.
Win=User > Application > OS > Hardware Linux=User > Shell > kernel > Hardware
Shell is outer layer of anything, Outer surface of Linux with this we operate Linux Shell word come from that water shell 🐚 which have pearl inside.
Technically shell is user interface of linux, when we have to control it, command it, operate it so we use shell. Number of shells comes in linux that we can use , for other purposes we have different shells here.
-
Process Management
-
Memory Management— Ram and harddrive primary and secondary memory here we are talking about.
-
File system management — Windows have NTFS and FAT. LINUX have EXT2, EXT3, EXT4, XFS.
-
Device Management — OS not directly mange the Hardware but with help of kernel it do, Kernel is in both windows and linux, kernel interact the Hardware same on both. Kernel is a part of OS. In here first Drivers and then kernels.
-
Security and Protection
-
User Interface
-
Network Management
-
System Performance Monitoring
-
Utilities and Support Services
-
Open Source -> Linux is licensed under the GNU General Public License ( GPL ), Which allows users to freely use, modify and distribute the software,The source code is accessible to everyone(This are those softwares which are published with the source code,which anyone can take,use and modify. Like we made a program on C language that difference odd and even numbers when we comply that,an binary is generate,If we share that binary then it's closed source,On the other hand if we share the program that we wrote then it's open source,Which user can coustmize accordingly by there requirements). This Linux OS is fully open source,we can freely coustmize Or modify it and published it by our name,but if we use that financially so the profit that genrate we have to share it and gave reference of source. Like this OS is made on that particular OS source code, that License have it's term And conditions according to that we have follow it.
-
Multitasking -> Linux can handle multiple tasks simultaneously without degrading performance, making it ideal for both personal and enterprise-level applications.
-
Multi-user Support -> Multiple users can access and work on a Linux system simultaneously without interfering with each other.
-
Portability -> Linux is highly portable and can run on a variety of hardware platforms, from servers and desktops to embedded systems and smartphones.
-
Security -> Linux is designed with robust security features, including file permissions, user authentication, and a strong firewall. It is less prone to malware compared to other operating systems.
-
Customization -> Users can customize Linux to meet their needs by choosing from a variety of distributions (like Ubuntu, Fedora, or Debian) and desktop environments (like GNOME, KDE, or XFCE).
-
Command-Line Interface (CLI) -> The Linux terminal offers a rich command-line interface, enabling users to perform complex tasks efficiently through scripting and commands.
-
Stability and Performance -> Linux is known for its stability, often running for years without requiring a reboot. It is also efficient in resource usage, making it suitable for high-performance computing.
-
Package Management -> Linux distributions use package managers (like apt, yum, or pacman) to simplify the installation, updating, and removal of software.
-
Community Support -> Linux has a large and active community of developers and users who provide support, tutorials, and documentation.
-
Free of Cost -> Most Linux distributions are free to download and use, reducing costs for personal users and organizations.
this whole OS is based on unix system. some main distributions are:-
- Debian Family
Base Distribution: Debian Package Manager: apt (Advanced Package Tool) File Format: .deb Key Features: Stability, community-driven, excellent documentation.
Popular Derivatives:
Ubuntu: User-friendly, widely adopted for desktops and servers. Linux Mint: Designed for simplicity and ease of use, especially for newcomers. Kali Linux: Tailored for penetration testing and ethical hacking. Raspberry Pi OS: Optimized for Raspberry Pi devices.
- Red Hat Family
Base Distribution: Red Hat Enterprise Linux (RHEL) Package Manager: dnf (or yum) File Format: .rpm Key Features: Enterprise-focused, stability, and robust support.
Popular Derivatives:
CentOS Stream: Community-supported, upstream development for RHEL. Fedora: Cutting-edge technology and innovations. AlmaLinux & Rocky Linux: Community-driven alternatives to CentOS.
- Arch Family
Base Distribution: Arch Linux Package Manager: pacman Key Features: Rolling release model, minimalistic, highly customizable.
Popular Derivatives:
Manjaro: User-friendly version of Arch with pre-configured tools. EndeavourOS: Keeps the Arch spirit alive while simplifying installation.
Root Directory (/) The root directory is the topmost level in the hierarchy. All other directories and files reside under it.
- /bin (Binaries)
Contains essential user command binaries (executables) required for the system to boot and operate in single-user mode.
- /sbin (System Binaries)
Contains essential system administration binaries. Commands are typically used by the system administrator (root).
- /etc (Configuration Files)
Stores system-wide configuration files.
- /home (Home Directories)
Contains user-specific directories where personal files, settings, and data are stored.
- /root (Root User's Home Directory)
Home directory for the root user (superuser). Separate from /home for security reasons.
- /var (Variable Files)
Stores variable data that changes over time.
- /usr (User Programs)
Contains user-related utilities and applications.
- /lib and /lib64 (Libraries)
Stores shared libraries required by binaries in /bin and /sbin.
- /tmp (Temporary Files)
Used for temporary storage by applications and the system. Files here are usually cleared on system reboot.
- /dev (Device Files)
Contains device nodes that represent hardware devices (e.g., hard drives, USB drives, printers).
- /proc (Process Information)
Virtual filesystem providing information about system processes and hardware.
- /sys (System Information)
Similar to /proc, but specific to the kernel and hardware devices. Used for device management and debugging.
- /opt (Optional Software)
Contains optional, third-party software installed on the system. Common for proprietary software like Google Chrome.
- /boot (Boot Files)
Contains files required for booting the system.
- /mnt and /media (Mount Points)
/mnt: Temporary mount points for filesystems. /media: Auto-mount points for removable media (e.g., USB drives, DVDs).
- /srv (Service Data)
Stores data for specific services, like web servers or file servers.
Shell is the outer layer of any surface, linux's user interface is called shell. every shell maintain its history files on different locations like for bash shell history file is on .bash_history.
-
hostname : Hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name. its switches are : command! hostname -a localhost.localdomain localhost4 localhost4.localdomain4 localhost.localdomain localhost6 localhost6.localdomain6 -this is used for more details like hostname then PCname but in here all are hostname, command! hostname -i ::1 127.0.. -it will show IPv6. command! hostname -I 192.168.. -it will show IPv4.
-
pwd : Present Working Directory, Print the full filename of the current working directory.
-
id : it shows the details of user from which we are logged in , shows uid, its display name, group id, primary group name and groups name which is secondary.
-
ls : List information about the directory (the current directory by default).Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. Mandatory arguments to long options are mandatory for short options too. ls -l : ls -h , --human-readable : ls -a , --all : ls -R : ls -t :
-
cd : Change directory, home of that user and if that user dont have its home directory then it deny i dont have home.
cd . : shows the current directory.
cd .. : one folder out from the location. -
Switches or Subcommands : a) -h,--help,help : it will give summarised information theoritically of commmands switches.
b) man : man is the system's manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page asso‐ ciated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the manual.The default action is to search in all of the available sections following a pre-defined order (see DEFAULTS), and to show only the first page found, even if page exists in several sections ( for more practical information of commands switches).
c) info : it have both practical and theoritical info of commands switches. -
ifconfig : Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down.
ifconfig -a : display all interfaces which are currently available, even if down.
ifconfig -s : display a short list (like netstat -i).
ifconfig -v : be more verbose for some error conditions. -
touch : create an empty file at the present location, example. [root@localhost Desktop]# touch file.txt [root@localhost Desktop]# ls file.txt - we can create mutiple files with by space between and there name like this, [root@localhost Desktop]# touch f1.txt f2.txt f3 f4 [root@localhost Desktop]# ls f1.txt f2.txt f3 f4 - and if we want to create a file by name which have space we can by naming it in double,single qoutes (" ") or can use backslash\ before the space like this, double qoutes - [root@localhost Desktop]# touch "varin local" [root@localhost Desktop]# ls 'varin local' single qoutes - [root@localhost Desktop]# touch 'vc 2' [root@localhost Desktop]# ls 'vc 2' Backslash - [root@localhost Desktop]# touch vc\ 3 [root@localhost Desktop]# ls 'vc 3'
-
file : describes the media type of file, example. [root@localhost Desktop]# file file.txt file.txt: empty
-
cat : to read the files we use cat commands and also to write content in the file like this, [root@localhost Desktop]# cat d1 [root@localhost Desktop]# cat > d1 this is for test purpose. ^C [root@localhost Desktop]# cat d1 this is for test purpose. @ if we want our OS information then by this we can have command! cat /etc/os-release NAME="CentOS Stream" VERSION="9" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" ANSI_COLOR="0;31" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:centos:centos:9" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://issues.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream" next for the entry of DNS we can check it by, command! cat /etc/resolv.conf Generated by NetworkManager nameserver 8.8.8.8
-
mkdir : to create a directory we use mkdir command, example. [root@localhost Desktop]# mkdir dir1 dir2 dir3 dir4 [root@localhost Desktop]# ls d1 d2 dir1 dir2 dir3 dir4 when we have to create directory which'll have sub directories or folder we can create it by using switch -p which look like this, [root@localhost Desktop]# mkdir -p s1/s2/s3/s4 [root@localhost Desktop]# ls -R s1/ s1/:s2 s1/s2: s3 s1/s2/s3: s4 s1/s2/s3/s4:
-
Wild card() Globbing pattern : here we describe the pattern, and its apply where the pattern is match. its helpfull in both windows and linux even in programming languages its helpfull like in PHP, Python, Java, .Net, Some basic wildcarts are: * it means any number or character. example ca output be car,cat,ca,carpet,carll2 eg. rm -fv ma* ? it means any single character. example hel? output be help,hell,helw. eg. rm -f messages? [] it means Single character from range. example 1, file[0-2] output be file0,file1,file2. 2, [hd]ello output be include hello or dello eg. rm -vf messages[2-5] [!] it means Single character file not listed in brack. example file[!1] output be file0,file2 eg. rm -fv messages[!1] { } its a list of pattern with comma seprated terms. example {.txt,.pdf} output is where the extension .txt and .pdf. eg. rm -vf {.log,cron,messages?}
-
rm : to delete the directory or content of some files. (for content) [root@localhost d4]# rm -fv ma* removed 'maillog' removed 'maillog-20241201' removed 'maillog-20241210'
-
cp : copy the file or directory in desired location, it can have source multiple but can have only one destination whatever is in last can only be the destination, Copy SOURCE to Destination or multiple SOURCE(s) to DIRECTORY. its subcommand contain -v, --verbose used for explain what is being done. -R, -r, --recursive for copy directories recursively means its subdirectories also. command! cp -vr /etc/*.conf /root/Desktop/conf/: wildcard for .conf files. command! cp -vr /var/log/ ~/Desktop/d4 : from home of root then Desktop/d4. command! cp -vr /var/log/ . : here . means at current location. ! Example of multiple source to single destination are below command! cp -v /etc/passwd /etc/shadow /etc/gshadow /etc/group /var/log/messages /var/log/anaconda/anaconda.log /root/Desktop/d2 '/etc/passwd' -> '/root/Desktop/d2/passwd' '/etc/shadow' -> '/root/Desktop/d2/shadow' '/etc/gshadow' -> '/root/Desktop/d2/gshadow' '/etc/group' -> '/root/Desktop/d2/group' '/var/log/messages' -> '/root/Desktop/d2/messages' '/var/log/anaconda/anaconda.log' -> '/root/Desktop/d2/anaconda.log' We can also made a file after copy and rename it : command! cp -v /var/log/messages /root/Desktop/d3/messages2 '/var/log/messages' -> '/root/Desktop/d3/messages2'
-
mv : Move coomand means that we do cut paste of data, its not recommended bcuz at the time of copy, data is at risk , thatswhy its better to use copy(cp) instead of mv. it is recursive by default. command! mv anaconda-ks.cfg Documents/ : if we cut paste or move it on same location then it'll be renamed like this :- command! mv anaconda-ks.cfg anaconda-ks2.cfg : cuz here in linux we don't have rename command, we have but it doesn't works. pattern of command:- mv -v messages cron* firewalld lastlog anconda/ se* b* ../../d1/
-
ln : link commmand means for creating a shortcut for an long location we dont have to go for that all location, like we have to use var/log/messages many times so use this whole location in command but we want its shortcut on Desktop or at Current location. links are of two types Hard link and Soft link. -> (Hardlink) command! ln /var/log/messages my_hard_link then we`ll have my_hard_link name file at current location which have same content as of var/log/messages, this link will always there either actual file is there or not,this is called hard link it needs exact space at actual disk which actual file needs. to understand its full clone, lets check it after restarting the pc cuz after restarting this file updates and if we delete actual file rm -f /var/log/messages even thou its link remains, after rstarting we can see that log messages file again made but have limited lines and its link have all old content plus this new content also, here we said OS to write all contents of var/log/messages to my_hard_link this called hard link. -> (Softlink) command! ln -s var/log/messages my_soft_link this actual link as we call my_soft_link even also then var/log/messages is called, it have size very less then an actual one, here problem is that if actual file misplaced then the link breaks down, here apply everything that we apply on actual file
-
less : the content of command cat if its larger then we use command less with location to see content of then this less command only show the output which can come in screen size then it holds there after that we can use arrow keys to scroll down, up, right, left also can use page up,page down and enter to change line, space key to page up, same home key and end key. and from key Q we get out from command. less command used more than the More command. command! less /var/log/messages
-
more : more command also shows the content of file in an screen size then holds the output, its similar to less command but here on more command some keys dont supports like right left arrow key also Home, End key. thatswhy its better to use less command instead of more command
-
tty : terminal type means we have two types of terminal which is actual terminal means classic terminal when we open actual pc by terminal not graphicaly from CNTRL+ALT+(F1,F2,F3,F4,F5,F6,F7) keys like that tty we have 7 terminals on actual login without using any software for accessing it, now we loggedin graphgically on F1 its for graphically login and in there when we open terminal thats not an tty bcuz we got it from graphical interface,technically its not an actual terminal bcuz its not from software, its of Gnome shell thatswhy here command tty shows pts in output, same as we made ssh connection on windows there also it shows pts in tty command output, there are two types of terminal which is pts and tty, tty receives on physical login also only on console based not graphical based then only we can have tty otherwise not, Generally we have 1 to 7 tty which max can be of 10 on the other hand we can make pts as much as we require there numbers can increased it can be of upto 100. command!(pts) : tty command!(tty) : tty /dev/pts/0 /dev/tty3 tty tty /dev/pts/1 /dev/tty4
-
whoami : shows from which we are logged in. command! whoami root
-
who : it will show details of all users which are login. command! who
root seat0 2024-12-25 12:18 (login screen) root tty2 2024-12-25 12:18 (tty2) root pts/0 2024-12-25 12:21 (192.168..) root tty3 2024-12-25 13:06 root tty4 2024-12-25 13:06 root tty5 2024-12-25 13:07 vc pts/2 2024-12-25 13:49 (192.168..) Basically we see how many users on this machine is login for more details we use this two similar commands also: command! who -a command! w system boot 2024-12-25 12:17 13:58:54 up 1:41, 7 users, load average: 0.00, 0.00, 0.00 run-level 5 2024-12-25 12:17 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root ? seat0 2024-12-25 12:18 ? 1709 (login screen) root seat0 12:18 0.00s 0.00s 0.00s /usr/libexec/gdm-wayland-session --register-session gnome-session root + tty2 2024-12-25 12:18 01:38 1709 (tty2) {or} root tty2 12:18 1:41m 0.02s 0.02s /usr/libexec/gnome-session-binary root + pts/0 2024-12-25 12:21 . 2318 (192.168..) root pts/0 12:21 2.00s 0.05s 0.00s w root + tty3 2024-12-25 13:06 00:21 2970 root tty3 13:06 24:06 0.00s 0.00s -bash root + tty4 2024-12-25 13:06 00:49 3013 root tty3 13:06 24:06 0.00s 0.00s -bash root + tty5 2024-12-25 13:07 00:49 3057 root tty5 13:07 51:42 0.01s 0.01s -bash vc + pts/2 2024-12-25 13:49 . 3277 (192.168..**) vc pts/2 13:49 2:40 0.00s 0.00s -bash -
uname : for our version of linux mainly kernel information, command! uname -a Linux localhost.localdomain 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux for only kernel the switch is, command! uname -r 5.14.0-539.el9.x86_64 for architecture with kernel, command! uname -rs Linux 5.14.0-539.el9.x86_64
-
lscpu : for cpu information of our pc by simple, command! lscpu
-
lsusb : details of usb whatever we attached in here, command! lsusb
-
lspci : Pci slots we have in our device,it will shows the detail of devices which are plugged on Pci, command! lspci
-
lsblk : shows details of disks in our machine,command! lsblk
-
free -h : shows the usages of RAM, command! free -h
-
date : it will shows the current date and time in standard formate, command! date Wednesday 25 December 2024 02:58:56 PM IST for only month the formate is, command! date "+%m" 12 for only date the formate is, command! date "+%d" 25 for only year the formate is, command! date "+%y" 24 formate according to our choice can be, command! date "+%d-%m-%y-%H-%M-%S" 25-12-24-15-06-54 where %H is for hour,%M for minute,%S for seconds.
-
cal : opens the calender for any year which we need of its lowest value is 0001year and higest value is of 9999year. command! cal 2025 command! cal 0001 command! cal 12 10 9999 Also can jump on particular date,month,year in between the range.
-
ip a : its full command is ip address but it will match after one character so we can use only ip a, this also used for viewing IP, command! ip a
-
route -n : it will show our gateway along with interface name, command! route -n
-
history : it will shows the history of all commands which we used till now, when we restart or shutdown the pc then the last commands we used that commands will now save in history files, their location which is different for all shells like for bash its at .bash_history etc. command! history command! cat .bash_history and if we deleted that files then its deleted, after restarting or shutdown the pc started then again this file created and gonna stores histroy cuz thats its work to. but if we want never to maintain our history here, then we have /dev/null where we can put any content but its not goes there, so that we cant see any of its content, so we can create its link in /dev/null command! ln -s /dev/null .bash_history After history command, by using exclamation mark and the no. of that command then that command will run, Also if we want to run anyone command from few last commands where we remember that command is start from some rm sort of, so we can use ! and rm then any command from last that starts from rm will run, like this. command! !763 command! !rm also we can filter history command command! histroy 8 then only last 8 commands will appear
-
/dev/null : location where the content cant go, its an blackhole of linux means if we want to dump any content or permanently delete any file, so we can redirect here. command! cat /dev/null command! cat > /dev/null to write any content for checking, command! cat /dev/null to see the content we wrote,
-
echo : it prints the value and also variable but we have to gave variable in capital letters, command! echo
-
uptime : it will shows the uptime of cpu from last proper shutdown, command! uptime
-
exit : to end the ssh session, command! exit
-
logout : another way to end the session, command! logout
-
shutdown : to shutdown the pc, it will immediatelly not but takes time to shutdown. command! shutdown -P it will poweroff the pc nd shows time of 1min to let you stop the work performing, command! shutdown -P now do poweroff just now, command! shutdown -h h stands for halts means to do immediatelly asap shutdown, command! shutdown -h now it do shutdown now, command! shutdown -c if we want to cancel schedule shutdown then this command will do that, command! shutdown -r here r means to do restart with showing some time to let you stop the performing work, command! shutdown -r now restart now the connection or pc,
-
halt : it do poweroff immediatelly.
-
poweroff : here it do poweroff by sequencewise.
-
reboot : restart the pc.
-
init 0 : means to poweroff.
-
init 6 : means to restart.
To run multiple coomands in one command we can use ; or && in between different commands like this,
command# id ; ls ; date ; ip a ; pwd
command# id && ls && date && ip a && pwd
• Linux offers various text editors for editing connfiguration files, writing code, or managing text files.
- Command-line text editors Vi/Vim
• Features:
Modes: insert, Command, Visual. Lightweight, available on almost all Linux systems. syntax heighlighting and plugin support (Vim). • Basic Commands:
Insert mode: Press i. Save: :w. Exit: :q. Force exit without saving: :q! . exit with saving: :wq!. nano
• Features:
User-friendly and Simmple. Display of shortcuts at the bottom. • Basic Commands:
Ctrl+O: Save file. Ctrl+X: Exit editor. Ctrl+k: Cut text. Ctrl+U: Paste text.
• Cat
cat is also use as a text editor but it is not use for big files.
this is basically use to read the the content.
•bzip2 : bzip2 messages (file name) •gzip : gzip messages1 •zip : zip messages2.zip messages2 (create new file) •7za : 7za a messages3.7z messages3 (compress more compare others) (create new file) 7za e messages3.7z •tar : tar -cvf messages4.tar messages4 tar -xvf messages4.tar tar -czvf messages5.tgz messages5 tar -cjvf messages6.tbz messages6
Sort : The sort command is used to arrange the lines of a text file or input in a specified order, either alphabetically or numerically, ascending or descending. • Common Options:
-n : Sort numerically (default is lexicographically).
-r : Reverse the sort order (descending).
-k : Sort based on a specific field or column.
-u : Eliminate duplicate lines.
-t : Specify a delimiter (default is whitespace).
-f : Ignore case (case-insensitive sorting).
-b : Ignore leading blanks.
-M : Sort by month names (e.g., "Jan", "Feb", "Mar").
-o : Write the sorted output to a file.
head : tail : wc (word count) : cut : paste : grep :
A user account in linux is a record that allows an individual or process to log in and access the system with specific permissions and privileges. It erves as an identitiy for users to interact with the system, ensuring security and accountability.
• Username: A unique identifier for the user on the system (e.g., sachin, admin).
• User ID (UID): A unique numerical ID assigned to each user. for example:
- 0 is reserved for the root user.
- UIDs above a certain range are for regular users. • Group ID (GID): Specifies the primary group the user belongs to. groups help manage permissions collectively.
• Home Directory: A personal directory for the user to store files and configuration settings (e.g., /home/username).
•Shell: The default command-line interpreter for the user (e.g., /bin/bash).
• Password: Stored (usually in an encrypted format) to authenticate the user. It's often managed in /etc/shadow.
/etc/passwd: Contains user account information (excluding passwords).
/etc/shadow: Stores encrypted password data.
System Accounts: Used by system services and processes (e.g., root, daemon).
Regular User Accounts: Created for individuals to log in and perform tsaks.
Service Accounts: Dedicated accounts for applications or services to run with specific permissions.
Security: ensures that only authorised individuals or processes access resources.
Acccountability: Tracks user actions and access logs.
Customization: Allows personalised settings for each user.
In Linux, managing user accounts involves creating, modifying, and deleting them using commands like useradd, usermod, and userdel, or by directlyediting configuration files with administrative privileges.
Group Name: A Unique identifier for the group (e.g., developers, admin).
Group ID (GID): A Unique numerical identifier assigned to each group.
Group Members: A list of users who belong to the group. A user can beloong to multiple groups.
Primary Group: Each user is assigned a primary group when their account is created. Files created by the user are associated with this grouups.
-
System Groups: Used by system services and processes (e.g., adm,daemon).
-
User Groups: Created for users to belong tp specific roles or teams (e.g., dev,marketing).
•Access Control: Allows collective permisssion management for files, directories and resources.
•Simplified Administration: Reduces the complexity of managing permissions for multiple users.
•Collaboration: Faciltates teamwork by providing shared access to resources.
# cat /etc/login.defs
# grep -v "^#" /etc/login.defs | grep -v "^$"
Passwd File
• cat /etc/passwd [User] :[x] :[UID] :[Comment] :[Home directory] :[Default shell] root :x :0 :root :/root :/bin/bash daemon :x :2 :daemon :/sbin :/sbin/nologin sshd :x :74 :privilege-sperated SSD :/usr/share/empty.sshd :/usr/sbin/nologin apache :x :48 :apache :/usr/share/httpd :sbin/nologin armour :x :1000 :Armour Infosec :/home/armour :/bin/bash
- root - The first root is the username.
- x - Indicates that the account is protected by a shadowed password
- 0 - 0 is the suer ID for this user.
- 0 - 0 is the group ID for this user.
- root - comment about this user.
- /root - /root is the home directory for this user.
- /bin/bash - And finally /bin/bash is the shell for this user.
• cat /etc/shadow [User] :[Encrypted Password] :[Last pass change] :[Min pass age] :[Max pass age] :[Warning period] :[Inact period] :[Exp date] :[Unused] root :$6$ot1LMMm5ih8sJUM4$Q : :0 :99999 :7 : : : daemon :* :19760 :0 :99999 :7 : : : sshd :!! : 20034 : : : : : : apache :!! :20063 : : : : : : armour :$6$wf/dsYGa7aWhThyi$Y : :0 :99999 :7 : : : root - Username.
Encrypted Password - The password is using the $type$salt$shashed format. $typw is the method cryptographic hash algorithm and can have the follwign values:
17110 - Last password change
0 - Minimum password age
99999 - Maximum password age
7 - Warning period
...... - Inactivity period
...... - Expiration date
...... - Unused
• cat /etc/group
[group] :[x] :[GID] :[Comma-seperated list of username]
root :x :0 :
daemon :x :2 :
sshd :x :74 :
apache :x :48 :
armour :x :1000 :armour
root - The firstpart is the name of the group
x - x is a placeholder for password.
0 - The group ID / gid
armour - The lat part is a comma-seperated list of username that belong to that group.
Gshadow File
• cat /etc/gshadow
[group] :[Encrypted password] :[group administrators names] :[group members names]
root : : :
daemon : : :
sshd :! : :
apache :! : :
armour :! : :
root - Group Name
!! - Contains the encrypted group password of the text password which was specified using gpasswd command. if the file /etc/gshadow is deleted, then this encryped password is moved to second field of /etc/group. if no passworf is given to group, then a '!' is displayed in the file.
contains list of the group administrators names. By default it is blank i.e. only user having same name as,group name is first group adminstrator.
armour - contains list of group members names. Blank by default.