Linux Full Course - 11 Hours [2024] | Linux Tutorial For Beginners | Linux Training | Edureka
Introduction to Linux
In this section, we will learn about the birth of Linux and its evolution to become the dominant operating system. We will also get an overview of what will be covered in this Linux full course video.
Birth of Linux
- In 1969, Dennis Ritchie and Ken Thompson created C programming language and Unix operating system while working at AT&T Bell Labs.
- In the 1970s, many scientists collaborated together to contribute to the development of Unix operating system.
- Unix became popular due to open-source collaboration and commercial sale of Unix.
Fundamentals of Linux
- Learn what is Linux and how do we use it.
- Understand different shells in Linux.
- See how to install Linux using a virtual box.
- Learn basic commands on Ubuntu.
- Explore some Linux commands for DevOps.
Technical Aspects of Linux
Package Management in Linux
- Understand package management in Linux.
Administration in Linux
- Learn how to configure a DNS server.
Shell Scripting
- Get an introduction to shell scripting.
- See some shell scripting interview questions with answers.
Comparison with Other Operating Systems
Windows vs. Linux
- Compare Windows and Linux operating systems.
Unix vs. Linux
- Compare Unix and linux operating systems
Essential Interview Questions
- Look at some essential linux interview questions
The Birth of GNU and Linux
In the 1980s, there were many versions and dialects of Unix operating system, which led to confusion. Richard Stallman came up with the GNU project, which aimed to create a free operating system that people could collaborate on. This led to the combination of GNU and Linux kernel, resulting in various distributions of Linux.
The Birth of GNU Project
- Many versions and dialects of Unix operating system caused confusion.
- Richard Stallman created the GNU project to develop a free operating system for people to collaborate on.
- The combination of GNU and Linux kernel resulted in various distributions of Linux.
The Popularity of Linux
- Linus Torvalds put the next kernel source code online in 1991 or 1992.
- The combination of Linux and GNU gained popularity, leading to various distributions like Ubuntu, CentOS, Red Hat, Debian, Fedora.
- CentOS is reliable and fast while Ubuntu is popular.
Various Distributions of Linux
There are many versions or distributions of Linux available today. Some important commercial ones include Red Hat Enterprise Linux (RHEL), Fedora, Debian. Ubuntu is one of the most popular free distributions.
Commercial Distributions
- Red Hat Enterprise Linux (RHEL), Fedora, Debian are important commercial distributions.
- RHEL is stable and reliable for servers and workstations while Debian is developed by a group of developers as free open-source software.
Free Distributions
- Other free distributions include Linux Mint, OpenSUSE, Gentoo.
- CentOS is reliable and fast while Ubuntu is popular.
Linux Distributions and Features
In this section, the speaker talks about different Linux distributions and their features. They also discuss the advantages of using Linux over other operating systems.
Different Linux Distributions
- Centos is based on Red Hat Enterprise Linux.
- Ubuntu is a distribution based on Debian.
- There are different versions of Ubuntu like Xubuntu or Edubuntu.
Features of Linux
- Updates are easy to perform with just one command in the terminal.
- The Command Line Interface (CLI) allows for more control over software behavior compared to Graphical User Interface (GUI).
- Access to source code makes it easier for developers to create programs.
- Software is free, unlike Windows which requires payment and licensing.
Benefits of Using Linux
- Companies cannot use pirated versions of Windows due to audits and fines, but they can use Linux for free.
- Access to source code allows for customization and flexibility in software development.
Introduction to Linux
In this section, the speaker introduces Linux and its features.
Features of Linux
- Complete access to source code and freedom to modify it.
- Multiple distributions with various options and flexibility.
- Better malware protection compared to Windows.
Hands-On Session
In this section, the speaker provides a hands-on session on how to run commands in CentOS operating system.
Introduction to Terminal and Basic Commands
- Use of commands like PWD, clear, LS, and CD for browsing through different directories.
- The speaker is using a virtual machine (VM), specifically CentOS running on VirtualBox installed on Windows OS.
- The speaker shows multiple VM options available in VirtualBox including Ubuntu 64-bit.
Introduction to Ubuntu Operating System
In this section, the speaker introduces the Ubuntu operating system and explains the difference between Windows and Linux. The speaker also explains how files and folders are stored in Linux.
Understanding File Storage in Linux
- In Linux, files and folders are stored in a root directory.
- All documents, directories, or folders can be accessed from the file system.
- The forward slash (/) represents the root directory.
- Files and folders can be accessed through a tree hierarchical structure with one root and different branches representing directories.
Accessing Files Through GUI
- Files can be accessed through the graphical user interface (GUI).
- Documents, videos, music, etc., are stored in specific folders such as Desktop, Documents, Downloads, Videos or Music.
- These files or folders will be stored in /home/username if downloaded from the internet.
Accessing Files Through CLI
- The command-line interface (CLI), called Terminal in Ubuntu OS provides a faster way to access files than GUI.
- CLI is better for tasks that cannot be performed with GUI.
- PWD stands for print working directory. It displays the current working directory.
Understanding Directories and Navigation
In this section, the instructor explains how to navigate through directories using the terminal. They cover topics such as changing directories, listing contents of a directory, and navigating back to previous directories.
Changing Directories
- To change to a different folder in the present working directory, use the command
cdfollowed by the name of the folder.
- To move back to the previous directory in your path, use
cd ...
Listing Contents of a Directory
- Use
lscommand to list down all files and folders present in a directory.
- Ensure that you give exact names when navigating to folders or directories. Otherwise, it won't work.
Present Working Directory
- The present working directory displays the current directory that your terminal is in.
- The root directory is where all your directories or folders are marked from and everything can be accessed from there.
Clearing Terminal Screen
- Use
clearcommand to clear out all commands previously run on your terminal screen. However, they are not deleted but just hidden until you scroll down.
Navigating Directories
In this section, the speaker explains how to navigate directories using the CD and LS commands. They also demonstrate how to use the tab key to autofill directory names.
Using CD and LS Commands
- To navigate to a different directory, use the CD command followed by the directory name.
- To view the contents of a directory, use the LS command.
Autofilling Directory Names with Tab Key
- Use the tab key to autofill directory names after typing a few characters of their name.
- If there are multiple directories with similar names, type more characters before using tab for autofilling.
Echo Command and Sudo User
In this section, the speaker explains what is meant by standard output and demonstrates how to use the echo command and sudo user.
Echo Command
- The echo command writes its arguments to standard output which is displayed in your terminal.
- To clear your screen in terminal, use Ctrl+L or give clear command.
Sudo User
- The sudo user allows you to execute commands as another user (usually root).
Introduction to Echo, Su and Sudo Commands
In this section, the instructor introduces the echo, su and sudo commands. The echo command is used to print values of variables or strings to standard output. The su command is used to switch between users on a system, while the sudo command allows executing commands with superuser privileges.
Echo Command
- The echo command prints values of variables or strings to standard output.
- To print the value of a variable using echo, append a dollar sign before the variable name (e.g.,
echo $X).
- If you want to print a string instead of a variable value, simply pass it as an argument to the echo command (e.g.,
echo "Hello World").
Su Command
- The su command is used to switch between users on a system.
- The root user has ultimate permissions on a system and can access any folder that other users cannot access.
- To switch to the root user using su, type
suin the terminal and enter your root password when prompted.
- You can also use
su <username>to switch between different users on a system.
Sudo Command
- The sudo command allows executing commands with superuser privileges.
- When executing commands with sudo, only that particular command will have superuser privileges.
- Later in the session, there will be more information about creating and deleting users from the terminal.
Understanding Sudo and Su Commands
In this section, the instructor explains the difference between sudo and su commands in Linux.
Sudo vs. Su
- The sudo command executes only that particular command with root or superuser privileges.
- The su command logs you in as a root user, and all subsequent commands will be executed as a root user.
- When you give sudo username, you can switch to a different user. When you give su, you can switch to the root user.
Using Sudo and Su Commands
- To use sudo, type "sudo" followed by the command you want to execute with root permissions.
- To use su, type "su" followed by your password. You will then be logged in as a root user and can execute any number of commands.
- If you want to execute another command with root permission after using su, simply enter the command.
Using LS Command in Linux
In this section, the instructor explains how to use the ls command in Linux.
Basic Usage of LS Command
- The ls command lists all contents in the current working directory.
- When executed without any options or flags, it lists all directories and files present in the current working directory.
Options/Flags for LS Command
- Use "ls path" to list down contents present in a specific path.
- Use "ls -l" to list down all contents along with their owner settings, permissions, and timestamp.
- Use "ls -al" to list down all contents, including hidden files and directories.
Understanding Permissions in LS Command
In this section, the instructor explains the different permissions that can be seen when using the ls command with the -l flag.
Permissions in LS Command
- The first character indicates whether it is a file or directory. A "-" indicates a file, while a "d" indicates a directory.
- The next three characters indicate read, write, and execute permissions for the owner of the file/directory.
- The following three characters indicate read, write, and execute permissions for users belonging to the same group as the owner.
- The last three characters indicate read, write, and execute permissions for other users who are not part of the owner's group.
LS Command
In this section, the instructor explains how to use the LS command in the terminal to list all contents of a directory, including hidden files and directories. The author flag is also introduced to display the owner of each file.
Using LS -a Flag
- Use
ls -ato show all contents of a directory, including hidden files and directories.
- Hidden files and directories are not visible when using the GUI.
- The output will include regular files that are not hidden.
Using Author Flag
- Use
ls -lwith the author flag (ls -l --author) to display the owner of each file.
- The author name will be displayed instead of username and hostname.
- Output includes size and timestamp information.
Combining Flags
- Combine flags by using them together after
ls.
- Example:
ls -lashows all contents (including hidden) in long format.
- Example:
ls -laSsorts results by size.
Storing Results in a File
- Use
>symbol after a command to store results in a file.
- Example:
ls -la > file1.txtstores results in a new file called "file1.txt".
- Results can be stored in any directory by navigating there before running the command.
Working with ls and cd commands
In this section, the speaker explains how to work with the ls and cd commands in Linux.
Using the vi command to open a file
- The speaker explains that they used the vi command instead of ls.file because they made a mistake by not specifying a directory.
- They show how to use the vi command to open a file.
Storing output in a different file
- The speaker shows how to store output generated by the ls command in a different file using redirection.
- They demonstrate how to store the file in a specific directory.
Working with CD directories
- The speaker explains how to change directories using CD and switch between parent and child directories using "..".
- They explain how to switch to directories with spaces in their names using single or double quotation marks.
Switching Directories
In this section, the speaker explains how to switch between directories in Linux using the CD command. They also explain the difference between using a forward slash and not using one when switching to the root directory.
Using CD Command to Switch Directories
- The CD command is used to switch between directories in Linux.
- To switch to the root directory, use either "CD" or "CD /".
- Inside the root directory are other directories such as home and network. Desktop and documents are subdirectories of these parent directories.
Example of Changing Directories
- To change from the root directory to bin folder, use "CD bin".
- Inside bin folder, there are other folders that can be listed down using "LS" command.
- To go back to the root directory from bin folder, use "CD ..".
- To navigate through different subdirectories inside LMS folder located on desktop, use commands like "CD home/Erica/LMS/HBase/Advanced HBase Practicals Module 9".
Cat Command
In this section, the speaker explains what cat command is used for and how it differs from vi or Nano commands.
Displaying Content of Text Files with Cat Command
- Cat command is used to display content of text files and concatenate several files into one.
- When only one file name is given with cat command, it displays content similar to vi or Nano commands.
Displaying Contents of Multiple Files
- Cat command can list down contents of multiple files.
- It is possible to specify three different files with cat command.
Grep Command
In this section, the speaker explains what grep command is used for and how it can be used to search for specific patterns in text files.
Searching for Specific Patterns in Text Files with Grep Command
- Grep command is used to search for specific patterns in text files.
- The syntax for using grep command is "grep pattern filename".
- Grep command can also be used with regular expressions to search for more complex patterns.
Sort Command
In this section, the speaker explains what sort command is used for and how it can be used to sort data in text files.
Sorting Data in Text Files with Sort Command
- Sort command is used to sort data in text files.
- The syntax for using sort command is "sort filename".
- By default, sort command sorts data alphabetically. However, it can also be customized to sort numerically or by field.
Pipe Command
In this section, the speaker explains what pipe command is used for and how it can be used to combine multiple commands together.
Combining Multiple Commands Together with Pipe Command
- Pipe command is used to combine multiple commands together.
- The syntax for using pipe command is "command1 | command2".
- Pipe command can be used to filter data and pass it on to the next command.
Navigating Directories and Creating Files
In this section, the instructor explains how to navigate directories and create files in Linux using commands such as cd, ls, cat, and Ctrl D.
Navigating Directories
- Use the
cdcommand to change directories.
- Use
lsto list the contents of a directory.
- The present working directory is represented by
.and the parent directory is represented by...
Creating Files
- Use the
catcommand to display the contents of a file.
- Use
>or>>to redirect output to a file.
- To create a new file, use the direction symbol (
>) followed by the name of the file.
- For example:
cat > file2.txt
- To append text to an existing file, use double direction marks (
>>) followed by the name of the file.
- For example:
cat 501.txt >> file2.txt
Displaying File Contents with Cat Command
In this section, we learn how to display content from multiple files using cat command.
Displaying Multiple Files with Cat Command
- Use cat command followed by filenames separated by space to display content from multiple files.
- For example:
cat 501.txt file2.txt
Appending Text with Cat Command
In this section, we learn how to append text from one file into another using cat command.
Appending Text with Cat Command
- Use double direction marks (
>>) followed by filename where you want to append text.
- For example:
cat 501.txt >> file2.txt
Be careful while appending text as it can overwrite existing data if not used properly.
Introduction to Cat Command
In this section, the speaker introduces the cat command and explains its various options.
Understanding the Cat Command
- The cat command is used to concatenate files and display their contents.
- The
-nflag adds line numbers to all lines, including blank lines.
- The
-Bflag adds line numbers only to non-blank lines.
- The
-sflag squeezes multiple blank lines into one.
- The
-Eflag adds a dollar sign at the end of each line.
Introduction to Grep Command
In this section, the speaker introduces the grep command and explains its usage.
Understanding the Grep Command
- The grep command is used to search for a particular string or word in a text file.
- It can be used with various flags such as
-i, which ignores case sensitivity while searching for a string;-v, which displays all lines that do not match the given pattern; and-c, which counts the number of times a pattern appears in a file.
- Regular expressions can also be used with grep for more complex searches.
Introduction to Sed Command
In this section, the speaker introduces sed command and explains its usage.
Understanding Sed Command
- Sed stands for stream editor and is used for performing basic text transformations on an input stream (a file or input from a pipeline).
- It can be used with various commands such as
s/old/new/g, which replaces all occurrences of "old" with "new" in a file;d, which deletes specific lines from a file;p, which prints specific lines from a file; andy/source/dest/, which replaces characters from source with corresponding characters in dest.
- Sed can also be used with regular expressions for more complex transformations.
Introduction to Awk Command
In this section, the speaker introduces awk command and explains its usage.
Understanding Awk Command
- Awk is a powerful text processing tool that can be used for data extraction and reporting.
- It works by scanning a file line by line and performing actions based on patterns found in the input.
- It can be used with various commands such as
print, which prints specific columns from a file;if/else, which allows conditional statements; andfor/whileloops, which allow iteration over lines in a file.
- Awk also supports regular expressions for pattern matching.
Conclusion
In this section, the speaker concludes the tutorial on basic Linux commands.
Key Takeaways
- The cat command is used to concatenate files and display their contents.
- The grep command is used to search for a particular string or word in a text file.
- The sed command is used for performing basic text transformations on an input stream (a file or input from a pipeline).
- The awk command is a powerful text processing tool that can be used for data extraction and reporting.
- Regular expressions are supported by all four commands discussed in this tutorial.
Introduction to Grep Command
In this section, the speaker introduces the Grep command and explains how it can be used to search for specific strings in large files.
Using Grep Command
- The grep command is used via CLI to search for a specific string in a file.
- The -i flag can be used with grep command to make the search case-insensitive.
- The -v flag can be used with grep command to display lines where the searched string was not found.
- The -c flag can be used with grep command to count the number of lines where the searched string was found.
Example Usage
- To demonstrate how to use the grep command, the speaker creates a new file called "automobile.txt" and adds some content related to automobile companies.
- The speaker then uses the grep command with and without the -i flag to search for a specific string in the file.
- Finally, they demonstrate how using the -n flag displays line numbers along with matching strings.
Conclusion
In this section, the speaker concludes by summarizing what was covered in this tutorial on using Grep Command.
Summary
- The Grep Command is useful for searching for specific strings in large files via CLI.
- Different flags such as -i, -v, and -c can be used with Grep Command for different purposes.
- Line numbers can also be displayed along with matching strings using the -n flag.
Using grep command
In this section, the speaker explains how to use the grep command to search for specific text in a file or directory. The speaker also discusses various flags that can be used with the grep command.
Using the -v flag
- Use the -v flag to exclude lines containing a specific string from the output.
- When using -v flag, all results except for Yamaha and Lamborghini will be present.
- The -i flag is used to include case-insensitive options in search results.
Using the -c flag
- Use the -c flag to display the number of times a string was found in a file or directory.
- When using both -i and -c flags, Amber will also be included in search results.
Sorting Results with Sort Command
In this section, the speaker explains how to use sort command to sort files alphabetically or numerically.
Sorting Files Alphabetically
- Use
sortfollowed by filename(s) to sort contents of file(s) alphabetically.
- Sort command can also be used on directories and lists generated by other commands like
ls.
Sorting Files Numerically
- Use
-nflag withsortcommand to sort files numerically based on their content.
- To reverse order of sorting, use
-rflag withsort.
- To perform case-insensitive sorting, use
-fflag withsort.
Sort Command
In this section, the instructor explains how to use the sort command in Linux. The section covers different flags that can be used with the sort command, such as -r and -f. The instructor also demonstrates how to use the -n flag to sort files numerically.
Using Flags with Sort Command
- The -r flag is used to display results in reverse order.
- The -f flag is used to return results in a case-insensitive fashion.
- The -n flag is used to return results in numerical order.
Sorting Files Numerically
- To sort files numerically, we need to add numerical values before each line of text.
- When using the -n flag with the sort command, lines are sorted based on their numerical values.
Pipe Command
In this section, the instructor explains how to use the pipe command in Linux. The pipe command allows users to perform two operations within one command by separating them with a pipe symbol (|).
Using Pipe Command
- The pipe command is used to output the result of one command as input for another.
- An example of using the pipe command is searching for a string from a file using grep and then sorting those results using the sort command.
Conclusion
This video covered two important commands in Linux: sort and pipe. By understanding these commands, users can efficiently manage large amounts of data and automate tasks.
Linux Tutorial: Copy, Move, Make Directory, Remove Directory and User Permissions
In this section of the Linux tutorial, the instructor covers the copy move make directory remove remove directory and user permissions. The first topic covered is CP (copy).
CP Command
- CP stands for copy and is used to copy files or directories.
- To use CP through the terminal, specify the command followed by any flag, then specify the source and destination.
- A demonstration is shown where automobiles.txt is copied from documents to desktop using
cp automobiles.txt /root/home/edureka/Desktop.
- To copy a folder, use
cp -rfor recursive copy. An error message will appear if-rflag is not used.
Interactive Mode
- Use
cp -ifor interactive mode when copying files. This prompts you before overwriting existing files.
Move Command
- The move command (mv) moves or renames files or directories.
- To rename a file or directory, use
mv oldname newname.
- To move a file or directory to another location, use
mv filename /path/to/new/location.
Make Directory Command
- The make directory command (mkdir) creates a new directory.
- Use
mkdir dirnameto create a new directory with name "dirname".
- Use
-pflag with mkdir to create nested directories.
Remove Directory Command
- The remove directory command (rmdir) removes an empty directory.
- Use
rmdir dirnameto remove the directory named "dirname".
- Use
-pflag with rmdir to remove nested directories.
User Permissions
- Linux has three types of permissions: read, write, and execute.
- Permissions can be set for owner, group, and others using chmod command.
- To change permission for a file or directory use
chmod [permissions] filename.
- The numeric value of permissions is calculated by adding the values of read (4), write (2), and execute (1).
- Examples are shown where
chmod 777 filenamegives all users full access whilechmod 400 filenamegives only the owner read access.
Copying Files in Linux
In this section, the instructor explains how to copy files in Linux using the cp command. The different flags that can be used with the cp command are also discussed.
Using the -i Flag
- The -i flag is used for interactive mode.
- When copying a file using the -i flag, if a file with the same name already exists in the destination directory, it will prompt you to confirm whether or not you want to overwrite it.
- To confirm overwriting, enter "y". To cancel overwriting, enter "n".
Using the -n Flag
- The -n flag is used to prevent overwriting of files.
- By default, when copying a file using cp command, if a file with the same name already exists in the destination directory, it will be overwritten.
- However, by using the -n flag along with cp command, we can make sure that no files are overwritten.
Using the -u Flag
- The -u flag is used to update only those files whose content has changed.
- If a file with same name already exists in destination directory and its content is different from source file then only it will get copied otherwise not.
Using Verbose Mode (-v)
- Verbose mode (-v) provides detailed information about each step of copying process.
- It displays which folder or sub-folder is being copied and which files are being copied.
Interactive Mode Example
In this section, an example of how to use interactive mode while copying files is demonstrated.
Copying Files Interactively
- Use "-i" flag for interactive mode while copying files
- If a file with same name already exists at destination location then system prompts user whether they want to overwrite it or not.
- To confirm overwriting, enter "y". To cancel overwriting, enter "n".
Copying Files in Linux
In this section, the instructor explains how to copy files in Linux using the CP command. The instructor also demonstrates how to use the -N flag to prevent overwriting existing files and how to copy a file from a different directory to the current working directory.
Using CP Command
- To copy files in Linux, use the CP command.
- By default, CP overwrites existing files with the same name.
Using -N Flag
- Use the -N flag with CP command to prevent overwriting existing files.
- If a file with the same name exists in both source and destination directories, it will not be overwritten when using -N flag.
Copying Files from Different Directory
- To copy a file from a different directory to your current working directory, use "CP <path_to_file> ."
- The "." represents your current working directory.
Moving Files in Linux
In this section, the instructor explains how to move files in Linux using the MV command.
Using MV Command
- Use MV command to move or rename files in Linux.
- MV works like cut-paste where it removes original file from source directory and pastes it into destination directory.
Renaming Files
- To rename a file using MV command, specify new name as destination filename while keeping source path same.
Moving Files between Directories
- To move a file from one directory to another using MV command, specify source path and destination path as arguments.
- If the destination directory does not exist, MV will rename the file to the new name specified in the destination path.
Copy and Move Commands
In this section, the instructor explains the copy and move commands in Linux. The U flag is used to update the destination file only when the source file is different from the destination file. The MV minus V flag moves files and prints the system status.
Copy Command
- The CP command copies files or directories from one location to another.
- The R flag is used to copy directories recursively.
- The P flag preserves attributes such as timestamps, ownership, and permissions.
Move Command
- The MV command moves files or directories from one location to another.
- Use the V flag to see system status while moving files.
- Use I flag for interactive mode when moving multiple files at once.
Regular Expressions
- Regular expressions can be used with both CP and move commands to transfer all files of a particular format at once.
Overall, this section covers how to use copy and move commands in Linux, including flags such as R, P, U, V, I. It also introduces regular expressions for transferring multiple files at once.
[t=1:59:31s] File Management Commands
In this section, the instructor explains how to use file management commands such as CP and MV to copy or move files from one directory to another. The instructor also demonstrates how to create new directories using the mkdir command.
Copying and Moving Files
- To copy all files with a .txt format in a directory, use the command
CP *.txt.
- To move all files with a .txt format in a directory, use the command
MV *.txt /path/to/directory.
- Use
CDto change directories before executing these commands.
- It is possible to move files from the present working directory by specifying only the filename instead of the full path.
Creating Directories
- Use
mkdirfollowed by the desired directory name to create a new subdirectory in the current path.
- It is possible to create multiple nested directories at once by specifying them in order separated by slashes.
[t=2:04:13s] Make Directory Command
In this section, the instructor explains how to use the mkdir command to create new directories or folders.
Creating New Directories
- Use
mkdirfollowed by the desired directory name to create a new subdirectory in the current path.
- The newly created folder will be visible when using
ls.
Creating Multiple Nested Directories
- It is possible to create multiple nested directories at once by specifying them in order separated by slashes.
Creating Directories with mkdir and rmdir
In this section, the speaker explains how to create directories using the mkdir command in the terminal. They also cover how to remove directories using the rmdir and rm commands.
Creating Directories with mkdir
- Use
mkdirfollowed by the name of the directory you want to create.
- To create multiple directories at once, use
-pflag followed by a path that includes all parent directories.
- Example:
mkdir -p folder1/folder2/folder3
- Alternatively, use curly braces `` to specify multiple directory names separated by commas.
- Example:
mkdir folder1/folder2,folder3,folder4
Removing Directories with rmdir and rm
- Use
rmdirfollowed by the name of the directory you want to remove. This only works if the directory is empty.
- Use
rm -rfollowed by the name of a non-empty directory to remove it along with all its contents. Be careful when using this command as it permanently deletes files and folders.
Difference between rmdir and rm Commands
In this section, the speaker explains the difference between using rmdir and rm commands for removing directories.
- The main difference between these two commands is that
rmdircan only be used to remove empty directories whilerm -rcan be used to remove non-empty directories along with their contents.
- It's important to be cautious when using
rm -r, as it can permanently delete files and folders without any confirmation prompts.
Introduction to Remove Directory and RM Commands
In this section, the speaker introduces the Remove Directory (rmdir) and RM commands. They explain how these commands can be used to remove directories in Linux.
Removing Directories with rmdir Command
- The rmdir command is used to remove empty directories.
- To remove multiple folders at once, use the rmdir command followed by the folder names separated by a space.
- If a directory is not empty, it cannot be removed using the rmdir command. You must first delete all files and subdirectories within it.
- To delete both a parent directory and its child directory at once, use the -p flag followed by the absolute path of the child directory.
Using Verbose and Recursive Flags with rmdir Command
- The -v flag can be added to provide verbose output when removing directories.
- The -p flag only removes the specified child directory. To remove all subdirectories within that directory as well, use the -r flag along with it.
Removing Non-empty Directories with RM Command
- Unlike rmdir, RM command can be used to remove non-empty directories.
- When using RM command with -r and -p flags together, it removes both parent and subdirectories including non-empty ones.
Conclusion
In this section, the speaker concludes their discussion on Remove Directory (rmdir) and RM commands in Linux.
Key Takeaways
- Use rmdir command for removing empty directories
- Use rm command for removing non-empty directories
- Use -p flag with rmdir command to remove both parent and child directories at once
- Use -r flag with rm command to remove all subdirectories within a directory
- Use -v flag for verbose output when removing directories.
Working with User Permissions
In this section, the speaker explains the importance of user permissions for a Linux administrator and how to control them using the ls -l command. The different types of file permissions are also discussed.
Understanding File Types and Permissions
- Use the ls -l command to view file contents and their permissions in long format.
- The first 10 characters of each row represent the file type and user permissions.
- The first character represents the file type: D for directory, hyphen for normal file, C for character special file, B for binary special file.
- The next nine characters represent user permissions divided into three blocks: user, group, and others.
- User permissions are represented by rwx (read, write, execute).
- Group permissions are represented by rwx (read, write, execute).
- Other users' permissions are represented by rwx (read, write, execute).
Interpreting File Permissions
- The order of permission blocks is always rwxrwxrwx: user-group-others.
- A blank space in any block means that those users only have read and execute access.
- If all three blocks have rwx permission then it means that the owner has read/write/execute access to that particular file or folder.
This section provides an overview of working with user permissions on Linux systems. For more detailed information on this topic please refer to additional resources.
Understanding File Permissions in Linux
In this section, the speaker explains the concept of file permissions in Linux and how to modify them.
File Permissions
- Each file or directory in Linux has three types of permissions: read, write, and execute.
- These permissions are assigned to three different groups: user, group, and others.
- The permission for each group can be represented by a 3-bit binary number (r = 4, w = 2, x = 1).
- The permission for each group is represented by a string of nine characters. The first character represents the type of file (- for normal files), followed by three characters representing the user's permissions, then three characters representing the group's permissions, and finally three characters representing other users' permissions.
Modifying File Permissions
- To modify file permissions in Linux, use the
chmodcommand.
- Use
+to add new permissions and-to remove existing ones. For example:chmod g+w+x filename.
- Use
=to set new permissions and overwrite existing ones. For example:chmod u=rwx filename.
- You can also set access control for multiple users or groups at once using commas. For example:
chmod u+rwx,g+rx,o-rw filename.
Conclusion
Understanding file permissions is essential for managing files and directories in Linux. Using the chmod command allows you to modify these permissions as needed. Remember that each permission is represented by a binary number and a string of nine characters that represent the type of file and each group's permission.
Introduction to Linux Permissions
In this section, the instructor introduces Linux permissions and explains how they work.
Understanding Linux Permissions
- Linux permissions control access to files and directories.
- There are three types of permissions: read, write, and execute.
- Permissions can be set for three different groups: owner, group, and others.
- The chmod command is used to change file permissions.
Changing File Permissions
- Use chmod followed by a combination of letters and symbols to change file permissions.
- Use + or - to add or remove permission respectively.
- Use u for owner, g for group, o for others, and a for all users when changing permissions.
- Use r for read permission, w for write permission, and x for execute permission.
Changing Ownership of Files
- The chown command is used to change ownership of files or directories.
- Use chown followed by the new owner's username and the name of the file or directory.
Working with Linux Repositories
- Linux repositories contain stable versions of most software packages.
- yum is used on Red Hat Enterprise Linux systems while apt-get is used on Debian-based systems like Ubuntu.
- dny is used on Fedora-based systems.
- sudo yum install [package-name] installs a package using yum repository.
Installing Software on Linux
In this section, the speaker explains how to install software on Linux using repositories. He also explains how to install Java and set environment variables.
Installing Docker
- To install Docker, use the command
sudo yum install Dockerfor CentOS orsudo apt-get install Dockerfor Ubuntu.
- Once installation is complete, update environment variables in your
.bashrcfile and runsource .bashrc.
Installing Java
- Use the command
sudo yum install Java 1.8.0to download and install Java 8 from Linux repositories.
- If you already have a different version of Java installed, use the command
update-alternatives --config javato select which version to execute.
- Update environment variables in your
.bashrcfile with the path where Java is installed.
Other Software Installation
- Use commands like
sudo yum install PHP,sudo yum install MySQL server, orsudo yum install w getto easily download and install other software from Linux repositories.
Selecting Which Version of Java to Run
In this section, the speaker explains how to select which version of Java to run when multiple versions are installed.
- When multiple versions of Java are installed, only one can be executed at a time.
- Use the command
update-alternatives --config javato select which version of Java you want to execute.
Using Sudo Command on Linux
In this section, the speaker explains how and why to use sudo command on Linux.
- The sudo command allows users with root privileges access to everything on their system.
- Use sudo followed by a command that requires root privileges (e.g., installing software).
- Enter your password when prompted to execute the command as a root user.
Installing and Setting Up Java
In this section, the speaker explains how to install and set up Java on a Linux machine.
Installing Java
- To install Java, use the command
sudo apt-get install default-jdk.
- To avoid interactive mode during installation, use the flag
-ywith the command.
- Set environment variables by editing the
.bashrcfile usingsudo gedit .bashrc.
- Find where Java is installed in your system (usually in
/usr/lib/jvm) and set its path in.bashrc.
- Additionally, give the path to your bin directory.
Syncing Environment Variables
- After saving and closing
.bashrc, runsource .bashrcto sync environment variables with the terminal.
- This step is necessary for executing commands from that particular terminal.
Working with Tar Files
In this section, the speaker explains what tar files are and how to compress and decompress them on a Linux machine.
Tar Files vs. WinZip/WinRAR
- Tar files are equivalent to WinZip/WinRAR in Windows.
- Use tar files or gzip/gunzip files for compression/decompression on Linux.
Compressing/Decompressing with Tar Files
- Use
tar -cvf filename.tar foldername/to compress a file/folder into a tar file.
- The
-cflag stands for create.
- The
-vflag stands for verbose.
- The
-fflag specifies the filename of the output tar file.
- Use
tar -xvf filename.tarto decompress a tar file into its original form.
- The
-xflag stands for extract.
Introduction to Compressing and Decompressing Files
In this section, the speaker introduces the concept of compressing and decompressing files in Linux. They explain why it is important to compress files before transferring them and how to do so using tar files.
Compressing Files
- Tar files are commonly used for compressing files in Linux.
- To compress a file, use the command
tar -cvf <filename>.tar <file/folder>.
- The compressed file will have a smaller size than the original file, making it easier to transfer over FTP or SSH.
- To extract a compressed file, use the command
tar -xvf <filename>.tar.
Environment Variables
- Environment variables control the behavior of software packages installed in Linux.
- The path where packages are installed is specified in environment variables.
- When installing Java and Hadoop, environment variables must be set for both programs to work together.
Conclusion
In this section, we learned about compressing and decompressing files using tar files in Linux. We also learned about environment variables and their importance when installing software packages.
Setting Environment Variables
In this section, the speaker explains how to set environment variables in the bash RC file and provides examples of common environment variables.
Setting Environment Variables
- To set environment variables, go to your home directory and run
gedit .bashrc.
- In the
.bashrcfile, you can set the path for programs like Hadoop and Java.
- Other applications can access these programs by looking at their path in the
.bashrcfile.
- Common environment variables include:
printenv: lists all or almost all environment variables
echo $HOME: prints the path of the user's home directory
echo $PATH: prints a list of directories where the shell looks for commands
echo $HOSTNAME: prints the name of your system's host
echo $USERNAME: prints your username
echo $LANG: prints the language in which the system works (e.g. Chinese or English)
echo $BASH_VERSION: prints the version of bash being used
Regular Expressions
This section covers regular expressions and how they are used to search through data.
Regular Expressions
- Regular expressions (regex or regx) are used to search through data.
- They can be piped along with grep command to find patterns of text in files.
- With regex, you can search for patterns of data that match a certain pattern.
- For example, if you have a spelling mistake in a file (e.g. "aple" instead of "apple"), regex can help you find it.
[ ] Regular Expressions
In this section, the speaker explains how to use regular expressions with grep command and the combination of graph. The speaker also explains different symbols used in regular expressions such as dot, carrot symbol, dollar symbol, asterisk, question mark and brackets.
Using Regular Expressions with Grep Command
- Use pipe to use one operation's output as the input to another operation.
- Dot (.) can replace any character.
- Carrot symbol (^) matches the start of the string.
- Dollar symbol ($) matches the end of the string.
- Asterisk (*) matches zero or more times.
- Question mark (?) matches exactly one or more times.
- Brackets () can be used to group regular expressions.
Example of Using Regular Expressions
- Use cat and grep commands to search for strings starting with a particular character using carrot (^).
- Use regular expression to filter out those strings which are starting with a particular character.
Regular Expressions
In this section, the speaker explains how to use regular expressions in Linux commands.
Using Carrot and Dollar Symbols
- The Carrot symbol matches the starting of a string.
- The Dollar symbol matches the end of a string.
- To search for strings ending with a specific character, put the whole expression inside quotation marks.
Using Asterisk Symbol
- The Asterisk symbol represents zero or more occurrences of a character.
- Example:
grep -n 'a*' automobiles.txtwill display all occurrences where 0 or more times 'a' is occurring.
Using Dot Symbol
- Two dots represent filling characters with alphabetical sequence.
- Two numbers represent filling characters with numerical sequence.
- Combinations can be used to generate patterns.
Processes
In this section, the speaker explains what processes are and how they work in Linux.
Definition of Processes
- A process is an instance of a program running on your system.
- Multiple instances of programs can be present at any given time, referred to as processes.
Foreground and Background Processes
- There are two types of processes: foreground and background processes.
- Only one application or process can be in the foreground at any given time.
Identifying Running Processes
- You can determine which processes are running on your system by using the command
ps.
- Each process has a unique process ID.
Adding Users
In this section, the speaker explains how to add users in Linux.
Creating a New User
- To create a new user, use the command
adduser.
- You will be prompted to enter information about the new user, such as their name and password.
- The new user's home directory will be created automatically.
Granting Sudo Privileges
- To grant sudo privileges to a user, add them to the sudo group using the command
usermod -aG sudo username.
SSH
In this section, the speaker explains how to use SSH in Linux.
What is SSH?
- SSH stands for Secure Shell.
- It is used to securely connect to remote servers over an unsecured network.
Connecting via SSH
- To connect via SSH, use the command
ssh username@hostname.
- You will be prompted for your password.
- Once authenticated, you can execute commands on the remote server as if you were physically present at that machine.
[ ] Linux Processes and Process Management
In this section, the speaker explains the concept of processes in Linux and how to manage them. The speaker demonstrates how to use the top command to view all running processes and their details. They also show how to start a process from the terminal, push it to the background, and bring it back to the foreground.
Understanding Processes
- A process is initiated every time a program or software is started in Linux.
- The top command can be used to view all running processes on a system.
- Each process has a unique process ID (PID), user name, priority level, niceness value, CPU/memory usage, virtual memory usage, and other details associated with it.
Managing Processes
- To start a new process from the terminal, enter the command for that program or software.
- To push a running process into the background without stopping it completely, use Ctrl+Z or Ctrl+W.
- To bring a backgrounded process back into the foreground of your terminal window, use FG followed by the name of that process.
- To push a running process into the background again after bringing it back into focus with FG, use BG followed by that same process's name.
The speaker also briefly mentions niceness values as they relate to priority levels but does not go into detail about how they are set or adjusted.
Processes and User Management
In this section, the speaker talks about processes and user management in Linux.
Processes
- The
topcommand displays information about running processes, including CPU usage, memory usage, process ID (PID), and command.
- To see a list of all running processes, use the
ps uxcommand. To see only the processes started by the current user, useps -u <username>.
- To find the PID of a specific process, use the
pidof <process name>command.
- To terminate a process with a specific PID, use the
kill <PID>command.
User Management
- Users can be created using the
sudo useradd <username>command. Passwords can be set usingsudo passwd <username>.
- Users can be deleted using the
sudo userdel <username>command.
- Users are added to default groups when created. To add a user to a specific group, use the
sudo usermod -g <groupname> <username>command. Groups can also be created and deleted using commands such assudo groupadd <groupname>andsudo groupdel <groupname>.
Creating and Managing Users and Groups
In this section, the speaker explains how to create and manage users and groups in Linux.
Creating a User
- To create a user, use the command
sudo useraddfollowed by the desired username.
- To give the new user sudo access, use the command
sudo adduser <username> sudo.
- To set a password for the new user, use the command
sudo passwd <username>.
Creating a Group
- To create a group, use the command
sudo groupaddfollowed by the desired group name.
Deleting Users and Groups
- To delete a user, use the command
sudo userdelfollowed by the username.
- To delete a group, use the command
sudo groupdelfollowed by the group name.
Secure Shell (SSH)
In this section, the speaker explains what SSH is and how it can be used to gain remote access to systems.
How SSH Works
- SSH allows remote access to systems without physically accessing them.
- Two different systems are required: one as master and one as slave.
- The IP addresses of both systems must be set in
/etc/hosts.
- Use
ifconfigorip addr showto list down IP addresses of machines.
Setting Up SSH
- Set up IP address for master and slave machine in
/etc/hosts.
- Use commands such as
ssh-keygen,ssh-copy-id, andssh-addto set up SSH connection between two machines.
Using SSH
- Use command
ssh <username>@<IP_address>to connect remotely via SSH.
- Once connected via SSH, you can execute commands on remote system just like on local system.
Setting up SSH Connection
In this section, the speaker explains how to set up an SSH connection between a master and slave node. They also discuss potential issues with firewalls and generating RSA keys.
Setting Up IP Address for Slave Node
- To set up the IP address for the slave node, delete the existing IP address using a command before adding the new one.
- The same command can be used for both nodes.
Establishing Secure Connection
- Type "SSH master" or "SSH slave" to establish a secure connection between nodes.
- Once logged in, you will see the username of the system you are connected to.
Dealing with Firewalls
- If there is a firewall present, it is still possible to set up an SSH connection.
- However, generating RSA keys can be complicated for beginners.
- The speaker recommends turning off the firewall by dropping the ID table using a command that permanently disables it.
Checking Network Connections
In this section, the speaker demonstrates how to check network connections on both master and slave nodes.
Running ifconfig Command
- Use "ifconfig" command to check network connections on both nodes.
- On Linux systems, you will typically only see L naught and at zero options.
- F1 option appears when running VMs on your machine.
Understanding Entity Address and Network Address Translation (NAT)
- At 0 represents your NAT address or network address translation.
- L naught represents entity address which is your IP address used to connect to the internet.
- F1 represents different adapters used when running multiple VMs on your machine.
Setting Different IP Addresses for Master and Slave Nodes
- Set different IP addresses for each node by changing F1 adapter settings.
- Drop any existing IP addresses before setting new ones.
Pinging Slave from Master Node
In this section, the speaker explains how to ping the slave node from the master node.
Dropping Existing IP Address
- Before pinging, drop any existing IP address using a command.
- Repeat this process for both master and slave nodes.
Setting New IP Addresses
- Set new IP addresses for each node.
- The speaker sets their slave node's address as 192.168.56.3.
- Ping the slave node from the master node to ensure successful connection.
Setting Up IP Addresses
In this section, the speaker explains how to set up IP addresses for a master and slave virtual machine.
Dropping an IP Address
- To delete an IP address, use the command
sudo IP adder deletefollowed by the specific IP address.
- After deleting the IP address, run
ifconfigto confirm that it has been dropped.
Adding an IP Address
- To add an IP address, use the command
sudo IP adder addfollowed by the specific IP address and mask.
- After adding the new IP address, run
ifconfigto confirm that it has been added.
Updating ETC Hosts File
- To update the ETC hosts file with new IPs, go to home directory and enter
sudo gedit /etc/hosts.
- Copy and paste the new IPs into their respective sections for master and slave VMs.
- Save and close the file.
SSH Connection
In this section, the speaker explains how to establish a SSH connection between a master and slave virtual machine.
Establishing SSH Connection
- Use
SSH Mastercommand to connect from slave VM to master VM without specifying its specific IP address due to updating of ETC hosts file.
- Enter password when prompted.
- Confirm successful login by checking last login date/time.
SSH and Secure Shell Connection
In this section, the speaker explains how to access a remote machine using SSH and secure shell connection. The speaker demonstrates how to navigate through folders on the remote machine and access files.
Accessing Remote Machine
- To access a remote machine, use SSH command followed by the IP address of the remote machine.
- Use password authentication to log in to the remote machine.
- Once logged in, navigate through folders on the remote machine using CD command.
- Use LS command to list all files and folders in a directory.
Remote Access
- Two virtual machines can communicate with each other such that one VM is accessing and running commands inside another VM.
- Whatever is visible on one VM is accessible from another VM.
- To exit from a Master's machine, type "exit" which logs out of the SSH shell.
Firewall
- If there is a firewall enabled, an RSA key must be generated from the Master's end and set at the Slave's end for an SSH connection to be present despite a firewall.
- The speaker shows how to disable IP tables temporarily or permanently if needed.
Conclusion
The speaker concludes by recommending Centos and Ubuntu as preferred Linux distributions.
Kernel and Shell
In this section, the speaker talks about the kernel and shell. The kernel is responsible for allocating system resources and interacting with hardware, while the shell processes user requests through a command-line interpreter.
Introduction to Kernel and Shell
- The kernel is responsible for allocating system resources and interacting with hardware.
- Users communicate with the kernel through a program called the shell.
- The shell interprets commands entered by the user and converts them into a language that is understood by the kernel.
Evolution of Shells
- The first Unix shell was discovered in 1971, called V6.
- In 1977, Stephen Bourne introduced the Bourne shell (Bash), which offered several advantages over its predecessors.
- Bill Joy created the C-shell (Csh), which had interactive features that made it easier to use than other shells in the 1980s.
- David Corn developed Corn Shell (KornShell or Ksh), which was backward compatible with Bourne Shell but included many features of C-shell as well.
- Bash remains one of the most popular shells today. It was written by Brian Fox for GNU project as a free software replacement for Bourne Shell.
Shell Scripting
In this section, we learn about shell scripting. A shell script is a list of commands executed in order of execution.
Introduction to Shell Scripting
- A shell script is a list of commands executed in order of execution.
- Shell scripts are used for automation, system administration, and other tasks.
- The shell script is a functional language that interacts with the operating system.
Writing Shell Scripts
- To write a shell script, you need to create a file with the .sh extension.
- The first line of the script should specify which shell interpreter to use.
- You can add comments to your script using the # symbol.
- Variables can be defined in shell scripts using the = operator.
Scripting Examples
In this section, we learn about some examples of shell scripting.
Example 1: Hello World
- The first example is a simple "Hello World" program written in Bash.
- The echo command is used to print text to the terminal.
Example 2: File Backup
- The second example demonstrates how to create a backup of a file using Bash.
- The cp command is used to copy files, and variables are used to specify filenames.
Example 3: System Information
- The third example shows how to display system information using Bash.
- Commands such as uname and df are used to retrieve system information.
Conclusion
In this section, we conclude our discussion on kernel and shells and summarize what we learned about shell scripting.
Summary
- The kernel allocates system resources and interacts with hardware while users communicate with it through a shell.
- Shells have evolved over time, with Bash being one of the most popular shells today.
- Shell scripting is used for automation and system administration tasks, and scripts are written in functional language that interacts with the operating system.
Introduction to Linux Shells
In this video, the speaker introduces different types of shells in Linux and explains the differences between them. The speaker also demonstrates how to run a script in different shells.
Types of Shells
- The Bash command syntax includes ideas drawn from The Conch Shell and the seashell as well after that the world came across various other shells such as the public domain con shell which was basically a public domain or a free version of the Corn shell you had The Alchemist shell then you had the extensible shell or the Plan 9 shell today we have many other shells namely your Z shell your dbn armquist shell or the dash shell and the mere BSD cone shell.
- Four shells are discussed in detail: bone, bash, corn, and scheme.
- The C-shell is introduced as a great option for those comfortable with C programming language.
Shell vs Bash
- While people often use these terms interchangeably, they are not actually synonymous. Shell is a specification while Bash is an implementation of that specification.
- Bash has acquired many extensions over time that may change behavior of valid posix scripts. By itself, bash is not a posix shell but rather a dialect of it.
Running Scripts in Different Shells
- Speaker demonstrates running same script in three different shells (bone, sea, conch).
- Script searches recursively for all executable files in specified directory along with number of files found.
- Script design is divided into three basic sections: shebang symbol declaration, argument testing section using argv variable to represent number of arguments passed excluding command name, and ensuring argument passed in was a directory using D operator.
Conclusion
The speaker concludes the video by summarizing the key points discussed in the video and encouraging viewers to explore different shells to find one that works best for them.
- Speaker summarizes key points discussed in the video.
- Encourages viewers to explore different shells to find one that works best for them.
English Introduction to Shells
In this video, the presenter introduces shells and their importance in computing. The presenter also discusses the different types of shells available and their features.
Understanding Shell Scripts
- A shell is a program that interprets commands and acts as an intermediary between the user and the operating system.
- Shell scripts are programs written in shell language that can be executed by a shell.
- Shell scripts are used for automating tasks, running multiple commands at once, and creating custom tools.
Types of Shells
- There are different types of shells available such as Bourne-Again SHell (BASH), Z-shell (ZSH), Korn SHell (KSH), etc.
- Each shell has its own set of features, syntax, and licensing terms.
Writing Shell Scripts
- To write a shell script, you need to use a text editor like nano or vim to create a file with .sh extension.
- You also need to include a shebang line at the beginning of your script to specify which shell should be used to execute it.
Demo: Creating an Executable File Using Different Shells
- The presenter demonstrates how to create an executable file using different shells such as BASH, KSH, and C-shell (CSH).
- The presenter explains the similarities and differences between these shells while creating the executable file.
System Requirements for Running Linux VM
- To run Linux on your system using VirtualBox or VMware, you need at least 2 GHz dual-core processor, 4GB RAM, and 25GB free disk space.
Setting Up Linux VM
- The presenter explains the two major steps involved in setting up a Linux VM on your system using VirtualBox or VMware.
- The first step is to download and install VirtualBox or VMware on your system.
- The second step is to download a Linux distribution ISO file and create a new virtual machine using it.
Conclusion
- Shells are an important part of computing that allow users to interact with the operating system through commands and scripts.
- Different types of shells have their own set of features, syntax, and licensing terms.
- To write shell scripts, you need to use a text editor and include a shebang line at the beginning of your script.
- Running Linux on your system requires meeting certain hardware requirements and setting up a virtual machine using software like VirtualBox or VMware.
Setting up a Virtual Machine
In this section, the speaker explains how to set up a virtual machine using Oracle VirtualBox and Ubuntu.
Downloading Ubuntu
- To download Ubuntu, go to the official website and click on the download button.
Installing Oracle VirtualBox
- Install Oracle VirtualBox by following the setup instructions.
- Ignore any warnings that may appear during installation.
Creating a New VM
- Open Oracle VirtualBox and create a new VM by clicking on "New".
- Provide a name for your VM and allocate up to 4GB of RAM. Choose dynamically allocated hard disk storage.
Loading Ubuntu into the VM
- Click on "Settings" and select "Storage".
- Load the Ubuntu ISO image into your VM by selecting it from your files.
- Start the VM and follow along with the installation process.
Conclusion
The demo concludes with instructions on how to restart your system and access your newly created Ubuntu virtual machine.
Linux Directory Commands
This section covers some basic Linux directory commands.
PWD Command
- The PWD command displays the location of your current working directory in Linux.
mkdir Command
- The mkdir command is used to make new directories under any existing directories in Linux.
rmdir Command
- The rmdir command is used to delete directories that you have already created in Linux.
ls Command
-The ls command is used to display a list of content present in a directory in Linux.
Linux Directory and File Commands
In this section, the speaker explains the basic Linux directory and file commands. The commands covered include LS, CD, touch, and cat.
LS Command
- The LS command displays the contents of the current directory.
- To use the LS command, type "LS" in the terminal.
- To see the directories in your root directory, type "LS" in your terminal.
CD Command
- The CD command is used to change directories.
- To change to a subdirectory within your current directory, type "CD" followed by the name of that subdirectory.
- To change from your root directory to another directory, type "CD" followed by the name of that directory.
Touch Command
- The touch command is used to create empty files.
- Multiple files can be created with one touch command by listing their names after "touch".
- To create a file using touch, type "touch [filename]" in your terminal.
Cat Command
- The cat command is used to view or concatenate files.
- To add content to a file using cat, use "cat > [filename]" followed by the content you want to add.
- To concatenate two files using cat, use "cat [file1] [file2] > [new_file]".
Linux File Commands
In this section, the speaker explains the basic commands used to manage files in Linux.
RM Command
- The RM command is used to remove a file.
- Syntax:
RMfollowed by the file name.
- To remove a file, navigate to its directory and type
RMfollowed by the file name.
CP Command
- The CP command is used to copy a file or directory.
- Syntax:
CPfollowed by the names of the files you want to copy.
- To copy a text file called "1.txt" into another text file called "new.txt", type
CP 1.txt new.txt.
MV Command
- The MV command is used to move a file or directory from one location to another.
- Syntax:
MVfollowed by the name of the file you want to move and then the name of the directory you want it moved to.
- To move a file named "new.txt" from your current directory to a folder named "documents", type
MV new.txt documents.
Rename Command
- The Rename command is used for renaming files in bulk.
- Syntax:
rename 'old_name' 'new_name' *.filetype.
- To rename all text files in your current directory as PDF files, type
rename 'txt' 'pdf' *.txt.
Linux File Content Commands
In this section, the speaker explains commands that are useful for viewing and manipulating content within files.
Head Command
- The Head command displays the first 10 lines of a given file.
- Syntax:
headfollowed by the name of the file you want to view.
- To view the first 10 lines of a file named "example.txt", type
head example.txt.
Tail Command
- The Tail command displays the last 10 lines of a given file.
- Syntax:
tailfollowed by the name of the file you want to view.
- To view the last 10 lines of a file named "example.txt", type
tail example.txt.
Cat Command
- The Cat command is used to display the contents of a file.
- Syntax:
catfollowed by the name of the file you want to view.
- To view all contents in a file named "example.txt", type
cat example.txt.
Grep Command
- The Grep command is used for searching for specific text within files.
- Syntax:
grep 'search_term' filename.
- To search for all instances of "hello" in a file named "example.txt", type
grep 'hello' example.txt.
Introduction to Linux Commands
In this section, the instructor introduces various Linux commands and their functionalities.
Basic Linux Commands
- The instructor explains that the basic Linux commands are used to navigate through directories and files. These include
cd,ls,pwd, andmkdir.
- The
cdcommand is used to change directories, while thelscommand is used to list files in a directory.
- The
pwdcommand is used to display the current working directory, while themkdircommand is used to create a new directory.
Advanced Linux Commands
- The instructor explains that advanced Linux commands are used for more complex tasks such as file manipulation, searching for files, and editing files.
- Some of these advanced commands include
cp,mv,rm, andgrep.
- The instructor demonstrates how to use the
cpcommand to copy a file from one location to another.
- He also shows how to use the
mvcommand to move a file from one location to another or rename it.
- The instructor explains that the
rmcommand is used to remove files or directories permanently.
- He also demonstrates how to use the
grepcommand for searching for specific text within a file.
Other Useful Commands
- In addition, there are other useful commands such as piping (
|) and redirection (>).
- Piping allows you to take output from one command and use it as input for another command.
- Redirection allows you to redirect output from a command to a file or another location.
File Manipulation Commands
In this section, the instructor explains various file manipulation commands in Linux.
Head and Tail Commands
- The
headcommand is used to display the first few lines of a file, while thetailcommand is used to display the last few lines of a file.
- The instructor demonstrates how to use these commands with an example file.
Tag Command
- The
tagcommand is used to display the contents of a file in reverse order.
- The instructor demonstrates how to use this command with an example file.
More and Less Commands
- The
moreandlesscommands are used for displaying large files on the terminal screen.
- These commands allow you to scroll through the content of a large file without overwhelming your terminal screen.
User Commands
- There are several user commands in Linux such as
su,id, andsudo.
- The
sucommand provides administrative access to another user's account, while theidcommand displays user ID and group ID information.
- Finally, the instructor explains that the
sudocommand is used extensively in Linux for accessing files that require administrator permission.
Linux Commands Overview
In this section, the speaker provides an overview of various Linux commands and their syntax.
Sudo Command
sudocommand is used to execute a command with administrative privileges.
sudo useradd <username>is used to add a new user to the Linux server.
sudo passwd <username>is used to create or change the password for a user.
Group Add Command
sudo groupadd <groupname>is used to create a new user group in Linux.
Filter Commands
Cat Command
catcommand is used as a filter to display the contents of a file.
- To use
catas a filter, pipe it with other commands using the syntaxcat | <command> | cat.
Cut Command
cutcommand is used to select specific columns from a file.
- The syntax for using cut command is
cut -d<delimiter> -f<column_number> <filename>.
Grep Command
grepcommand stands for Global Regular Expression Print and it's used to search content from files.
- The syntax for using grep command is
grep <search_term> <filename>.
Introduction to Basic Linux Commands
In this section, the speaker introduces basic Linux commands that are frequently used in DevOps. The commands covered include com, SED, T, TR, unique and WC.
Com Command
- The com command is used to combine two folders and their contents.
- It displays the content of all files in three columns.
- Syntax:
com folder1 folder2
SED Command
- The SED command is a stream editor used to edit files using regular expressions.
- It does not permanently edit files but only displays edited content on the screen.
- Syntax:
SED 's/old_word/new_word/' file_name
T Command
- The T command is similar to the cat command but puts standard input or output and can also write them into a file.
- Syntax:
cat file_name | T new_file_name
TR Command
- The TR command is used to translate file content from lowercase to uppercase or vice versa.
- Syntax:
TR 'old_word' 'new_word' <file_name>
Unique Command
- The Unique command forms a sorted list where every word occurs only once.
- Syntax:
sort file_name | unique
WC Command
- The WC command counts words, lines and characters in a file.
- Syntax:
WC <file_name>
Basic Linux Commands Practical Demonstration
In this section, the speaker demonstrates how to execute basic Linux commands on a Ubuntu-based system.
The speaker shows how to use each of the commands covered in the previous section on a Linux-based system.
Basic Linux Commands
In this section, the instructor introduces basic Linux commands that every user should know. The commands covered include LS, clear, PWD, CD, echo, Su, sudo and touch.
LS Command
- LS is a command used to list files and directories in a directory.
Clear Command
- Clear command is used to clear the terminal screen.
PWD Command
- PWD (Present Working Directory) command is used to display the current working directory.
- To change the current working directory use CD (Change Directory).
Echo Command
- Echo command is used to print text on the terminal.
Su and Sudo Commands
- Su (Switch User) command is used to switch between users.
- If you want to switch to root user who has all permissions on the system use "sudo bash" or "su".
- Sudo (Superuser Do) command allows users with limited access rights to execute certain commands with administrative privileges.
Touch Command
- Touch command is used to create an empty file in a directory.
VI Editor and Cat Command
- VI editor is a classic text editor in Linux family.
- Use cat command for reading, modifying or concatenating text files.
Introduction to Basic Linux Commands
In this section, the instructor introduces basic Linux commands and their syntax.
Basic Commands
ls: command used to list files and directories in a directory.
cd: command used to change the current working directory.
pwd: command used to print the current working directory.
mkdir: command used to create a new directory.
File Manipulation Commands
cat: command used to display the contents of a file.
cp: command used to copy files and directories.
mv: command used to move or rename files and directories.
rm: command used to remove files and directories.
Flags for Commands
ls Command Flags
-lflag: displays detailed information about each file or directory in a long format.
-aflag: displays all files including hidden ones.
cat Command Flags
-bflag: adds line numbers only for non-blank lines.
-nflag: adds line numbers for all lines.
-Eflag: shows dollar sign at end of each line.
cp Command Flags
-nflag: does not overwrite existing file.
-uflag: updates destination file only when source is different from destination.
-rflag: recursive copy for copying directories, including hidden files.
mv Command Flags
-iflag: enters interactive mode and asks before overwriting files.
-uflag: updates destination file only when source is different from destination.
-bflag: enters verbose mode and prints the source and destination file.
rm Command Flags
-rflag: removes even non-empty directories.
-rfflag: removes non-empty directories including parents and subdirectories.