loader
Navrangpura, Ahmedabad, Gujarat
Follow us :

WHAT IS  LINUX?

“Linux” refers to the operating system kernel on which Red Hat Enterprise Linux (RHEL) is built. The open-source Linux kernel provides the fundamental features and services required for an operating system to run on hardware, modeled after the Unix operating system.

In addition to the Linux kernel, system utilities, libraries, and software packages, RHEL is a Linux distribution. It offers a dependable, supported, and enterprise-level deployment-ready platform for companies and organizations.

As an operating system kernel, Linux takes care of crucial tasks like process management, memory management, device drivers, file systems, networking, and security. It serves as a bridge between the hardware and software layers, enabling system services and applications to communicate with the underlying hardware resources.

Built on the Linux kernel, RHEL enhances the Linux operating system’s capabilities by incorporating business-class features, security improvements, management tools, and ongoing support. It is frequently utilized in server environments, cloud infrastructure, and other business applications.

Additionally, RHEL supports a broad variety of open-source software packages and tools, giving administrators and developers access to a robust ecosystem for the creation and deployment of applications

It’s crucial to remember that while Linux is the operating system’s foundation, RHEL is the distribution that combines the Linux kernel with other software elements to produce an entire operating system that is appropriate for use in business settings.

The kernel of an operating system is Linux. You may be familiar with UNIX. Linux is, in fact, a copy of UNIX. But Linus Torvalds essentially started from scratch to construct it. Since Linux is free and open-source, you can easily modify it and re-distribute it under your own name! Numerous Linux distributions exist; they are referred to as “distros”.

Linux flavours Name 

Ubuntu Linux
Red Hat Enterprise Linux
Linux Mint
Debian
Fedora
Manjaro
Elementary OS
Zorin
MX Linux
Pop_OS! (from System76)
And ( ETC ) 

Servers primarily utilize Linux. Linux servers are used to power almost 90% of the internet. This is due to Linux’s speed, security, and affordability! The expense of using Windows servers is the biggest issue. Linux servers can be used to resolve this. The Linux kernel also serves as the foundation for Android, the operating system that powers about 80% of smartphones worldwide. The majority of viruses operate on Windows, but not on Linux!

The Linux shell, sometimes known as “Terminal” 

So, in essence, a shell is a program that takes user commands, passes them through to the OS for processing, and then displays the results. Its key component is the Linux shell. Although some of its distributions have a GI (graphical user interface), Linux primarily uses a CLI. We’ll go over the fundamental commands used in the Linux shell in this tutorial.

Linux basic commands 

1. ls Red Hat Enterprise Linux (RHEL) uses the ls command to list the files and directories that are present in a directory. If no directory is supplied, the names of the files and directories in the current working directory are displayed.

The basic syntax of the ls command is:

ls [options] [directory]

The following are a few frequently used ls command options in RHEL:

( 1 ) Ls – l  Detailed information about files and directories is displayed in a long format.
( 2 ) ls -a reveals hidden files (those with a dot in the name).
( 3 ) ls -h Human-readable file sizes.
( 4 ) ls -t Sorts files and folders based on the most recent modification date
( 5 ) ls -r Reverse the listing’s order.
( 6 ) ls -R List the files and directories in every subdirectory.
( 7 ) ls -I Identify each file’s and directory’s inode number.

2. cd: Change the current working directory in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) by using the cd command. You can use it to move about the file system’s various directories

cd [directory]

The following are some crucial details concerning the cd command:

( 1 ) The cd will take you to your home directory if you run it without specifying a directory.
( 2 ) You can specify either an absolute path (beginning with /) or a relative path to get to a specific directory.
( 3 ) An absolute path identifies the full directory path starting at the file system’s root.
( 4 ) The directory path relative to the active working directory is specified via a relative path.

The cd command supports the following special symbols:

. The symbol denotes the current directory.
.. stands for the parent directory (the previous level).
~ The user’s home directory is represented by.

Following are a few instances of how to use the cd command in RHEL:

1 Make a home directory change:

cd

2 Using an absolute path, navigate to a particular directory:

cd /path/to/directory

3 Making use of a relative path, change to a certain directory:

cd relative/directory/path

4 to reach the parent directory, move up one level:

cd ..

5 Navigate to the current directory (helpful if you unintentionally execute cd without any arguments):

cd .

6 The user’s home directory is changed:

cd ~

3. pwd: The pwd command can be used in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) to print the current working directory. It shows you the directory’s absolute path at the moment.

The pwd command’s syntax is straightforward:

Pwd

The full path to the current working directory is output when you use the pwd command.

1. Here is an illustration of how to use the pwd command in RHEL:

pwd

/home/user/Documents

( 1 ) The result in this case shows the working directory’s absolute path as /home/user/Documents. It displays the user’s current location as being in the “Documents” directory.

( 2 ) The pwd command comes in handy when you need to reference the entire path for other commands or scripts or when you want to confirm the current directory.

( 3 ) The pwd command does not accept any parameters, which is a crucial distinction. It only shows the working directory at the moment.4

4. date: The date command in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) is used to display or set the system date and time. It offers details on the time, date, and other relevant parameters as of right now.

( 1 ) The date command provides a number of parameters that let you alter the system date and time or customize the output. Here are a few frequently chosen choices:

( 2 ) -u or –utc: Use Coordinated Universal Time (UTC) rather than the local time zone to display or set the date and time.

( 3 ) -R or –rfc-2822: Show the time and date in RFC 2822 format.

( 4 ) +%format:  Display the time and date in a particular format. For instance, %Y stands for the year, %m for the month, %d for the day, %H for the hour in 24-hour format, %M for the minute, and %S for the second.

Here are a few instances of how to use RHEL’s date command:

1. Show the time and date as of right now:

date

2. The time and date will be shown in UTC:

date -u

3. show the time and date in a particular format:

date "+%Y-%m-%d %H:%M:%S"

5. mkdir: The mkdir command is used in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) to create new directories (folders). With certain names and settings, it enables you to establish one or more directories.

The mkdir command’s fundamental syntax is as follows

mkdir [options] directory_name

( 1 ) The following are some critical details regarding the mkdir command:

( 2 ) Multiple directory names can be specified, separated by spaces, and mkdir will create each one at once.

( 3 ) The mkdir command typically creates folders in the location of the active working directory.

( 4 ) To create folders in a specified area within the file system, you can specify an absolute path.

( 5 ) Use the -p option to create the target directory and any parent directories in the path if they don’t already exist.

Here are a few instances of how to use RHEL’s mkdir command

1. In the directory where you are working, make a single directory:

mkdir directory_name

2. In the current working directory, make a number of directories:

mkdir dir1 dir2 dir3

3 A directory with the given path should be created:

mkdir /path/to/directory

4 If parent directories don’t already exist, create them.

mkdir -p /path/to/new/directory

Remember to substitute the desired name or path for the directory you want to create for directory_name or /path/to/directory.

The ls command can be used to confirm that the directories have been correctly created after running the mkdir command.

6. rmdir:  The rmdir command in Red Hat Enterprise Linux (RHEL)’s command-line interface (CLI) is used to delete empty directories (folders). You can eliminate folders that are empty of files or subdirectories

The rmdir command has the following basic syntax:

rmdir [options] directory_name

( 1 ) The following are key information regarding the rmdir command:

( 2 ) Only empty directories can be deleted with the rmdir command. A directory won’t be erased if it has any files or subdirectories.

( 3 ) The current working directory is where the rmdir command works by default.

( 4 ) To define the location of the directory you want to remove, you can offer an absolute path.

 Here is an illustration of how to use the rmdir command in RHEL:

1. In the current working directory, delete the empty directory:

rmdir directory_name

2. A given path should be used to remove an empty directory:

rmdir /path/to/directory

Always use the correct name or path when replacing directory_name or /path/to/directory with an empty directory that you wish to remove.

An error message stating that the directory is not empty will be displayed if you try to use the rmdir command on a non-empty directory. To remove the directory and its contents recursively in that situation, you might need to run the rm command with the right arguments.

To prevent mistakenly deleting significant files or directories, it is always a good idea to double-check the contents of a directory before executing the rmdir command.

7. mv: The mv command can be used in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) to move or rename files and directories. You can use it to modify the name or placement of a file or directory within the file system.

The mv command’s fundamental syntax is:

mv [options] source destination

The following are some critical details of the mv command:

( 1 ) The file or directory that you want to transfer or rename is represented by source.

( 2 ) destination denotes the new name or intended location for the file or directory.

( 3 ) The source will be relocated into the destination directory if it already exists. The source will be moved and/or renamed appropriately if the destination is a directory that doesn’t exist or has a different name.

( 4 ) To transfer or rename files and directories across various locations in the file system, you can specify absolute paths for both the source and destination.

Following are a few instances of how to use the mv command in RHEL:

1 Change the directory where a file is located:

mv file.txt /path/to/directory/

2 Change a directory’s location and all of its contents:

mv directory /path/to/new/location/

3 rename a directory or file:

mv old_name.txt new_name.txt

4 Moving and renaming a file or directory at the same time:

mv source.txt /path/to/new/location/new_name.txt

Keep in mind to substitute the proper file or directory names and paths according to your requirements for file.txt, directory, old_name.txt, or /path/to.

Additional parameters that can be used with the mv command include preserving file characteristics, forcing overwrites, and showing verbose output. To view all of the options available, use the man mv command in the terminal to access the mv command’s documentation page.

8. cp: The cp command can be used in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) to copy files and directories. You can use it to duplicate files and directories to a different position in the file system or to the same area inside the file system.

The cp command’s standard syntax is

cp [options] source destination

( 1 ) The following are some crucial details of the cp command:

( 2 ) The file or location you want to copy is represented by the source.

( 3 ) The target location where the duplicate will be generated is represented by the destination.

( 4 ) The source will be copied into the destination directory if it already exists. The source will be copied and/or renamed appropriately if the destination is a directory that doesn’t exist or has a different name.

( 5 ) If you want to move files and directories between various places in the file system, you can do so by giving absolute paths for both the source and destination.

Following are a few instances of how to use the cp command in RHEL:

1 A file should be copied to a different directory:

cp file.txt /path/to/directory/

2 Copy the contents of a directory to another directory:

cp -r directory /path/to/new/location/

Note: To copy folders and their contents recursively, use the -r option.

3 Renaming a file after a copy has been made:

cp old_name.txt new_name.txt

4 Copying a file or directory while keeping its permissions and timestamps intact:

cp -a source destination

Note: To maintain file attributes, use the -a option.

Keep in mind to substitute the proper file or directory names and paths according to your requirements for file.txt, directory, old_name.txt, or /path/to.

Additional parameters for the cp command include maintaining links, forcing overwrites, and displaying verbose output, among other things. Man cp can be used in the terminal to investigate all of the options available by referring to the cp command’s documentation page.

9. touch:  The touch command in the command-line interface (CLI) of Red Hat Enterprise Linux (RHEL) is used to create new files or change the timestamp of existing files. Empty files can be created or the access and modification times of existing files changed often.

The touch command’s basic syntax is as follows:

touch [options] file_name

The following are some significant details concerning the touch command:

( 1 ) The touch command creates a brand-new, empty file with the supplied file_name if it doesn’t already exist.

( 2 ) The touch command adjusts the access and modification timestamps of the file to the current time by default if the file_name already exists.

( 3 ) The touch command by default adds or modifies a single file’s timestamp.

( 4 )To simultaneously create or update the timestamps of several files, you can use multiple file_name parameters.

Listed below are a few instances of how to use the touch command in RHEL:

1 Make a fresh, blank file:

touch file.txt

2 Put the most recent time in an existing file’s timestamp:

touch existing_file.txt

3 Make a number of blank files:

touch file1.txt file2.txt file3.txt

4 Add the current time to the timestamps of numerous existing files:

touch file1.txt file2.txt file3.txt

Keep in mind to substitute file.txt, existing_file.txt, or file1.txt, file2.txt, and file3.txt with the appropriate file names to meet your needs.

A precise timestamp can be specified, file characteristics can be adjusted, and verbose output can be displayed using additional options that are included with the touch command. The command man touch in the terminal can be used to investigate all of the options available by referring to the manual page for the touch command.

10. find Using a variety of criteria, the find command in Red Hat Enterprise Linux (RHEL) can be used to search for files and directories inside a directory hierarchy. With the use of criteria like name patterns, file kinds, sizes, timestamps, and more, you may find files and folders that meet your requirements.

The find command’s fundamental syntax is as follows:

find [path] [options] [expression]

( 1 ) What you should know about the search command includes the following:

( 2 ) The search’s initial directory is represented by [path]. The current directory is used as the starting point if none is provided.

( 3 ) [Options] offer other search settings, including restricting the depth, omitting specific directories, or regulating the output format.

( 4 ) [expression] gives the search parameters or the operations to be carried out on the files and directories that are found.

The search command in RHEL can be used in the following situations:

1. In the current directory and its subdirectories, look for files with a certain name:

find . -name "filename.txt"

2. Search for directories bearing a particular name and remove them (use with caution):

find . -type d -name "directory_name" -exec rm -r {} \;

3. Get files that are bigger than a certain size:

find /path/to/search -type f -size +1M

4 Search for files edited within a certain time frame:

find /path/to/search -type f -newermt "2022-01-01" ! -newermt "2022-12-31"

Keep in mind to substitute the appropriate numbers or patterns for filename.txt, directory_name, /path/to/search, or the date range to meet your needs.

With the find command, you may narrow down your search using a variety of arguments and phrases. The logical operators (-a, -o, and!) allow you to combine several expressions and carry out sophisticated searches. For more information on all of the available options and phrases, use the man find command in the terminal.

11 .tar: When using the command-line interface (CLI) in Red Hat Enterprise Linux (RHEL), the tar command is used to generate and modify archive files. It is frequently used to extract or list the contents of preexisting archive files as well as combine numerous files and folders into a single archive file.

In addition to archive operations, the tar command supports a number of compression techniques, including gzip (*.tar.gz), bzip2 (*.tar.bz2), and xz (*.tar.xz).
The tar command’s fundamental syntax is as follows:

tar [options] archive_file files/directories

( 1 ) The tar command has the following key information that you should be aware of:

( 2 ) The name of the archive file that is going to be generated or modified is represented by the archive_file argument. It can have extensions that match the compression scheme being used (such as.tar.gz,.tar.bz2, or.tar.xz), or it can only have the extension.tar for an uncompressed archive.

( 3 ) The parameter files/directories represent the directories or files that should be included in the archive. By separating them with spaces, you can specify the number of files and directories.

( 4 ) The tar command can generate, extract, or update archive files depending on the operation and arguments chosen.

Here are some instances of how to use the tar command in RHEL:

1 Compress data into an archive:

tar -czvf archive.tar.gz file1.txt file2.txt directory/

File1.txt, File2.txt, and the directory/ directory are all created in a compressed archive file called archive.tar.gz by this command.

2 Take files out of an archive:

tar -xzvf archive.tar.gz

The archive.tar.gz file’s contents are extracted with this command and placed in the current directory.

3 An archive’s contents are listed below:

tar -tvf archive.tar.gz

A thorough list of the files and folders found in the archive.tar.gz file is displayed by this command.

Keep in mind to change directory/, file1.txt, file2.txt, and archive.tar.gz to the actual names of the files and directories you wish to generate, extract, or modify.

The tar function offers a variety of options for working with archives, choosing compression ratios, maintaining file permissions, and more. Use the man tar command in the terminal to view the tar command’s manual page and explore all of your choices.

12. When using Linux, the “unzip” tool is used to extract files from ZIP archives. It enables you to unzip a ZIP file and extract its contents into a chosen location.

The “unzip” command’s fundamental syntax is as follows:

unzip [options] zipfile.zip [-d destination_directory]

The ZIP archive you want to extract is called “zipfile.zip” in this case. “-d destination_directory” is an optional flag that defines the directory where you want the files to be extracted. The “options” are additional flags you can use to change the behavior of the command. The files will be extracted into the currently active working directory if the destination directory is not specified.

Following are a few often-used options for the “unzip” command:

( 1 ) List the ZIP archive’s contents without extracting them with the -l option.

( 2 ) -o: Replace existing files automatically without asking.

( 3 ) Quiet mode, or -q. Suppress the extraction’s output.

( 4 ) -d: Indicate the location of the files that will be extracted.

Example of use

1 Get every file out of a ZIP archive:

unzip myfile.zip

2 A ZIP archive’s contents should be extracted into a specific directory:

unzip myfile.zip -d /path/to/destination/

3 Give a list of a ZIP archive’s contents:

unzip -l myfile.zip

These are but a handful of instances of how to employ the “unzip” command. Using the “man unzip” command, you can see the command’s documentation page to learn more about your options.

13. alias  A custom shortcut or shorthand for a lengthier or more complex command can be created in Linux using an alias. You can create your own command names or change the names of already existing commands to make them simpler to recall or type. In essence, an alias is a mapping between a unique name and the command or group of instructions it stands for.

Use the “alias” command, followed by the desired alias name and the command or commands it should represent, to define an alias. Here is the fundamental syntax:

alias alias_name='command'

Here, “alias_name” is the name you wish to give the alias, and “command” is the command itself or a group of commands you want to link to the alias. The command(s) may contain any legal shell syntax, including arguments, pipes, and options.

For instance, suppose you wish to make a shorter alias for the “ls -l” command, which displays a full list of files. An alias can be defined as follows:

alias ll='ls -l'

Now, the “ls -l” command will be run anytime you type “ll” in the terminal and press Enter. This can help you save time and use the command line more effectively.

In order to maintain them between sessions, aliases are often defined in the shell’s configuration files, such as “/.bashrc” or “/.bash_profile”. As soon as an alias is created, you can use it in the current terminal session. Make sure to include the alias definition in the relevant configuration file, though, if you want the alias to be accessible in each new terminal session.

You can use the “alias” command without any arguments to obtain a list of the aliases that are currently defined:

alias

A list of aliases and their definitions will then be shown.

It’s crucial to remember that aliases are unique to the shell you’re currently using. You might need to modify your aliases in the configuration file of the new shell if you transition from one shell to another (for example, from Bash to Zsh).

14 cat: The “cat” command, which stands for “concatenate,” is used largely in Linux to display a file’s contents or to concatenate multiple files and display their contents simultaneously. It is a straightforward command that can be used in a variety of situations.

The “cat” command’s fundamental syntax is as follows:

cat [options] [filename]

The name of the file you want to show or concatenate is referred to as the “filename” in this case. To concatenate and show multiple filenames with their contents combined, separate the filenames by spaces. Without a filename, “cat” will read data from standard input, which is often the keyboard.

The cat command is frequently used for things like:

1 presenting a file’s content:

cat filename

2 combining many files together and showing their contents:

cat file1 file2

3 Use input from the terminal to create a new file or replace an existing one:

cat > filename

By doing so, you can type the contents of the file, and hit Ctrl + D ends the input.

4 Adding terminal input to a file that already exists:

cat >> filename

By doing this, you can add content to an existing file.

These are but a handful of applications for the cat command. It can be used with other commands to carry out more complicated actions and supports a number of options. If you’d like more information on the usage and options of the cat command, you may look them up in the manual by typing man cat in the terminal.

15. tail In Linux, the tail command is a command-line tool that is used to show the last few lines of a file or to continually check a file for newly added lines. When looking through recent additions to a file, such as log files, it is especially helpful.

The tail command is generally used as follows:

tail [options] [file(s)]

In this case, [file(s)] stands for the name(s) of the file(s) you want to display, and [options] refers to the numerous command arguments that change the behavior of the tail command.

The tail command is frequently used for things like:

1 displaying a file’s latest 10 lines (the default setting):

tail filename

2 displaying a set amount of lines from a file’s end:

tail -n <number-of-lines> filename

The last 20 lines of the file will be shown, for instance, when the tail -n 20 filename is used.

3 checking a file for new lines continuously (like the tail -f command):

tail -f filename

This will run the command continually, updating the output when new lines are added to the file, and display the most recent 10 lines of the file. Real-time log file monitoring is frequently done using it.

These are only a few uses of the tail command. It offers a lot of options, including the ability to display lines in reverse order, a specific number of bytes, and more. If you want full information on the usage and options of the tail command, type man tail in the terminal.

16. grep Linux has a robust command-line tool called grep that can be used to look for particular regular expressions or patterns in files or the output of other programs. The acronym GRE Print means “global regular expression print.”

The grep command is generally used as follows:

grep [options] pattern [file(s)]

Here, pattern denotes the text or regular expression you want to search for, [options] denotes the numerous command options that change the behavior of the grep command, and [file(s)] denotes the name(s) of the file(s) you wish to search within. Grep will search the standard input (such as the output of another command) if no files are given.

The grep command is frequently used for things like:

1 Finding a certain pattern in a file:

grep "pattern" filename

The given file will be searched for the specified pattern, and all matching lines will be displayed.

2 Finding a trend across several files:

grep "pattern" file1 file2

In both file 1 and file 2, the pattern will be looked for, and the matching lines and accompanying file names will be displayed.

3 Recursively searching directories

grep -r "pattern" directory

All files in the specified directory and its subdirectories will be searched for the pattern.

4 Without regard to the case:

grep -i "pattern" filename

A case-insensitive search will be conducted using this, disregarding the difference between capital and lowercase letters.

5 Regular expressions usage

grep -E "regex-pattern" filename

By enabling extended regular expressions, more intricate pattern matching is made possible.

These are only a few applications of the grep command. To execute more complex searches and manipulations, it provides a number of arguments and can be used in conjunction with other commands. By running man grep in the terminal, you may see the grep command’s manual page for further information on its usage and its options.

17 echo: Linux comes with a command-line tool called echo that can be used to show a line of text or the value of a variable on the terminal. It can be used interactively at the terminal, although it is typically used for printing messages or showing data within shell scripts.

The echo command can be used in the following ways.

echo [options] [text or variables]

In this case, [options] refers to the numerous command parameters that change how the echo command behaves, and [text or variables] stands for the text or variables whose values you want to display.

The echo command is frequently used for things like:

1 showing one line of text

echo "Hello, world!"

This causes the terminal to print the text that is supplied.

2 Putting a variable’s value on display:

my_var="Hello, world!"
echo $my_var</pre>

This will display “Hello, world!” as the value of the variable my_var.

3 Multiple lines of text displayed:

echo "Line 1"
echo "Line 2"

By doing this, the terminal will print each line of text separately.

4 removing the final newline after a line break:

echo -n "Hello"

The newline character is not displayed at the conclusion when the -n option is used, allowing you to continue on the same line.

These are only a few applications of the echo command. It provides a number of options, like enabling backslash escape interpretation, managing output formatting, and more. If you want full information on the usage and options of the echo command, type man echo into the terminal.

18 .chown  Change the ownership of files and directories in RHEL (Red Hat Enterprise Linux) by using the chown command. “Chown” is an acronym for “change owner.” It enables you to change a file or directory’s user and group ownership.

The chown command has the following basic syntax:

chown [OPTIONS] USER[:GROUP] FILE...

The following are the command’s essential elements:

( 1 ) The new owner of the file or directory is specified by USER. A username or a numerical user ID are both acceptable.

( 2 ) Names the new group that will be the owner of the file or directory in GROUP (optional). It might be a group name or a group ID, just like the user.

( 3 ) FILE: Indicates which file or directory the ownership change will affect. Multiple files or folders can be specified, with spaces separating them.

The following are some frequently used chown command options:

( 1 ) Changes ownership recursively, affecting all files and directories inside the specified directory, using the option -R or –recursive.

( 2 ) -v or –verbose: Shows descriptive output that details the modifications the command made.

( 3 ) Similar to the -v option, the -c or –changes option only shows the output for files whose ownership has changed.

Several uses for the chown command are shown below:

1 Changing a file’s owner:

chown john myfile.txt

2 Recursively modify a directory’s owner and group:

chown -R john:users mydir/

3 Multiple files can have their owners and groups changed:

chown user1:group1 file1.txt file2.txt

Keep in mind that administrative privileges are often needed to use the chown command.

19. chmod:  The permissions (access rights) of files and directories can be changed in RHEL (Red Hat Enterprise Linux) by using the chmod command. “Chmod” is an acronym meaning “change mode.” You may manage who has access to a file or directory and who can read, write, and execute code.

The chmod command’s basic syntax is as follows:

chmod [OPTIONS] MODE FILE...

( 1 ) The permissions to be set are specified by MODE. It might be formulated numerically or symbolically

( 2 ) The file or directory whose permissions are being altered is specified by the FILE keyword. Multiple files or folders can be specified, separated by spaces.

There are two ways to display the permissions:

1. Symbolic Mode: In the symbolic mode, permissions are represented by letters that both identify the type of permission and the user or group they apply to. The used letters are

( 1 ) g: Group
( 2 ) u: User (owner)
( 3 ) a: All (equivalent to u+g+o)
( 4 ) o: Other (everyone else)

( 1 )  The following letters stand in for the different types of permissions:

(1 ) r: Read
( 2 ) w: Write
( 3 ) x: Execute

( 2 ) The following symbols can be used in symbolic mode to give or revoke permissions:

( 1 ) +: Adds the specified permission
( 2 ) -: Removes the specified permission
( 3 ) =: Sets the specified permission and removes all others

code is written in bash

chmod ug=rw,o=r myfile

2. Numeric Mode: The numeric mode uses a three-digit octal number to denote the permissions. The permissions for the owner, group, and others are each represented by a different numeral. By adding the values for the desired permissions, the digits can be calculated:

( 1 ) Read (r): 4
( 2 ) Write (w): 2
( 3 ) Execute (x): 1

For instance, you may use the following to grant the owner read and write access while granting others only read permission:

code is written in bash

chmod 644 myfile.txt

The following are some frequently used chmod command options:

( 1 ) R or –recursive: Recursively modifies permissions for all files and folders inside the specified directory

( 2 ) -v or –verbose: the command’s modifications are displayed in detail in the output.

( 3 ) -c or –changes: Similar to the -v option, but only shows the output for files with modified permissions.

It’s important to keep in mind that the chmod command often needs administrative rights.

20 umask: For freshly created files and directories in RHEL (Red Hat Enterprise Linux), the umask command is used to specify the default file permissions. The word “umask” is an acronym for “user file creation mask.” It is a four-digit octal number that represents the rights that should be removed from newly created files’ default permissions.

The umask command often has the following syntax:

umask [options] [mask]

Here, [mask] provides the file permission mask you want to configure, and [options] depicts several command arguments that can be used with the umask command. The current umask value is shown if the [mask] option is left out.
An octal four-digit number serves as the representative for the file permission mask. The authorization bits for the owner, group, and others are assigned to each digit, correspondingly. Each digit can have a value between 0 and 7, with 0 denoting full permission (read, write, and execute) and 7 denoting no authorization.

The significance of each digit is broken down below:

( 1 ) The file owner’s (user’s) permissions are represented by the first digit.

( 2 ) The file’s group owner’s permissions are represented by the second digit.

( 3 ) Users who are neither the owner nor a member of the group have their permissions represented by the third digit.

Subtract the chosen digit from 7 to determine the total permit. The default permissions for newly generated files are 644 (666 – 022) and for directories are 755 (777 – 022), for instance, if the umask value is 022.

Note: The default permissions for new files and directories are the only ones that the umask command changes. Existing files and folders’ permissions are not changed by it.

For further information and thorough usage examples unique to your version of RHEL, consult the umask man page (man umask).

Author

by admin

bg

Subscribe to our Newslatter

Sign Up to Our Newsletter to Get Latest Updates & Services

mail box
logo-footer
HighSky IT Solutions Pvt. Ltd. is a leading IT training and certification programs in Red hat, RSCSA Cloud, Open-source, AWS, Devops and various domains.
Contact Info

2nd floor, Rohera Arcade, opp SOTC office, Near Navrangpura police station, Navrangpura, Ahmedabad -380009 Gujarat

Copyright ©2024 Design & Developed by HighSky IT