1. Home
  2. Training Library
  3. LPIC-1 101 Linux certification - Introduction (1 of 5)

Survival Skills: the command line interface (CLI) and Filesystems

play-arrow
Start course
Overview
DifficultyBeginner
Duration31m
Students2055

Description

The eleven courses in this Linux certification series will prepare you for the Linux Professional Institute LPIC-1 certification exam. While the series' main focus will be on Linux, where there's a parallel or overlap with the professional administration of deployments on Amazon's AWS architecture, we'll also highlight the skills you'll need to integrate the cloud into your Linux portfolio.

The cloud is the future, and Linux skills are the tools you'll need to get there.

This first course will introduce you to:

  • the Linux ecosystem
  • the structure and expectations of the LPIC exam
  • the way the eleven courses that make up this series will be organized, and
  • some critical survival skills that will help place your Linux skills on a solid foundation.

The next course in this series will focus on System Architecture.

If you have thoughts or suggestions for this course, please contact Cloud Academy at support@cloudacademy.com.

Transcript

You might not yet have all that much practical experience using the Linux command line interface - or the Terminal, as it's often known - but you should definitely expect that to change as you move through this series. However, there are some basic skills that you'll need right away and, even though we're going to discuss all these details in later videos, it makes a lot of sense to spend a few minutes up front learning them.

Some basic Linux command line survival skills

Just to make sure that I'm not leaving anyone out of the loop, the first thing I'm going to show you is how to access the terminal itself - you'd be surprised how many people who have been around computers for years might not know this. Once we've got that covered, I'll describe the structure of the Linux file system, the dozen or so commands that you just can't live without, and then the art of launching shell sessions under different identities.

For those who are wondering...here's how you find the Linux Terminal. If you're using the Ubuntu Unity Desktop, you could click on the Launcher at the top of the icon panel and start typing the word terminal. Since I had just used the terminal a few moments before, Launcher anticipated that I might want the terminal even before I started typing, but typing it out will definitely get the job done.

If you're using a Linux Desktop with a more traditional interface, then you could either navigate through the Applications menu until you hit what you're after, or type the Alt and F2 keys together to display the Run Application menu, into which you can then begin typing gnome-terminal (or sometimes just terminal).

So now everyone's happy.

Now let's move on to how the Linux filesystem is organized.

With a couple of very small exceptions, all files of all kinds on a Linux install can be found somewhere beneath the root directory. Visually, the root is often represented by a single forward slash. Below root, you'll see top level directories, most of which contain system data or configuration files. Working with the contents of these directories usually requires administrator permissions - which we'll discuss a bit later. The directory that should interest us the most right now, however, is slash-home, which contains all private user files. When a new user account is added to a Linux system, a directory with the same name is created beneath the /home directory. Often, once the user logs in to the graphic desktop for the first time, a set of user directories like Desktop, Documents, Downloads, and Videos will be automatically created for him. The user will generally have the right to create, edit, and delete any files or subdirectories found beneath his or her personal home directory.

By the way, even though we call our default directory "home" it's not the same as the slash-home directory, which is actually the *parent* directory to all the user directories. That can sometimes be a bit confusing.

When a user logs on to the system and opens either the Nautilus GUI file manager or a terminal session, his default working location is always going to be his home directory, and it's there that saved files will, in most cases, end up.

This brings us to command line tools.

We'll start by learning how to move around between directories. cd stands for Change Directory and, when followed by the name of directory, will take you there. Since we're currently in our user's default home directory, we'll type cd and forward slash to move to the root directory. Type ls to list the names of all the subdirectories and files contained in this directory. To move to one of these subdirectories, type, say, cd dev. Because you didn't include a slash in front of the directory name, the system assumes that the directory location is relative to our current location. To move to a different location, you would tell Linux that this will be an absolute location by starting with a slash. In this case, we'll go to /var/log.

Let's type ls to see who lives in /var/log. As you might have guessed, it's mostly system log files. We'll spend a fair amount of time working with those in later videos. But now we'll type ls -l to see the long version of the directory listing.

Starting from the right, we see the names of each file - or, when they're colored blue, of a subdirectory. To the left is the date when the file was last updated. To the left of that is the file size in bytes, the group to which the file (or directory) belongs, then the owner and, finally, the special notation that tells us what kind of access various categories of users and groups will have to the file. Believe me, every piece of the information you see here can be important. I was once able to prove that I wasn't responsible for a bit of security breach because the date of the update in question happened to correspond to a day I was at the hospital undergoing a minor test.

By way of a quick review: ls will list files, while ls -l will give you a longer list including details about ownership and activity history. Referring to an address that starts with a slash will be interpreted as an absolute address based on the root directory. All other addresses will be understood to be relative to your current location.

At any rate, let's see what's inside some of these files. cat will scroll through an entire file - in this case, the btmp file. Let's run ls -l again to see what else we can find. Let's cat alternatives.log but, since that's a lot to type and, like all good sysadmins, we're lazy, we'll just start it off, and use the tab key on the keyboard to let Command Completion finish it for us. Command Completion will read what you've already typed, and from context, will try to guess what you're after. Over a long career, command completion can save you hundreds of hours and, perhaps, thousands of dollars on orthopedic surgery. Also: hitting the arrow-up key will populate the command line with previous commands that you've used, in reverse order.

Let's move back to our home directory - which can be done using either cd /home/ubuntu - which is my username - or cd tilda - that's the key at the top left corner of most keyboards. The tilda, in Linux commands, is used to represent a user's home directory.

Now, the next three or four commands concern file management. Touch will create an empty file with the specified name. Let's try touch newfile. Now we'll use mkdir - makedirectory - to create a new directory, called, say, newdir. Typing ls shows us that we were successful, and the file newfile and directory newdir now both exist. We can copy the file to a new location using cp newfile /home/ubuntu/newdir - which will create a copy of newfile in our new directory. We could also use cp to create a copy of the file in the current directory, but giving it a new name. Type cp newfile newerfile. Let's hit ls again to make sure everything turned out as we planned.

Rather than creating copies, we might sometimes need to move files from one location (or filename) to another. Type mv newerfile oldfile. Listing the files shows us that newerfile is gone, but oldfile now exists.

To remove - or delete - a file altogether, use rm oldfile. To remove a directory, type rm -r (for recursive) newdir.

Let's review, cat will print an entire text file to your screen, your home directory is referred to either using /home/yourname or tilda, touch will create an empty file, cp makes a copy of a file or directory, mv moves or renames a file or directory, and rm permanently removes a file or directory. For your command to affect subdirectories and their files, you must add -r for your action to be recursive. We also saw two very handy tips: arrow-up displays previous commands, and tab will enable command completion.

Linux administration permissions

You absolutely must understand how to control the way you identify yourself to the Linux system. As we've mentioned, by and large, you don't have the permissions to edit system files or files belonging to other users. As a great deal of system administration requires control of these files, you will sometimes have to assume other roles. Assuming that you are part of the sudo group (and, if you're using the account created when you installed Linux, then you probably are), you can assume admin powers for a single command by prefixing a command with the word sudo.

Therefore, for instance, it's possible to create a new file in the system root directory. Let's cd to root, and then type touch myfile. It doesn't work. But if we add sudo, we'll be asked for the login password for this account, and the file will be created. Ls shows us that it's now there.

From a security standpoint, manually using sudo for each command where it's necessary is by far the preferred way to go about it. However, there may be times when you'll need to keep admin powers for a longer session. For these times, you can type sudo su, enter your password (if necessary), and every subsequent command will work with admin powers. You leave the sudo shell by typing exit. Notice how the name used as part of the command prompt changed back and forth.

Finally, you can adopt the identity of a different system user by using su (which stands for switch user). Since there's a user on this system named Tony, let's type su tony, enter Tony's password (I sincerely hope he doesn't mind) and, again, note how the command prompt changed. Everything we will do until we exit this shell will be done as Tony.

About the Author

Students15669
Courses17
Learning paths2

David taught high school for twenty years, worked as a Linux system administrator for five years, and has been writing since he could hold a crayon between his fingers. His childhood bedroom wall has since been repainted.

Having worked directly with all kinds of technology, David derives great pleasure from completing projects that draw on as many tools from his toolkit as possible.

Besides being a Linux system administrator with a strong focus on virtualization and security tools, David writes technical documentation and user guides, and creates technology training videos.

His favorite technology tool is the one that should be just about ready for release tomorrow. Or Thursday.

Covered Topics