asthaghosh-blog
ash_codes
10 posts
#100DaysOfLearning I am preparing for my Linux System Administration certification
Don't wanna be here? Send us removal request.
asthaghosh-blog · 3 years ago
Text
Day 10
Chapter 11 : Text editor
How to create and edit files using the available Linux text editors.
nano, a simple text-based editor.
nano is easy to use and requires very little effort to learn. To open a file, type nano <filename> and press Enter. If the file does not exist, it will be created.
nano provides a two-line shortcut bar at the bottom of the screen that lists the available commands. Some of these commands are:
CTRL-G Display the help screen.
CTRL-O Write to a file.
CTRL-X Exit a file.
CTRL-R Insert contents from another file to the current buffer.
CTRL-C Show cursor position
vi and emacs, two advanced editors with both text-based and graphical interfaces
VIM COMMANDS
Tumblr media Tumblr media Tumblr media
2 notes · View notes
asthaghosh-blog · 3 years ago
Text
Day 9
Chapter 10: File operation
Explore the filesystem and its hierarchy
Linux supports a number of native filesystem types, expressly created by Linux developers, such as:
ext3
ext4
squashfs
btrfs.
- The most advanced filesystem types in common use are the journaling varieties: ext4, xfs, btrfs, and jfs. These have many state-of-the-art features and high performance and are very hard to corrupt accidentally.
- Linux Partition: Each filesystem on a Linux system occupies a disk partition. Partitions help to organize the contents of disks according to the kind and use of the data contained. One advantage of this kind of isolation by type and variability is that when all available space on a particular partition is exhausted, the system may still operate normally.
- Mounting and Unmounting: The mount command is used to attach a filesystem (which can be local to the computer or on a network) somewhere within the filesystem tree
- $ sudo mount /dev/sda5 /home
To unmount the partition, the command would be: $ sudo umount /home
Display how this file is used and how to configure it : man fstab
Display information about mounted filesystems: df -Th
Explain the filesystem architecture.
- Commands that are not essential (theoretically) for the system to boot or operate in single-user mode are placed in the /usr/bin and /usr/sbin directories.
- /proc : are called pseudo-filesystems because they have no permanent presence anywhere on the disk. The /proc filesystem contains virtual files (files that exist only in memory) that permit viewing constantly changing kernel data. /proc contains files and directories that mimic kernel structures and configuration information. It does not contain real files, but runtime system information, e.g. system memory, devices mounted, hardware configuration, etc.
- /dev : directory contains device nodes, a type of pseudo-file used by most hardware and software devices, except for network devices. This directory is:
Empty on the disk partition when it is not mounted
Contains entries that are created by the udev system, which creates and manages device nodes on Linux, creating them dynamically when devices are found.
- /var : directory contains files that are expected to change in size and content as the system is running (var stands for variable)
- /etc : directory is the home for system configuration files. It contains no binary programs, although there are some executable scripts.
- /boot directory contains the few essential files needed to boot the system. For every alternative kernel installed on the system there are four files:
vmlinuz The compressed Linux kernel is required for booting.
initramfs The initial ram filesystem, required for booting, sometimes called initrd, not initramfs.
config The kernel configuration file, is only used for debugging and bookkeeping.
System.map The kernel symbol table is only used for debugging.
- /lib: contains libraries (common code-shared by applications and needed for them to run) for the essential programs in /bin and /sbin. These library filenames either start with ld or lib
Compare files and identify different file types.
- diff is used to compare files and directories. This often-used utility program has many useful options (see: man diff)
Tumblr media
- type diff [options] <filename1> <filename2>. diff is meant to be used for text files; for binary files, one can use cmp.
- we can compare three files at once using diff3, which uses one file as the reference basis for the other two
diff3 MY-FILE COMMON-FILE YOUR-FILE
- A patch file contains the deltas (changes) required to update an older version of a file to the new one. Distributing just the patch is more concise and efficient than distributing the entire file. For example, if only one line needs to change in a file that contains 1000 lines, the patch file will be just a few lines long
- Compare files : diff MyFile1 MyFile2
- compare with refrence file : diff3 MyFile1 MyFile2 MyFile3ference
To apply a patch, you can just do either of the two methods below:
$ patch -p1 < patchfile $ patch originalfile patchfile
Back up and compress data
Basic ways to do so include the use of simple copying with cp and use of the more robust rsync.Both can be used to synchronize entire directory trees. However, rsync is more efficient, because it checks if the file being copied already exists. If the file exists and there is no change in size or modification time, rsync will avoid an unnecessary copy and save time. Furthermore, because rsync copies only the parts of files that have actually changed, it can be very fast.
cp can only copy files to and from destinations on the local machine (unless you are copying to or from a filesystem mounted using NFS), but rsync can also be used to copy files from one machine to another. Locations are designated in the target:path form, where target can be in the form of someone@host. The someone@ part is optional and used if the remote user is different from the local user.
rsync is very efficient when recursively copying one directory tree to another, because only the differences are transmitted over the network. One often synchronizes the destination directory tree with the origin, using the -r option to recursively walk down the directory tree copying all files and directories below the one listed as the source. To use rsync at the command prompt, type rsync sourcefile destinationfile
Compressing files: -
Tumblr media
Disk-to-Disk Copying (dd): The dd program is very useful for making copies of raw disk space. For example, to back up your Master Boot Record (MBR) (the first 512-byte sector on the disk that contains a table describing the partitions on that disk)
tar allows you to create or extract files from an archive file, often called a tarball. You can optionally compress while creating the archive, and decompress while extracting its contents.
dd can be used to make large exact copies, even of entire disk partitions, efficiently.
0 notes
asthaghosh-blog · 3 years ago
Text
Day 8
Chapter 9: Processes
Describe what a process is and distinguish between types of processes. A process is simply an instance of one or more related tasks (threads) executing on our computer. The operating system (especially the kernel) is responsible for allocating a proper share of these resources to each process and ensuring overall optimized system utilization
Tumblr media
when a process is terminating. Sometimes, a child process completes, but its parent process has not asked about its state, such a process is said to be in a zombie state; it is not really alive, but still shows up in the system's list of processes.
At any given time, there are always multiple processes being executed. The operating system keeps track of them by assigning each a unique process ID (PID) number. The PID is used to track process state, CPU usage, memory use, precisely where resources are located in memory, and other characteristics.
To terminate a process, you can type kill -SIGKILL <pid> or kill -9 <pid>. In Linux, a nice value of -20 represents the highest priority and +19 represents the lowest. A process with a high nice value simply allows other processes to be executed first.
Understand the use of load averages and other process metrics.
load average is the average of the load number for a given period of time. It takes into account processes that are:
Actively running on a CPU.
Considered runnable, but waiting for a CPU to become available.
Sleeping: i.e. waiting for some kind of resource (typically, I/O) to become available. It can be a be viewed by running w, top or uptime
The load average is displayed using three numbers (0.45, 0.17, and 0.12)
Linux supports background and foreground job processing. A job in this context is just a command launched from a terminal window. Foreground jobs run directly from the shell, and when one foreground job is running, other jobs need to wait for shell access.
We can either use CTRL-Z to suspend a foreground job or CTRL-C to terminate a foreground job and can always use the bg and fg commands to run a process in the background and foreground, respectively
- Ascertain how long your system has been up - uptime
- Display its load averages: top | head
link
Manage processes using ps and top
0 notes
asthaghosh-blog · 3 years ago
Text
Day 7
Chapter 8: Finding Linux Documentation
The man pages are the most often-used source of Linux documentation. They provide in-depth documentation about many programs and utilities, as well as other topics, including configuration files, and programming APIs for system calls, library routines, and the kernel. To list all pages on the topic, use -f option. To list all pages that discuss a specified topic (even if the specified subject is not present in the name), use the –k option. man –f generates the same result as typing whatis man –k generates the same result as typing apropos
0 notes
asthaghosh-blog · 3 years ago
Text
Day 6
Chapter 6: Command line operation
Some basic utility
cat: used to type out a file (or combine files).
head: used to show the first few lines of a file.
tail: used to show the last few lines of a file.
man: used to view documentation
Turning Off graphical desktop:
restart it (after logging into the console) with:
$ sudo systemctl stop gdm (or sudo telinit 3)
Restart it (after logging into the console) with:
$ sudo systemctl start gdm (or sudo telinit 5)
Basic Operations:
1. Shutting down: $ sudo shutdown -h 10:00 "Shutting down for scheduled maintenance."
2. Locating application : $ which Application_name / $ whereis Application_name
Accessing directories:
pwd : Displays the present working directory
cd ~ or cd :Change to your home directory (shortcut name is ~ (tilde)) cd .. :Change to parent directory (..)
cd - :Change to previous directory (- (minus))
$ cd /usr/bin :Absolute pathname method
$ cd ../../usr/bin :Relative pathname method
Exploring filesystem
cd / : Changes your current directory to the root (/) directory (or path you supply)
ls : List the contents of the present working directory
ls –a : List all files, including hidden files and directories (those whose name start with . )
tree -d : Displays a tree view of the filesystem
Hard links are very useful and they save space, but you have to be careful with their use, sometimes in subtle ways. For one thing, if you remove either file1 or file2 in the example, the inode object (and the remaining file name) will remain, which might be undesirable, as it may lead to subtle errors later if you recreate a file of that name.
Symbolic links take no extra space on the filesystem (unless their names are very long). They are extremely convenient, as they can easily be modified to point to different places. An easy way to create a shortcut from your home directory to long pathnames is to create a symbolic link. Unlike hard links, soft links can point to objects even on different filesystems, partitions, and/or disks and other media, which may or may not be currently available or even exist
touch <filename> : creates file
mv Rename a file 
rm Remove a file 
rm –f Forcefully remove a file
rm –i Interactively remove a file
rm -rf Forcefully remove a directory recursively
Searching
$ locate zip | grep bin :To get a shorter (and possibly more relevant) list, we can use the grep program as a filter.
To search for files using the ? wildcard, replace each unknown character with ?. For example, if you know only the first two letters are 'ba' of a three-letter filename with an extension of .out, type ls ba?.out.
To search for files using the * wildcard, replace the unknown string with *. For example, if you remember only that the extension was .out, type ls *.out.
List (using ls) files with names starting with g and containing five letters - ls g????
List (using ls) files whose names begin with mk and end with any characters - ls mk*
List (using ls) files having five letter names starting with g and second character between a-n. - ls g[a-n]???
List (using ls) five letter named files starting with g and not having the second character between a-m. - ls g[!a-m]???
To find and remove all files that end with .swp:- $ find -name "*.swp" -exec rm {} ’;’
Tumblr media
The Advanced Packaging Tool (apt) is the underlying package management system that manages software on Debian-based systems.
0 notes
asthaghosh-blog · 3 years ago
Text
Day 5
Chapter 6: Common application
Common applications used in Linux was discussed
0 notes
asthaghosh-blog · 3 years ago
Text
Day 4
Chapter 5: System Configuration from the Graphical Interface
For Debian-based systems, the higher-level package management system is the Advanced Package Tool (APT) system of utilities. Generally, while each distribution within the Debian family uses APT, it creates its own user interface on top of it (for example, apt and apt-get, synaptic, gnome-software, Ubuntu Software Center, etc). Although apt repositories are generally compatible with each other, the software they contain generally is not. Therefore, most repositories target a particular distribution (like Ubuntu), and often software distributors ship with multiple repositories to support multiple distributions. dpkg is the underlying package manager for these systems.
Red Hat Package Manager (RPM) is the other package management system popular on Linux distributions. It was developed by Red Hat, and adopted by a number of other distributions, including SUSE/openSUSE, Mageia, CentOS, Oracle Linux, and others
The Yet another Setup Tool (YaST) software manager is similar to other graphical package managers. It is an RPM-based application. You can add, remove, or update packages using this application very easily.
Tumblr media
0 notes
asthaghosh-blog · 3 years ago
Text
Day 3
Chapter 4: Graphical Interface
The default display manager for GNOME is called gdm. Other popular display managers include lightdm (used on Ubuntu before version 18.04 LTS) and kdm (associated with KDE).
The default display manager for GNOME is called gdm. The gdm display manager presents the user with the login screen, which prompts for the login username and password
Nautilus gives three formats to view files.
0 notes
asthaghosh-blog · 3 years ago
Text
Day 2
Chapter 3: Basics and System startup
The Boot Process
Tumblr media
The Basic Input/Output System (BIOS) initializes the hardware, including the screen and keyboard, and tests the main memory. This process is also called POST (Power On Self Test). The BIOS software is stored on a ROM chip on the motherboard. After this, the remainder of the boot process is controlled by the operating system (OS).
When booting Linux, the boot loader is responsible for loading the kernel image and the initial RAM disk or filesystem (which contains some critical files and device drivers needed to start the system) into memory. the most common ones are GRUB (for GRand Unified Boot loader), ISOLINUX (for booting from removable media), and DAS U-Boot (for booting on embedded devices/appliances). Most Linux boot loaders can present a user interface for choosing alternative options for booting Linux. The boot Loader is either in the boot sector (for traditional BIOS/MBR systems) or the EFI partition (for more recent (Unified) Extensible Firmware Interface or EFI/UEFI systems).
For MBR method firstly the boot loader examines the partition table and finds a bootable partition. Once it finds a bootable partition, it then searches for the second stage boot loader, for example, GRUB, and loads it into RAM (Random Access Memory). For systems using the EFI/UEFI method, UEFI firmware reads its Boot Manager data to determine which UEFI application is to be launched and from where (i.e. from which disk and partition the EFI partition can be found). The firmware then launches the UEFI application, for example, GRUB, as defined in the boot entry in the firmware's boot manager. This procedure is more complicated but more versatile than the older MBR methods.
The second stage boot loader resides under /boot. A splash screen is displayed, after selecting the OS the boot loader loads the kernels of the selected OS. Kernel is always compressed so its first task is to decompress itself. After which it will check and analyze the system hardware and initialize any hardware device drivers built into the kernel.
The boot loader loads both the kernel and an initial RAM-based file system (initramfs) into memory, so it can be used directly by the kernel
Once the kernel has set up all its hardware and mounted the root filesystem, the kernel runs /sbin/init. Besides starting the system, init is responsible for keeping the system running and for shutting it down cleanly.
SysVinit viewed things as a serial process, divided into a series of sequential stages. Each stage required completion before the next could proceed. Thus, startup did not easily take advantage of the parallel processing that could be done on multiple processors or cores. SysV was replaced by systemd. systemd start up faster than those with earlier init methods. This is largely because it replaces a serialized set of steps with aggressive parallelization techniques, which permits multiple services to be initiated simultaneously.
3 flash storage filesystem : ubifs, JFFS2, YAFFS
0 notes
asthaghosh-blog · 3 years ago
Text
Day 1
I am starting my LFS101 course. I have decided to post my learning in order to keep track and stay consistent!
Chapter 2: Linux Philosophy and Concepts
Linux is developed by a loose confederation of developers from all over the world, collaborating over the Internet, with Linus Torvalds at the head.
Linux borrows heavily from the well-established UNIX operating system. It was written to be a free and open-source system to be used in place of UNIX, which at the time was designed for computers much more powerful than PCs and was quite expensive. Files are stored in a hierarchical filesystem, with the top node of the system being the root or simply "/". Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.
Linux is a fully multitasking (i.e. multiple threads of execution are performed simultaneously), multiuser operating system, with built-in networking and service processes known as daemons in the UNIX world.
The kernel is considered the brain of the Linux operating system. It controls the hardware and makes the hardware interact with the applications. An example of a kernel is the Linux kernel.
A distribution also known as Distros is a collection of programs combined with the Linux kernel to make up a Linux-based operating system. Some common examples of distribution are Red Hat Enterprise Linux, Fedora, Ubuntu, and Gentoo.
The boot loader, as the name implies, is a program that boots the operating system. Two examples of a boot loader are GRUB and ISOLINUX.
A service is a program that runs as a background process. Some examples of the service are httpd, nfsd, ntpd, ftpd and named.
A filesystem is a method for storing and organizing files in Linux. Some examples of filesystems are ext3, ext4, FAT, XFS and Btrfs.
The X Window System provides the standard toolkit and protocol to build graphical user interfaces on nearly all Linux systems.
The desktop environment is a graphical user interface on top of the operating system. GNOME, KDE, Xfce and Fluxbox are some examples of the desktop environment.
The Shell is the command-line interpreter that interprets the command line input and instructs the operating system to perform any necessary tasks and commands. For example, bash, tcsh and zsh.
Community support and services: CentOS, OpenSUSE, commercial distributors, including Red Hat, Ubuntu, SUSE, and Oracle
Commercial support and services including Red Hat, Ubuntu commercial support, SUSE, and Oracle
1 note · View note