image
Introduction to the Shell
Introduction to the Shell
Difficulty
Beginner
Duration
1h 43m
Students
801
Ratings
5/5
Description

Red Hat Enterprise Linux (RHEL) is a rock solid commercial grade Linux operating system. If you're interested in learning RHEL from a system admins perspective then this course is for you!

The "Red Hat Enterprise Linux Technical Overview" course walks you through many of the basic system admin tasks and concepts required to administer RHEL effectively.

This course will provide you with insights to:

  • Working with the Terminal
  • Understanding the Kernel and User Spaces
  • Graphical User Interface
  • File management and the File System Hierarchy
  • Editing Files using Vim
  • Organizing Users and Groups
  • File Permissions
  • Managing Software
  • Configuring Networking
  • Controlling System Startup Processes
  • Introduction to Containers
  • Overview of Cockpit
Transcript

The Linux Shell is the environment in which you work and it's used to interface with the rest of the Operating System as well as to execute commands.

Now, Red Hat Enterprise Linux uses the Bash shell by default but users are free to change their shells. The Bash shell however is a good place for newcomers to start.

Now, here're a couple of things that you need to know. When you look at the prompt, you should see a $ sign, if you are logged in as a normal user. This is your visual cue that you login as a normal user. As opposed to, and I'm going to switch tabs right now, you can see that I've got a # sign in my prefix.

As opposed to this tab over here, where you can see that I've got a # sign in my prompt and this is indicative that I am logged in as an administrative user.

The administrative user in Linux is called root. And again, this is important information because when you are reading documentation, if a command is prefixed with a $ symbol, it means that you don't have to type in the $ symbol and it in fact means that the command is meant to be executed as a normal user. As opposed to having a command prefixed with a # sign, it means that the command is meant to be executed as a root user. Now, talking about executing commands very often, we make use of commands with options which influence how the command is executed and also arguments. Arguments are very often the objects, that the command works against. Your Linux system has a number of amazing documentation references.

Chief amongst those would be your manual pages or man pages for short. Now, what you're looking at right now, is the man page for a command called ls and you can see over here that it's used to list directory contents. Having a look at the synopsis, it gives us more information about how you would go about executing this command. So, we have the ls command and then we have OPTIONs. Now, anything that is enclosed in square brackets [ ], those would be optional entities. So, what this is telling us right now is, that you could execute the ls command without any options.

However, the ellipsis afterwards outside of the square brackets over there, tells us that you can make use of multiple options. Similarly, you could see that the ls command may be executed against an object and that object would be a FILE.

As opposed to something like a username for example.

So, the object or the argument would be a FILE, and again it's optional you don't have to specify a file.

However, should you want to specify multiple files, you can. And again it's as a result of that ellipsis afterwards. So, when it comes to documentation in Linux the notation or the the synopsis is very important and again looking at this brackets, things are optional, ellipsis, you can make use of multiples. Now, further below you can see that we have the options and their meanings and you can see that one of the options that we have is, -a and you can also make use of --all. They both mean the same thing and again what's happening over here, is that the a tells us, that we are going to show all files, even those files that begin with a period. Typically, files that begin with a period are hidden from normal view. Now, the single - in front of it tells us that the option is an abbreviated form, as opposed to a  - which typically means that the option is meant to be interpreted as an entire word. Now, let's going to have a look at the following. I'm going to do a directory listing right now, and I'm not going to specify an option. I'm not going to specify any arguments. And you can see that I have a result. You can see that I have dirA and I have file1. Now, let's go and make use of an option.

So, again, I'm going to use ls -a and you can see over here that it now shows me those files that begin with the dot, that begin with the period and again those would typically be a hidden from your normal view. Now, what I'm going to do next is that, I'm going to run ls -all.

Now, what's really important to remember over here is that, I'm making use of three different options. a is going to be the one option and I'm using the l option twice. So, again it's got a completely different meaning, as opposed to if I had to run ls --all. Now, in this particular case, we are interpreting the entire word. In other words, all the characters that make up the option as one option. And you can see that we have a very different results. Now, next I'm going to show you how to make use of the ls command with an option against an argument and again using multiple arguments.

So let's go and do an ls, a directory listing using an option called -l.

We're going to do a long listing right now and are we going to do it against file1.

So, ls would be the command, the -l would be the option and then we have file1 which would be an example of the argument.

So, let's go have a look at that result. Now, a command may also be constructed in the following way, in which case I'm running the ls command using one option against two arguments. The two arguments would be file1 and fileA.

And I'm not breaking any rules over here because if we go back to the man page which tells us more about how to make use of the ls command. In the synopsis, it says, well, you can make use of multiple options and you're allowed to make use of multiple arguments. So, let's get have a look at the output of that command and you can see that it works perfectly. So, guys if you want to access man pages on a Linux system you can make use of the command man and then very often you could refer to a command or a configuration file for example. So, let's go and have a look at one more over here. I'm going to show you the man page for a tool called crontab and you can see that the purpose of crontab is to maintain crontab files for individual users. Now, look at the synopsis over here. You could see that it could get quite complex and the interpretation thereof is very important.

So, looking at running the crontab command you can run it against a file.

So, in this particular case, using this notation over here, you would use an argument. Further to that, the use of a user or the use of the -u option is optional. Again, it's enclosed in square brackets. Now, looking at the notations slightly below that, we have crontab and again the -u and then the reference to the user as the argument would be optional. However, this is very interesting notation that we have of over here. You see, when you have options that are separated by a pipe, it means that you can only make use of one of them at a time. So, you could make use of crontab -l or you can make use of crontab -r or you can make use of crontab -e. 

You wouldn't be able to make use of those options in one particular command and then the use of the -i in the -s those would be completely optional. Now, looking at the next example that we have over here, you could say crontab and then you would specify -n and if you are going to make use of -n, you could optionally specify a hostname and then we have a couple of other examples of how you could execute crontab.

Now, the question that I very often ask my students is, Can I run the crontab command on its own, without specifying any options and without specifying any arguments?

And the answer is, Yes! you can. And here's why. When you look at that second example of the synopsis over here, you could see that every item over here is in square brackets and that means that we can run the crontab command without any options and without any arguments.

Something important that you ought know about right now is, how to get out of a man page.

I showed you how to access a man page. To get out, simply hit q on your keyboard.

Now, most production servers don't have a keyboard, mouse, and monitor connected to them and they are located in icy-cold server rooms anyway.

So, a popular way to send commands would be to use a remote shell. So, for that, we have the ssh protocol. An ssh stands for secure shell and is a protocol for providing you with just that. So, let's can have a look at this tab over here.

I've got to command queued up already.

You can see that the command is ssh and we're wanting to make a connection to a remote server as the user student and the server that we are connecting to is called servera. So, in this particular case guys, you could see that I was logged into a computer called demo, as a user called kiosk and right now my prompt reveals that I'm logged in as a user called students, at a server called servera.

So, with that guys, that's some basic information about the shell.

I will see you in the next video.

 

About the Author
Students
143181
Labs
69
Courses
109
Learning Paths
209

Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.

He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, Azure, GCP), Security, Kubernetes, and Machine Learning.

Jeremy holds professional certifications for AWS, Azure, GCP, Terraform, Kubernetes (CKA, CKAD, CKS).

Covered Topics