
Why we need Linux? What will be covered in this course? No one can afford to ignore Linux. The acceptance of Linux as a robust and dependable Operating System is growing day by day. Big Corporations, Small Business Houses, Govt. Departments, Colleges and Universities are moving to Linux as their choice platform.
This Course will covers basics as well as some advance Linux topics. The focus is to make your Linux fundamentals very strong and clear. It will help you in using Linux CLI very easily.
How to create files in Linux.
“cat” is the basic utility to create files. You have to specify the “name of file” after “>” symbol. Press <ctrl +d> for saving the file.
How to view contents of file.
How to create directories. How to list contents of directories.
How to get detailed information about files and directories.
How to append the contents to file.
How to create multiple directories and sub-directories at once.
How to remove files. How to remove directories.
How to recursively remove files/directories
How to view and change system date.
How to count number of lines, words and characters in file.
How to view current month calendar. How to view calendar of particular year.
How to view the calendar page by page. there are 2 ways to do this.
How to use more and less commands for viewing the output page by page.
What is the difference between more and less. Which one is more powerful.
How to create and view variables.
We have seen that many persons are not comfortable with text mode, some are even afraid of using Linux, having the misconception that Linux is the most difficult thing to learn.
But in our opinion Linux is the easiest thing to learn. You have to just make the right start. Understanding Linux internals/structure is the first step in that direction.
To understand, why people sometimes do not want to enter into Linux field, we will discuss simple example.
What are the different methods of accessing files in Linux. How different methods can create confusion in your mind.
How to redirect the output in Linux. What is the benefit of capturing output. The most critical thing to understand is when to use which redirection symbol (“>”, “|”)
requirement redirection symbol example
sending output to a <command> | who |wc -l, cal 2019 |more
sending output to a <file> > cat file1 file2 >file3
what is the advantage of using "tee" command.
Run “pwd” command immediately after login as users “root”, “vipin” & “u1”. Observe the output and draw some important conclusions.
username home directory
vipin /home/vipin
u1 /home/u1
Whenever we are creating any normal user, home directory “/home/{username}” automatically gets created. ie if we are creating user “anantika”, home directory “/home/anantika” will get created.
“root” user’s home directory is
username home directory
root /root
All normal users will have their home directories underneath “/home” directory. the advantage of having this structure is when we want to take backup of users, we can take backup of “/home” directory only. Another is when implementing disk quotas (placing limit on size and no. of files a user can use)
“root” user have got separate “/root” directory which no other user can use. it is just like having separate room for “principal” and one common room for “students” in a college.
Can normal user create files outside home directory?
What are the different directories in Linux. What is their use. How to navigate between directories. How to view Linux directories.
How to create aliases in Linux. How to view aliases. What are the benefits of using alias. How to remove aliases. How to make aliases permanent.
How to delete files in Linux as a normal user as well as root user. How rm command behaves differently for normal and root users. How to delete files and directories recursively. How to remove files in interactive manner. How to remove files forcefully. Use this command very carefully.
How to copy files/directories in Linux as a normal user as well as root user.
How copy command behaves differently for normal and root users.
How to copy files and directories recursively.
How to copy files in interactive manner.
How to rename/move files/directories in Linux as a normal user as well as root user.
How mv command behaves differently for normal and root users.
How to Use in-built help in Linux. Why using help is important. What are different types of help available in Linux.
One major stumbling block in Linux adaptation is so many commands with so many options. The biggest mistake is made, when you start thinking about remembering each and every command along with all the options. To be a expert in Linux, you need not to remember each and every thing.
The trick lies in using the help available in Linux. There are various ways to get help.
- man
- info
- whatis
- command --help
- /usr/share/doc
How to use wild cards (*, ?, [ ]) in Linux. What is the benefits of using wild cards in Linux.
The 3 wild card characters are (*, ?, [ ])
wild card meaning
* matches zero or more than zero characters
? matches any single character
[ ] options/range
Use of curly braces { } saves a lot of time when doing repetitive type of things in Linux.
How to edit files in Linux. How to use Vi editor in Linux.
What is Vim.
What is insert mode in vi editor.
What is line mode in Vi editor.
What is command mode in Vi editor.
How to save files.
How to perform copy, cut/paste and delete operation in vi/vim editor.
How to perform search and replace operations in vi editor.
How to use history in Linux. Why it is very helpful.
Linux system keeps a default history of last 1000 commands. it can be increased and decreased. Use of history can make your work a lot easier.
You can use <tab> for completing the commands and the name of files/directories. It saves lot of typing efforts plus less chances of entering the names incorrectly.
There are 2 ways to change the shell, one temporary (sub-shell) and the other permanently.
How many shells are available.
How to change shell temporarily/permanently as normal and root user.
How to change the prompt in Linux. “PS1” environment variable contains prompt settings.
escape character meaning
\u the username of current user
\h the hostname up to first dot (.)
\W the basename of current working directory with “$HOME” displayed as “~”
\t the current time in 24 hour HH:MM:SS format
\! history no of the command
\$ display “#” for superusers & “$” for others
This is one of the most important variable. if this variable is not properly set or we have made wrong changes in this variable, then changes can be a disaster for an average Linux user. Why?
Whenever we are running any command, it looks for command in the “directory” specified in “PATH” variable.
it is sometimes recommended to specify the full path of the command. By doing so, we are not longer dependent upon PATH variable. In shell scripts it is the preferred method.
What are the different ways of getting detailed information about files. Why getting detailed information regarding files is important.
What are different types of files available.
What are different permissions.
What is metadata.
Why understanding soft link, hard link and inode is critical. What is the use of these.
Hard links does not need any additional space, can be useful for fault tolerance. If we are accidentally going to delete original file, data still be in hard link.
Soft links are very important when the path to the resource is very long. The other important use is when we want to give some friendly name to resources.
What is login shell. What is non-login shell.
What are the critical files in Linux. When to use which file is important.
The followings scripts can be read by users depending upon whether the user is root/normal user and whether the shell is login or non-login.
1 /home/{username}/.bash_profile
2 /home/{username}/.bashrc
3 /etc/profile
4 /etc/bashrc
5 scripts in “/etc/profile.d/” directory
Each startup script can override the changes made by the previous scripts. So it is very important to remember the order in which the startup scripts are run.
Which file is read when user logout.
Gzip, bzip2 and zip are compression utilities.
Compress using gzip, it will create compress file with “gz” extension.
Compress using bzip2, it will create compress file with “bz2” extension.
Both utilities will comperes the files. These utilities are suitable for compressing single files but not directories. For that purpose we have to use “zip” utility.
We can decompress using gunzip and bunzip2.
Tar means tape archive. Tapes were the preferred media for backups in early days. Why it is one of most used utility. For understanding the concept of backup we will create certain files in “test” directory.
$ tar cvf test.tar test
(create the backup in “test.tar” file)
the syntax is
tar <options> <backup-file> <directory-to-be-backed-up>
$ tar xvf test.tar
(restore from backup)
option meaning
c create
v verbose
f use file for archive
x extract
u update
t list the contents of archive without extracting
z compress with gzip
j compress with bzip2
How to use tar with gzip and bzip2.
How to use tar with gunzip and bunzip2.
How to take backup of all users.
How to take backup at logout.
There are 2 types of variables local and global in Linux.
The difference between local and global variables is that local variables are not available in sub-shells, while global are available in sub-shells.
How to list all local and global variables.
How to list only global variables.
How to display the value of local and global variables.
How variables behave when used with single quotes (‘ ‘) and double quotes (“ “).
If you want to display simple text, you can enclose the text in single quotes (‘ ‘), double quotes (“ “) or no need at all for enclosing in single/double quotes but not recommended.
Single quotes will display the content without expanding any variable while double quotes allow expansion of certain variables.
View Information about Linux Partitions. How to Find Disk Used by Directories.
How to use df and du utilities.
Mount/umount is an important concept in Linux. To access new partitions, removable drives, USB drives, CDROM/DVDs, we have to make use of “mount” command.
How to access USB/Pen Drive in Linux. What problems you can face when accessing these and how to solve those.
Whenever we are running some commands/utilities, there might be two types of outputs, one normal output and other error type of output. There are 3 streams available.
INPUT (stdin) (0): standard input is generally keyboard. other can be mouse, mic etc.
OUTPUT (stdout) (1): standard output is your system screen. other can be printer, speakers.
ERROR (stderr) (2): standard error is your system screen. other can be printer, speakers.
How to redirect theses streams.
symbol meaning
> redirect output
1> redirect output
2> redirect error
< input
>> append output
2>> append error
&> redirect output and error (redirect all)
2>&1 redirect error to standard output
| redirect output to command
How to suppress errors using "/dev/null".
Understand Linux permissions. Handling permissions is a required skill set for any user. Understand user permissions.
What do we mean by “read(r)”, “write(w)”, “execute(x)” permissions on files. In Linux everything is dependent upon permissions.
With normal “cat”, you can check read permissions, “cat” with append “>>” is used for checking write permissions and running the file by giving absolute path (/home/y1/file2) is for checking execute permissions.
What do we mean by “read(r)”, “write(w)”, “execute(x)” permissions on files. In Linux everything is dependent upon permissions.
With normal “cat”, you can check read permissions, “cat” with append “>>” is used for checking write permissions and running the file by giving absolute path (/home/y1/file2) is for checking execute permissions.
What do we mean by “read(r)”, “write(w)”, “execute(x)” permissions on directories. In Linux everything is dependent upon permissions.
What do we mean by “read(r)”, “write(w)”, “execute(x)” permissions on directories. In Linux everything is dependent upon permissions.
Sometimes combination of permissions is most important. ie for entering into directory and listing the contents of that directory, we need read and execute (rx) permissions
When we run “ls -l”, it gives us detailed information regarding files and directories. It also gives detailed information about permissions.
1st column is regarding permissions. it contains 10 characters.
char 1 denotes file/directory (“-” means file, “d” means directory)
char 2,3,4 user permissions
char 5,6,7 group permissions
char 8,9,10 other permissions
How to change the permissions.
How to verify whether the permissions are according to your requirements or not.
What is major problem with user permissions.
What is the problem with user permissions.
How to solve the problem using group permissions.
Till now we have used the symbolic method of viewing and changing the permissions. The other can be octal/numeric method. In this generally we use 3 digit number.
* first digit denotes user permissions
* second denotes group permissions
* third digit denotes other permissions
* r=4,w=2,x=1
Suppose we want to give all permissions “rwx” to user(u), group(g), others(o). The numeric equivalent will be first digit(4+2+1=7), second(4+2+1=7), third(4+2+1=7), ie 777.
What is umask. What are the advantages of using umask.
When ever we are creating files and directories in Linux, default permissions should be “666” for files and “777” for directories. But that is too much openness. “umask” is used to reduce/subtract/withhold the permissions. The effective permissions can be obtained by deducting umask from default permissions.
The advantage of using umask is that you can control permissions of your newly created files and directories. otherwise first the files and directories will be created with certain permissions, then you have to use “chmod” to change the permissions.
“chown” can be used to change user, group or both user/group ownership on files/directories individually or recursively.
“chgrp” to change group ownership on files/directories individually or recursively.
”chmod” to change permissions on files/directories individually or recursively.
How to make file and directories irremovable even for “root”
How to make files append able only
How to make sure that no change in access time when accessing the files. This saves on disk i/o operations.
The answer lies in using “chattr”.
If your system is required to be managed by many people or you want to delegate certain tasks to one user (ie creating users), others tasks to someone else (disk management using fdisk) and so on, then “sudo” is of great help.
Other option could have been to give “root password” to other administrators, but not recommended. sudo allows a permitted user to run a command as superuser or as a another user as specified in “/etc/sudoers” file.
Sudo requires you to authenticate with password of “yourself”, not that of “root”, which is very important. Once authenticated, it will not ask for the password for next 5 minutes (which we can reset) for executing other commands. moreover whatever we are executing or trying to execute will get logged in “/var/log/secure” file.
How to use sudo.
How to give all permissions to user.
How to test permissions given to user.
Understand entries in sudo files.
How to add users.
How to create groups.
How to modify user settings.
How to delete users.
Various versions of CentOS 7 (18.04) such as full and minimal are available. Here we are going to cover how to download and install full version of Linux. What are the various steps. If you are already comfortable with installing Linux, you can skip this.
Various versions of CentOS 7 (18.04) such as full and minimal are available. Here we are going to cover how to install full version of Linux. What are the various steps. If you are already comfortable with installing Linux, you can skip this.
After installation is complete, we need to perform some post installation tasks. How to check current firewall settings and change.
In CentOS 7/RHEL 7, there are 2 ways to manage firewall. First one is “firewalld” and other one is “iptables”. Here we want to use the recommended method of “iptables”.
First install the “iptables-services” package by using “yum”. Then permanently disable the “firewalld” by using “systemctl disable firewalld” and temporarily by using “systemctl stop firewalld”.
Then flush the current firewall rules by using “iptables -F” and save the current status of rules by using “service iptables save”.
How to check security enhanced Linux (SELINUX) settings and change.
How to view current network settings and change.
After CentOS 7 Full version installation, Linux will boot in GUI (graphical) mode. How to run commands using GUI terminal. Mostly we will be working in TUI mode.
It is very important concept. We want to work in text mode.
How to change from GUI to TUI (Text User Interface) temporarily.
If default booting mode is GUI (graphical.target) then only 5 text virtual console plus 1 graphic console is available on (<ctrl + alt + F1>). These consoles can be accessed using the combination of ctrl, alt, functions (F1 to F6) keys.
How to change from GUI to TUI (Text User Interface) permanently.
If your default booting mode is text (multi-user.target), then default 6 text virtual consoles are available. You can get the graphical console by running “startx”. If you are going to run “startx” on “tty2”, then graphic console will be available on (<ctrl + alt + F2>). If you are going to run “startx” on “tty1”, then graphic console will be available on (<ctrl + alt + F1>).
How to install CentOS 7 minimal version.
Instructions for installing CentOS 8 minimal version.
No one can afford to ignore Linux. The acceptance of Linux as a robust and dependable system is growing day by day. big corporations, small business houses, government departments, colleges and universities are moving to Linux as their choice platform. Linux is future. It is the most flexible and open ended operating system (OS).
We will learn about:
- How to install Linux
- Linux command line basics.
- How to create files and directories.
- Home directory in Linux.
- Directory structure in Linux.
- Linux aliases.
- How to remove files and directories in Linux.
- How to copy files and directories in Linux.
- How to rename/move files and directories in Linux. - Linux help.
- Linux wildcards.
- How to use Vi, Vim file editor in Linux.
- Linux history command.
- Change Linux shell.
- How to change Linux prompt.
- How to create soft link in Linux.
- How to create hard link in Linux.
- Inodes in Linux
- What is login shell in Linux.
- What is non-login shell in Linux
- What are the most critical files in Linux and what is - their use.
- How to use compress and decompress using gzip, gunzip, bzip2, bunzip2, zip and unzip in Linux.
- How to backup and restore using tar in Linux.
- What are local and global variables in Linux.
- How to access CD/DVD/USB devices in Linux.
- What is input and output redirection in Linux.
- What is read permission in Linux.
- What is write permission in Linux.
- What is execute permission in Linux.
- How to change user permissions in Linux.
- How to change group permissions in Linux.
- What is umask in Linux.
- Symbolic vs numeric permissions in Linux.
- How to manage users and groups in Linux.
- Useful steps to configure sudo in Linux.
- How to use sudo in Linux.
This course starts from basics and takes you to some advance Linux concepts. The focus has been to make learning experience very simple and interesting. Everything has been explained by giving examples.