Basic Linux Commands: Beginners Friendly

Basic Linux Commands: Beginners Friendly

So, you've decided to learn Linux! Congratulations – you're in for a world of fun and flexibility. But where do you start? This guide will take you through the basics of Linux in minutes to hit the ground running. Keep in mind that every distribution (or "distro") of Linux is different, so there may be some small differences between what we cover here and what you see on your screen. But don't worry: with a little exploration, you'll be a Linux pro in no time!

Filesystem Hierarchy Standard in Linux

You've just logged into your Ubuntu distro for the first time and were greeted by the command line. You type in a few basic commands and navigate your way around the file system. But what exactly is the file system? How is it organized?

In Linux, the file system is organized into a hierarchy. This means there is a leading directory, which contains subdirectories, which may include other subdirectories, and so on. The main directory is usually represented by a forward slash ( / ).

You can think of the file system hierarchy as a family tree. At the tree's root is the main directory, which contains all the other directories and files. Each subdirectory can be considered a child of the main directory, and each file can be considered a grandchild.

The file system hierarchy helps keep everything organized so that you can easily find what you're looking for. It also helps to prevent files from being overwritten or accidentally deleted. Suppose you understand how the file system hierarchy works. In that case, you'll be able to navigate your way around the Linux command line with ease.

image.png

The root directory (/): The root directory is the top-level directory in a Linux file system. It is represented by a forward slash (/). All other directories in the file system are subdirectories of the root directory.

image.png

/bin: This directory is where many of the most important executables are stored, including ls, cp, and mv.

/boot: Simply put, it is a directory that contains all the files needed to boot your Linux system. This includes the kernel, initial RAM disk, and other important files. Without /boot, your system would not be able to start up!

/dev: This directory contains all the device files. These files can be used to access various hardware devices on the system, such as keyboards, printers, and storage devices.

/etc: Also known as the "etcetera directory," is a folder on Unix-based operating systems that contains system-wide configuration files. These config files control everything from the system's overall appearance to how individual applications behave.

/lib: This directory contains essential shared library files used by various programs on your system. Without these files, your programs wouldn't be able to run.

How To Use The Linux Command Line

For those of us who are new to Linux, the terminal can be a bit intimidating. After all, it's where we type in commands that can potentially delete all of our data!

So, let's start with the basics: how do we open the terminal? In most cases, it's as simple as opening the "Terminal" application from your applications menu. Once you've done that, you should see a window with a black background and white text. Congratulations, you're now in the terminal!

Now that you know how to open the terminal, let's talk about what happens when you type in a command. When you type in a command and hit enter, Linux will look for a program on your computer that knows how to execute that command. If it finds one, it will execute the command and print the output to the terminal window. It will print an error message if it doesn't find a program that knows how to execute the command.

So there you have it: the basics of using the terminal in Linux. With just a few commands, you can accomplish a lot! But don't worry if you don't remember everything right away - there's plenty of help available online if you get stuck.

Basic Linux commands every user should know

There are a few basic Linux commands that every user should know. These commands can help you navigate your file system, manage files and directories, and even run programs. Let's talk about some of them.

Pwd

The pwd command displays the current working directory.

image.png

Let's do a little analysis of the omisore76@omisore76-VirtualBox: ~/Desktop$ pwd

omisore76 shows the user's name currently logged in.

omisore76-VirtualBox shows the Linux machine, host, or server name.

The tilde symbol ~ represents the home directory.

/Desktop shows we are in the Desktop directory.

The dollar symbol $ shows that we are logged in as a normal user. This sign is replaced with the hash symbol # when a root/superuser is logged in. Commands are written after the $ or # symbol

Mv

The mv command helps you to move files and directories around.

image.png

Ls

This command is used to list the contents of a directory. You can use it to see what files and folders are in your current location.

image.png

Cd

This command is used to change directories. You can use it to move around your file system. Typing just the cd will take you to the home directory.

To use the cd command, simply type "cd" followed by the name of the directory you want to change to. For example, to change to the "Desktop" directory, you would type cd Desktop. You can also use the cd command to change to a parent or child directory. To do this, simply type cd .. to change to the parent directory, or cd . to change to the child directory.

image.png

Mkdir

This command is used to create new directories. This is helpful if you want to organize your files into different folders. For example, to create a directory called "playground," type mkdir playground into the terminal.

image.png

Rm

This command is used to delete files and directories. This is a powerful command, so be careful when using it!

image.png

Cat

The Cat command allows you to view the contents of a file. To view the contents of a file named "deluser.conf," type cat deluser.conf into your playground.

image.png

Man

The Man command provides access to the manual pages for a particular command. To use the man command, simply type man followed by the name of the command you want more information about. For example, typing man ls would bring up the documentation for the "ls" command, which lists the contents of a directory.

image.png

Touch

the touch command allows you to create a new file.

image.png

Nano

The Nano command helps you to edit text files.

image.png

Useful tips and tricks for using Linux

As you might have noticed, most Linux commands are abbreviations. For instance, the man stands for manual, rm stands for remove, and cd stands for change directory. This was to make each command easy to understand.

In addition, when typing a command or directory, you can use the tab key for autocompletion. If there are many commands, directories, and files with the name you have typed, Linux will display them. For example, if you have multiple folders on your Desktop with the name "test," then typing "cd test" and pressing the tab key will show all of the options for "test" folders on your Desktop. Then, you can use the arrow down key to the correct folder and press enter. This is a helpful way to autocomplete directories, especially when many options have similar names.

So, there you have it. Some basic Linux commands to get you started in your Linux journey. Do you have a favourite command that wasn't mentioned here? Let me know in the comments below, and I'll be sure to add it to the list.