What is Linux?
Is it an OS 🤔
Many people think Linux is an operating system, but in reality,
Linux is just a kernel!
A kernel is the core component of an operating system (OS) that
manages hardware and software communication.
💡 So, if Linux is just a kernel, what about the OS?🤯
🤯 A Linux Distro is known as OS🤯
A Linux distribution (distro) is a complete OS that includes:
Linux kernel
GNU are free software tools which makes Linux usable which
include(compilers, shell, utilities)
Desktop environment which includes (GNOME, KDE, etc.)
Package manager (APT, RPM, etc.)
Examples of Linux distro are Ubuntu, Fedora, Arch Linux, and
CentOS.
Difference between - and --
“-” represents a flag which is used to modify the
behaviour of a command and usually means we
will pass one letter argument, like 'ls - l'.
“--” represents long option, full word, more than
one letter means we will pass more than one
letter as argument, like ls --option, ls --color =
auto.
How does Linux knows about it’s
commands 🤔
Linux system commands (like ls, cp, mv, rm, etc.)
are stored as executable files in system
directories.
How to find the directory path of the linux
command 🤔
Linux directory structure
List all the files
ls → Lists visible files and directories.
Clear Screen !!!!
'clear' command clears the screen.
The same you can achieve by running
/bin/echo -e
"\x1b\x5b\x48\x1b\x5b\x32\x4a\c" ,
but 'clear' is easier to remember!
File creation, modification and
display
The touch command is used to create an empty file
or update its timestamp.
touch file.txt
The echo command prints text to the terminal or writes
text to a file.
echo "Hello, World!" > file.txt (overwrites a file)
echo "New line added!" >> file.txt (appends to the file)
The cat command display contents of a file
cat file.txt
Long Listing Format
ls - l - long listing format
ls -n - It converts the owner and the group to UID for user identifier
and GID for group identifier.
-rw-r--r--
- means a regular file (not a directory (d) or symlink (l))
rw - Owner can read and write, but not execute
r-- - Group(to which owner belong) members can only read.
r-- - Other members can only read
Hidden files
ls -a → Lists all files, including hidden files (.
prefix).
Sorting the files
Sorts file on the basis of
mtime - The last time file was modified.
atime - The last time file was accessed.
ctime - The last time file metadata is changed.
A file block is the smallest unit of data storage on a
disk. When a file is stored, it is divided into blocks,
and each block has a fixed size (typically 4KB in
modern systems).
Printing subdirectories
File author
File Permissions
r - Read - View file contents
w - write - Modify file contents
x - execute - Execute a file
😎 Modifying file permission
Add execute to owner: chmod u+x example.sh
Remove write from group: chmod g-w example.sh
Give full access to everyone: chmod a+rwx example.sh
Octal representation
rwx - 7 (4+2+1)
rw- 6 (4+2)
r-- 4 (4)
--- 0
chmod 644 example.txt → rw-r--r--
Owner - read, write permission
Group(to which owner belongs) - read
Other users - read