Linux Mynotes2024
Linux Mynotes2024
Linux Mynotes2024
What is Linux?
Linux
Linux is, in simplest terms, an operating system, assembled under the
model of free and open source software development and distribution.
Operating System
Operating systems are computer programs. An operating system is the
first piece of software that the computer executes when you turn the
machine on. The operating system loads itself into memory and begins
managing the resources available on the computer. It then provides those
resources to other applications that the user wants to execute.
To say that Linux is an operating system means that it's meant to be used
as an alternative to other operating systems, Windows, Mac OS, MS-
DOS, Solaris and others. Linux is not a program like a word processor and
is not a set of programs like an office suite. Linux is an interface between
computer/server hardware, and the programs which run on it.
Why Linux?
Linux has proven to be a tremendously stable and versatile operating
system, particularly as a network server. Its down-time is almost
negligible. We can run Linux servers continuously without reboot for many
years. There have been cases when Linux servers have been running for
more than 3-4 years without re-booting and then only taken down for a
brief period for routine maintenance.
History of Linux
1. Open Source:
o Freedom and Customization: Linux is free and open-source
software, meaning anyone can access the source code, modify
it, and distribute their own versions. This allows users and
organizations to tailor Linux to their specific needs.
2. The Linux Kernel:
o The kernel is the core of the operating system. It manages
hardware resources (CPU, memory, and devices), provides
process management, and facilitates communication between
software and hardware.
3. Linux Distributions:
o A distribution is a package of the Linux kernel along with
various software tools, libraries, and user interfaces. Popular.
Linux is the most popular operating system which provides several
powerful administrative tools and utilities that help us to manage the
systems effectively. With the Linux command line feature we can access
any system remotely and securely.
Ubuntu:
Currently the most popular distributor. The most user-friendly version for Linux newbies.
Fedora:
The next most popular distributor is Red Hat's free distributor that includes a powerful
desktop GUI based on Gnome 3 but there are also various spins of it that use different
desktops - such as KDE, LXDE, XFCE. It is often amongst the first to include new
technology and is strong on security. It has strong command line feature and is more reliable
and ideally suited to the slightly more adventurous user.
Linux Mint:
It is another user friendly version of Linux, based on the Ubuntu core or can described as "an
improved Ubuntu".
CentOS:
It is completely based on Red Hat Enterprise Linux. It is mostly used for servers.
Red Hat:
It is the best server distribution. But it is not free; you have to pay for it. If an organization
doesn’t mind spending dollars on purchasing the red-hat support, this is no 1 recommendation
to any organization who runs mission critical applications.
Debian:
Debian is known as one of the most well-tested and bug-free distributor. It serves as the
foundation for Ubuntu, most view Debian as a distro best-suited for those experienced with
Linux. Debian has a relatively slow release cycle, with stable ones coming out every one to
three years.
2. Kernel: Directly interfacing with the hardware layer is the kernel, the
heart of the Linux operating system. As the core part of the OS, the kernel is
responsible for low-level tasks such as disk management, task scheduling,
memory management, and controlling peripherals.
3. Shell: One layer up from the kernel is the shell. In simplest terms, the
shell is a user interface that allows users to interact with the kernel. In
Linux, most interactions with the shell occur in a command-line interface
(CLI), where users type commands interpreted by the shell.
There are several different shells available in Linux, each with its unique
features and syntax, such as
1. The Bourne Shell (sh)
2. Bash (Bourne Again Shell)
3. C Shell (csh)
4. TC Shell (tcsh)
5. Korn Shell (ksh)
The Linux/Unix file system hierarchy base begins at the root and everything
starts with the root directory.
Linux File system/File Hierarchy Standard (FHS)
The Linux File Hierarchy Structure or the File system Hierarchy Standard
(FHS) defines the directory structure and directory contents in Unix-like
operating systems. It is maintained by the Linux Foundation.
These are the common top-level directories associated with the root
directory:
Directories Description
Directories Description
/dev It is the location of the device files such as dev/sda1, dev/sda2, etc.
Directories Description
1. / (Root):
Primary hierarchy root and root directory of the entire file system
hierarchy.
Every single file and directory start from the root directory.
The only root user has the right to write under this directory.
/root is the root user’s home directory, which is not the same as /
2. /bin :
Essential command binaries that need to be available in single-user mode;
for all users, e.g., cat, ls, cp.
Contains binary executables.
Common linux commands you need to use in single-user modes are
located under this directory.
Commands used by all the users of the system are located here e.g. ps,
ls, ping, grep, cp
3. /boot :
Boot loader files, e.g., kernels, initrd.
4. /dev :
Essential device files, e.g., /dev/null.
These include terminal devices, usb, or any device attached to the
system.
5. /etc :
Host-specific system-wide configuration files.
Contains configuration files required by all programs.
This also contains startup and shutdown shell scripts used to
start/stop individual programs.
6. /home :
Users’ home directories, containing saved files, personal settings, etc.
Home directories for all users to store their personal files.
7. /lib:
Libraries essential for the binaries in /bin/ and /sbin/.
Library filenames are either ld* or lib*.so.*
8. /media:
Mount points for removable media such as CD-ROMs
Temporary mount directory for removable devices.
Examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives
9. /mnt :
Temporarily mounted filesystems.
Temporary mount directory where sysadmins can mount filesystems.
10. /opt :
Optional application software packages.
Contains add-on applications from individual vendors.
Add-on applications should be installed under either /opt/ or /opt/
sub-directory.
11. /tmp :
Temporary files. Often not preserved between system reboots and may be
severely size restricted.
Directory that contains temporary files created by system and users.
Files under this directory are deleted when the system is rebooted.
12. /usr :
Secondary hierarchy for read-only user data; contains the majority of
(multi-)user utilities and applications.
13. /proc:
Virtual filesystem providing process and kernel information as files. In
Linux, it corresponds to a procs mount. Generally, automatically
generated and populated by the system, on the fly.
Contains information about system process.
Relative Path: Relative path is defined as path related to the present working
directory(pwd). Suppose I am located in /home/user1 and I want to change directory to
/home/user1/Documents. I can use relative path concept to change directory to
Documents.
example:
here are two examples for changing directory, 1st by using relative path, 2nd by using
absolute path.
$ pwd
/home/user1
$cd Documents/ (using relative path)
$pwd
/home/user1/Documents
Ownership:
Closed Source:
Licensing:
Users of proprietary software must agree to the license terms set by the owner, which
typically restrict how the software can be used, modified, or redistributed. A common
example is end-user license agreements (EULAs).
License fees may apply, and the software might come with restrictions on the number
of installations or the types of devices it can be used on.
Limited Modification:
Users are generally not allowed to modify proprietary software. Only the owner or
authorized developers can make changes or updates.
Support:
Distribution Control:
The owner of the proprietary software controls how it is distributed and can limit its
availability, restricting users from sharing the software with others.
The Linux shell is the bridge that connects the user with the operating system. At the
core of the Linux operating system lies the kernel. This kernel is responsible for
managing the resources of the computer, like the memory, CPU, etc. When the user
wants to make the kernel work, it has to connect to it through a shell. Linux shell
programming is the term associated with shell scripting, which uses simple English to
give instructions to the computer. You can even instruct the operating system to do
repetitive tasks through Linux shell programming.
Note:
*System hard disk is named as cygdrive
*tab button on keyboard is used to automatically fill the paths and names
cd /:root directory
cd ~:Home directory
ls -a: list the hidden file and directories (list all files and directories)
File management
---------------
*touch
*cat
touch filename{1..10}.txt
cat dir1/filename
cat > filename : '>' this redirects and open the file for edit
cat >> filename : '>>' this appends and edit without overwriting the previous data of file
cat file1 > file2 this command redirect the contents file1 to file2
-------------------------------------------------------------
for i in $(seq 1 5)
do
done
Make Directories
----------------
mkdir <name1>/<name2>
mkdir dir{1..10}
mkdir -p <name1>/{name2,name3,name4}
mkdir -p <name1>/<name2>/<name3>/<name4>
mkdir -p its creates the directories with parent directory with sub directory
-------------------
rmdir <dir_name>
rmdir -p <name1>/<name2>/<name3>/<name4>
********************
cp filename{1..10}.txt directory
cp -r dir1 new_dir {it creates a new_dir and copies the content of dir1}
cp -r dir1 dir3 { if dir3 already exists,it will copy the dir1 to dir3}{
cp -i without overwrite
cp ../test1.txt ../test2.txt . from previous directory it takes the files and copy to current directory [dot
represent current directory]
Move Directories/files
mv dir1 ./dir11/dir12/dir13/dir14 {note '.' represent current directory}in this above command dir1
moved to sub directory dir14
mv -i file3.txt dir1
mv junk junk1 {here the junk directory renamed as junk1} so 'mv' can be used for rename also
mv filename{1..10}.txt directory
2.we can move multiple files to single directory (but the directory should exist)
3.we can move single directory to single directory(its not compulsory that
should exist)
Miscellaneous Commands
----------------------
11. Ps : used to list the currently running processes and their PIDs along with some
13. who : lets you display the users currently logged in to your UNIX or Linux
operating system.
14. Whoami : It displays the username of the current user when this command is
invoked.